datasets_api package
Subpackages
- datasets_api.migrations package
- Submodules
- datasets_api.migrations.0001_initial module
- datasets_api.migrations.0002_dataset_groups module
- datasets_api.migrations.0003_alter_dataset_options module
- datasets_api.migrations.0004_dataset_broken module
- datasets_api.migrations.0005_dataset_dataset_name module
- datasets_api.migrations.0006_datasethierarchy module
- datasets_api.migrations.0007_datasethierarchy_direct module
- datasets_api.migrations.0008_datasethierarchy_instance_id module
- Module contents
- datasets_api.tests package
- Submodules
- datasets_api.tests.conftest module
- datasets_api.tests.test_datasets_api module
test_datasets_api_get_404()
test_datasets_api_get_all()
test_datasets_api_get_forbidden()
test_datasets_api_get_one()
test_datasets_api_parents()
test_datasets_api_visible_datasets()
test_datasets_default_description_editable()
test_datasets_description_get()
test_datasets_description_not_admin()
test_datasets_description_post()
test_datasets_federation()
test_datasets_hierarchy()
test_datasets_hierarchy_hidden()
test_datasets_pedigree_no_such_column()
test_datasets_pedigree_no_such_dataset()
test_datasets_pedigree_proper_request()
test_datasets_permissions()
test_datasets_permissions_search()
test_datasets_permissions_search_nonexistent()
test_datasets_permissions_single()
test_datasets_permissions_single_missing()
test_user_client_get_nonexistant_dataset_details()
- datasets_api.tests.test_permissions module
na_user()
omni_dataset()
test_any_user_propagates_to_children()
test_any_user_propagates_to_parents()
test_any_user_with_anonymous()
test_basic_rights()
test_dataset_group_rights()
test_dataset_group_rights_gives_access_to_all_descendants()
test_dataset_group_rights_gives_access_to_parent_dataset()
test_dataset_group_rights_mixed()
test_datasets_studies_ids()
test_disable_permissions_flag_allows_all()
test_nauser_user_and_dataset_groups_getter_methods()
test_parents()
test_permissions_give_access_to_parent()
test_unregistered_dataset_does_not_propagate_permissions()
test_user_and_dataset_groups_getter_methods()
- Module contents
Submodules
datasets_api.models module
- class datasets_api.models.Dataset(*args, **kwargs)[source]
Bases:
Model
Datasets and permissions on datasets.
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- ancestor
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- broken: BooleanField
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- dataset_id: TextField
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- dataset_name: TextField
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property default_groups: list[str]
- descendant
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- groups: ManyToManyField
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>
- classmethod recreate_dataset_perm(dataset_id: str) None [source]
Add the default groups to a dataset object.
- class datasets_api.models.DatasetHierarchy(*args, **kwargs)[source]
Bases:
Model
Data for dataset hierarchy and inheritance.
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- classmethod add_relation(instance_id: str, ancestor_id: str, descendant_id: str, *, direct: bool = False) None [source]
Add a relation to the hierarchy with provided dataset IDs.
- ancestor: ForeignKey
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- ancestor_id
- descendant: ForeignKey
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- descendant_id
- direct: BooleanField
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod get_children(instance_id: str, dataset: Dataset, *, direct: bool | None = None) list[Dataset] [source]
Return all children of a given dataset.
- classmethod get_direct_datasets_parents(instance_id: str, datasets: Iterable[Dataset]) dict[str, list[str]] [source]
Return dictionary of parents for a list of DB datasets.
- classmethod get_parents(instance_id: str, dataset: Dataset, *, direct: bool | None = None) list[Dataset] [source]
Return all parents of a given dataset.
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- instance_id: TextField
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod is_study(instance_id: str, dataset: Dataset) bool [source]
Return whether a dataset is a study.
A dataset without children is a study and not a group.
- objects = <django.db.models.manager.Manager object>
datasets_api.permissions module
- class datasets_api.permissions.IsDatasetAllowed[source]
Bases:
BasePermission
Checks the permissions to a dataset.
- has_object_permission(request: HttpRequest, _view: Any, obj: str) bool [source]
Return True if permission is granted, False otherwise.
- has_permission(request: HttpRequest, view: Any) bool [source]
Return True if permission is granted, False otherwise.
- static permitted_datasets(user: User, instance_id: str) Iterable[str] [source]
Return list of allowed datasets for a specific user.
- static prepare_allowed_datasets_query() str [source]
Return query for getting all datasets a user has access to.
This handles cases in the hierarchy where there are partial rights. Query is divided and abstracted into multiple Common Table Expressions. The query has a single parameter for user ID and returns rows of dataset DB ID and WDAE ID pairs.
user_to_group joins users with their respective groups. dataset_to_group joins datasets with their respective groups.
from_root and to_root are recursive and walk through the dataset hierarchy from a given dataset ID in the respective direction.
dataset_branch combines from_root and to_root to give all datasets present in a dataset hierarchy “branch”.
- datasets_api.permissions.get_allowed_genotype_studies(instance_id: str, user: User, dataset_id: str) set[str] [source]
Collect and return genotype study IDs the user has access to.
- datasets_api.permissions.get_dataset_info(dataset_id: str) dict[str, Any] | None [source]
Return a dictionary describing a Dataset object.
- datasets_api.permissions.get_directly_allowed_genotype_data(user: User) list[dict[str, Any]] [source]
Return list of genotype data the user has direct permissions to.
- datasets_api.permissions.get_instance_timestamp_etag(_request: Request, **_kwargs: dict[str, Any]) str [source]
- datasets_api.permissions.get_permissions_etag(request: Request, **_kwargs: dict[str, Any]) str [source]
Return E-Tag for queries dependant on user access permissions.
- datasets_api.permissions.get_wdae_children(instance_id: str, dataset_id: str) list[Dataset] [source]
Return list of child wdae dataset objects.
Given a dataset ID or DAE genotype data object or WDAE dataset object, returns list of direct childrens as WDAE dataset object (if ‘leaves’ parameter is ‘False’). If ‘leaves’ parameter is ‘True’, returns list of leaves of the datasets tree.
- datasets_api.permissions.get_wdae_dataset(dataset: str) Dataset | None [source]
Return wdae dataset object.
Given a dataset ID or DAE genotype data object, returns WDAE dataset object.
- datasets_api.permissions.get_wdae_parents(instance_id: str, dataset_id: str, *, direct: bool = False) list[Dataset] [source]
Return list of parent wdae dataset objects.
Given a dataset ID or DAE genotype data object or WDAE dataset object, returns list of parents as WDAE dataset object.
- datasets_api.permissions.handle_partial_permissions(instance_id: str, user: User, dataset_id: str, request_data: dict) None [source]
Handle partial permission on a dataset.
A user may have only partial access to a dataset based on which of its constituent studies he has rights to access. This method attaches these rights to the request as study filters in order to filter variants from studies the user cannot access.
datasets_api.urls module
datasets_api.views module
- class datasets_api.views.BaseDatasetPermissionsView[source]
Bases:
QueryBaseView
Base dataset permission view.
- class datasets_api.views.DatasetDescriptionView[source]
Bases:
QueryBaseView
Provide fetching and editing a dataset’s description.
- class datasets_api.views.DatasetHierarchyView[source]
Bases:
QueryBaseView
Provide the hierarchy of one dataset configured in the instance.
- class datasets_api.views.DatasetPedigreeView[source]
Bases:
QueryBaseView
Provide pedigree data for a given dataset.
- class datasets_api.views.DatasetPermissionsSingleView[source]
Bases:
BaseDatasetPermissionsView
Single dataset permission view.
- page_size = 25
- class datasets_api.views.DatasetPermissionsView[source]
Bases:
BaseDatasetPermissionsView
Dataset permissions view.
- page_size = 25
- class datasets_api.views.DatasetView[source]
Bases:
QueryBaseView
General dataset view.
Provides either a summary of ALL available dataset configs or a specific dataset configuration in full, depending on whether the request is made with a dataset_id param or not.
- class datasets_api.views.FederationDatasetsView[source]
Bases:
QueryBaseView
Class used for federation-related dataset requests.
- class datasets_api.views.VisibleDatasetsView[source]
Bases:
QueryBaseView
Provide a list of which datasets to show in the frontend.
- datasets_api.views.augment_accessibility(dataset: dict[str, Any], allowed_datasets: Iterable[str]) dict[str, Any] [source]
Augment a dataset response JSON with access_rights section.
- datasets_api.views.augment_with_groups(dataset: dict[str, Any], db_dataset: Dataset | None = None) dict[str, Any] [source]
Add groups to response object.