utils package

Submodules

utils.authentication module

Module containing a custom OAuth2 authentication class.

class utils.authentication.GPFOAuth2Authentication[source]

Bases: OAuth2Authentication

Provide custom OAuth2 authentication.

This authentication class that will return a 401 error in the case that an invalid OAuth token has been provided. We need this behaviour as we have routes which will allow unauthenticated requests, which in turn prevents distinguishing requests with expired tokens from those that bear no authentication headers.

authenticate(request: HttpRequest) tuple | None[source]

Returns two-tuple of (user, token) if authentication succeeds, or None otherwise.

class utils.authentication.SessionAuthenticationWithUnauthenticatedCSRF[source]

Bases: SessionAuthentication

Session authentication with unauthenticated CSRF.

authenticate(request: Request) tuple | None[source]

Return the currently logged-in user or None otherwise.

class utils.authentication.SessionAuthenticationWithoutCSRF[source]

Bases: SessionAuthentication

enforce_csrf(request: Request) None[source]

Enforce CSRF validation for session based authentication.

Middleware patch to allow storing OAuth tokens as cookies.

utils.datasets module

utils.datasets.find_dataset_id_in_dict(dictionary)[source]
utils.datasets.find_dataset_id_in_request(request)[source]

utils.email_regex module

utils.email_regex.is_email_valid(email: str) bool[source]

utils.expand_gene_set module

utils.expand_gene_set.expand_gene_set(data: dict) dict[source]

Expand gene set to list of gene symbols.

utils.expand_gene_set.expand_gene_syms(data: dict) dict[source]

Expand gene set symbols.

utils.gene_sets module

utils.gene_sets.get_denovo_gene_set_spec(gene_sets_types: list[Any]) dict[str, Any][source]

Convert typescript style gene sets types into python dict.

utils.logger module

utils.logger.log_filter(request: Request | WSGIRequest, message: str, *args: Any) str[source]

Filter request info for logging.

utils.logger.request_logging(logger: Logger) Callable[source]

Automatically log request info on views.

utils.logger.request_logging_function_view(logger: Logger) Callable[source]

Automatically log request info on view functions.

utils.pagination module

class utils.pagination.WdaePageNumberPagination[source]

Bases: PageNumberPagination

get_paginated_response(data)[source]
paginate_queryset(queryset, request, view=None)[source]

Paginate and handle empty pages by returning 204.

utils.password_requirements module

utils.password_requirements.is_password_valid(password: str) bool[source]

Validate a password.

A password is considered valid if it is at least ten symbols long and is not a commonly used (blacklisted) password.

utils.query_params module

utils.query_params.parse_query_params(data)[source]

utils.streaming_response_util module

utils.streaming_response_util.convert(obj)[source]
utils.streaming_response_util.iterator_to_json(variants)[source]

utils.testing module

utils.testing.setup_t4c8_grr(root_path: Path) GenomicResourceRepo[source]
utils.testing.setup_t4c8_instance(root_path: Path) GPFInstance[source]
utils.testing.setup_wgpf_instance(root_path: Path) WGPFInstance[source]

Module contents