Managers

Module contents

Manager subclasses for some of the app’s models.

References

Submodules

django_analyses.models.managers.analysis module

Definition of a custom Manager for the Analysis class.

class django_analyses.models.managers.analysis.AnalysisManager

Bases: django.db.models.manager.Manager

Custom Manager for the Analysis class.

from_dict(definition: dict) → Tuple[django.db.models.base.Model, bool, bool]

Gets or creates an Analysis instance based on a dictionary definition.

Parameters:definition (dict) – Analysis definition
Returns:analysis, created, versions_created
Return type:Tuple[models.Model, bool, bool]
from_list(definitions: list) → Dict[str, Dict[KT, VT]]

Gets or creates Analysis instances using a list of analysis dictionary definitions.

Parameters:definition (list) – Analysis definitions
Returns:A dictionary with analysis titles as keys and analysis version dictionaries as values.
Return type:Dict[str, Dict]

django_analyses.models.managers.analysis_version module

Definition of a custom Manager for the AnalysisVersion class.

class django_analyses.models.managers.analysis_version.AnalysisVersionManager

Bases: django.db.models.manager.Manager

Custom Manager for the AnalysisVersion class.

from_dict(analysis, definition: dict)
from_list(analysis, definitions: list) → dict
get_by_string_id(string_id: str)

Gets an AnalysisVersion instance using a string_id.

There are two valid ways to specify the string_id:

  • <analysis title>.<analysis version title> - Specific analysis version.
  • <analysis title> - Latest analysis version (by descending title order).
Parameters:string_id (str) – A string identifying some analysis version
Returns:The matching analsis version
Return type:AnalysisVersion
Raises:self.model.DoesNotExist – Matching analysis version does not exist
get_kwargs_from_definition(analysis, definition: dict) → dict

Converts a dictionary definition of an anlysis version to valid keyword arguments that can be used to create a new instance.

Parameters:
  • analysis (Analysis) – The analysis to which the created instance will belong
  • definition (dict) – Analysis version dictionary definition
Returns:

Keyword arguments

Return type:

dict

See also

django_analyses.models.managers.input_definition module

Definition of the InputDefinitionManager class.

class django_analyses.models.managers.input_definition.InputDefinitionManager

Bases: model_utils.managers.InheritanceManager

Custom manager for the InputDefinition model.

from_dict(key: str, definition: dict)

Creates an input definition (an instance of any subclass of the InputDefinition model) using the provided data. Expects definition to include a type key with the subclass (model) itself.

Parameters:
  • key (str) – Input definition key
  • definition (dict) – Any other fields to populate
Returns:

Created input definition

Return type:

InputDefinition

from_specification_dict(specification: dict) → list

Creates multiple input definitions using some specification dictionary.

Parameters:specification (dict) – A dictionary specification of input definitions
Returns:Created input definitions
Return type:list

django_analyses.models.managers.input_specification module

Definition of the InputSpecificationManager class.

class django_analyses.models.managers.input_specification.InputSpecificationManager

Bases: django.db.models.manager.Manager

Custom manager for the InputSpecification model.

filter_by_definitions(analysis, definitions: list) → django.db.models.query.QuerySet

Returns a queryset of input specifications that match the provided arguments.

Parameters:
  • analysis (Analysis) – The analysis with which the input specification is associated
  • definitions (list) – Input definitions contained in the queried specification
Returns:

Matching input specifications

Return type:

QuerySet

from_dict(analysis, specification: dict) → tuple

Creates a new input specification from a dictionary of input definitions.

Parameters:
  • analysis (Analysis) – The analysis with which the input specification will be associated
  • specification (dict) – Input specification dictionary
Returns:

  • Tuple[~django_analyses.models.input.input_specification.InputSpecification,
  • bool] – Input specification, created

django_analyses.models.managers.output_definition module

class django_analyses.models.managers.output_definition.OutputDefinitionManager

Bases: model_utils.managers.InheritanceManager

from_specification_dict(specification: dict) → list

django_analyses.models.managers.output_specification module

class django_analyses.models.managers.output_specification.OutputSpecificationManager

Bases: django.db.models.manager.Manager

filter_by_definitions(analysis, definitions: list) → django.db.models.query.QuerySet
from_dict(analysis, specification: dict) → tuple

django_analyses.models.managers.run module

Definition of the RunManager class.

class django_analyses.models.managers.run.RunManager

Bases: django.db.models.manager.Manager

Manager for the Run model. Handles the creation and retrieval of runs when Node are executed.

create_and_execute(analysis_version: django_analyses.models.analysis_version.AnalysisVersion, configuration: dict, user: django.contrib.auth.models.User = None)

Execute analysis_version with the provided configuration (keyword arguments) and return the created run.

Parameters:
  • analysis_version (AnalysisVersion) – AnalysisVersion to execute
  • configuration (dict) – Full input configuration (excluding default values)
  • user (User, optional) – User who executed the run, by default None
Returns:

Resulting run instance

Return type:

Run

filter_by_configuration(analysis_version: django_analyses.models.analysis_version.AnalysisVersion, configuration: Union[Dict[str, Any], Iterable[Dict[str, Any]]], strict: bool = False, ignore_non_config: bool = False) → django.db.models.query.QuerySet

Returns a queryset of analysis_version runs matching the provided configuration.

Parameters:
  • analysis_version (AnalysisVersion) – Analysis version runs to query
  • configuration (Union[Dict[str, Any], Iterable[Dict[str, Any]]]) – Configuration options to filter by
  • strict (bool, optional) – Whether to exclude runs with non-default value configurations not included in the provided configuration, by default False
  • ignore_non_config (bool, optional) – Whether to exclude keys that match definitions for which the is_configuration attribute is set to False, by default False
Returns:

Matching runs

Return type:

models.QuerySet

get_existing(analysis_version: django_analyses.models.analysis_version.AnalysisVersion, configuration: dict)

Returns an existing run of the provided analysis_version with the specified configuration.

Parameters:
  • analysis_version (AnalysisVersion) – The desired AnalysisVersion instance for which a run is queried
  • configuration (dict) – Full input configuration (excluding default values)
Returns:

Existing run with the specified analysis_version and configuration

Return type:

Run

Raises:

ObjectDoesNotExist – No matching run exists

get_or_execute(analysis_version: django_analyses.models.analysis_version.AnalysisVersion, configuration: dict, user: django.contrib.auth.models.User = None, return_created: bool = False)

Get or execute a run of analysis_version with the provided keyword arguments.

Parameters:
  • analysis_version (AnalysisVersion) – AnalysisVersion to retrieve or execute
  • configuration (dict) – Full input configuration (excluding default values)
  • user (User, optional) – User who executed the run, by default None, by default None
  • return_created (bool) – Whether to also return a boolean indicating if the run already existed in the database or created, defaults to False
Returns:

New or existings run instance

Return type:

Run