Scopes ====== Scopes contain datasets, generally from a long-term research projects. They serve two primary functions: they allow to assign permissions to view/create datasets to users and groups, and they can enforce data consistency by defining a schema for the attributes of the datasets they contain. While for managing schemas and users permissions we recommend using the DataQruiser app, in Python we offer the following functionality to work with scopes. Viewing Available Scopes ------------------------ To see the scopes that are available to you, use the following commands: .. code-block:: python from qdrive.scopes import get_scopes print(scopes) scopes = get_scopes() print(scopes) # Accessing the scopes first_scope = scopes[0] # Get the first scope object in the list print(first_scope.uuid) # Get the UUID of the first scope print(first_scope.name) # Get the name of the first scope Getting a scope by name (or uuid) --------------------------------- To get a scope by name (or uuid), use the following commands: .. code-block:: python from qdrive.scopes import get_scope scope = get_scope("my_scope_name") print(scope.uuid) print(scope.name) .. _setting-up-a-scope: Setting and Getting the Default Scope ------------------------------------- When performing operations like searching or creating datasets, the package assumes a default scope is set. This default scope can be set or read using the following commands: .. code-block:: python from qdrive.scopes import get_scopes, set_default_scope, get_default_scope scopes = get_scopes() # Print the name of the default scope that is currently set print(get_default_scope().name) # Set the default scope by name (option 1) set_default_scope(scopes[0].name) # Set the default scope by using the scope object (option 2) set_default_scope(scopes[0]) Setting the Default Scope in the GUI ------------------------------------ The default scope can also be set in the GUI. To do this, run the following commands: .. code-block:: python from qdrive import launch_GUI launch_GUI() Then, set the selected scope property in the GUI.