StudiesSetup

Qualified name: api.simulation.studies.studies_setup.StudiesSetup

class api.simulation.studies.studies_setup.StudiesSetup(item)[source]

Bases: ABC

Entry point for the studies API

You should create this object using the SimulationSetup object.

Methods

add_job

Adds a job from a parameters dict

add_tags

Adds tags to the available tags

create_job_setup

Creates a JobCreationContext object for handling job creation for this study

get_available_job_type_names

Get the available job type names

get_name

Returns the name of the object

remove_job

Removes a job from the study

remove_tags

Remove tags from the available tags

set_name

Changes the name of the study

set_study

Sets the study being edited in this setup object.

set_study_name

Changes the name of the study

abstract add_job(parameters_dict: dict) StudiesSetup[source]

Adds a job from a parameters dict

Deprecated

add_job will be removed in a future MORe release, it is replaced by create_job_setup() which streamlines the job creation process

Parameters:

parameters_dict (dict) – The parameters dict consisting of parameter uuid’s and parameters to add as a new job to the study

Returns:

self

Return type:

StudiesSetup

abstract add_tags(tags: List[str]) StudiesSetup[source]

Adds tags to the available tags

Example

To add tags to the list available in the program:

>>> from more.api import ApiGateway
>>> api = ApiGateway(proj=proj)
>>> simulation_setup = api.create_simulation_setup()
>>> study_setup = simulation_setup.create_study_setup().set_name(name='study_name')
>>> study_setup.add_tags(['first_tag', 'second_tag'])
<more...>
Parameters:

tags (list of strings) – A list of tag names to add to the available tags

Returns:

self

Return type:

StudiesSetup

Raises:

TypeError – Raised if a non-string value is given as one of the tags

abstract create_job_setup(job_name: str) JobCreationContext[source]

Creates a JobCreationContext object for handling job creation for this study

Example

>>> from more.api import ApiGateway
>>> api = ApiGateway(proj=proj)
>>> simulation_setup = api.create_simulation_setup()
>>> study_setup = simulation_setup.create_study_setup()
>>> print(study_setup.get_available_job_type_names()) # Check which job type names are available
[...]
>>> job_setup = study_setup.create_job_setup(job_name='Static Job') # Adds a static job and returns a job creation pipeline object
Parameters:

job_name (str) – The name of the job type to add

Returns:

An object for setting up the job

Return type:

JobCreationContext

Raises:

NameNotFoundError – Raised if no job type with the given name exists

abstract get_available_job_type_names() List[str][source]

Get the available job type names

Example

>>> from more.api import ApiGateway
>>> api = ApiGateway(proj=proj)
>>> simulation_setup = api.create_simulation_setup()
>>> study_setup = simulation_setup.create_study_setup()
>>> study_setup.get_available_job_type_names()
[...]
Returns:

The list of available job type names to use with the create_job_setup method

Return type:

list of strings

abstract get_name() str[source]

Returns the name of the object

Example

>>> from more.api import ApiGateway
>>> api = ApiGateway(proj=proj)
>>> simulation_setup = api.create_simulation_setup()
>>> study_setup = simulation_setup.create_study_setup().set_name(name='study_name')
>>> study_setup.set_name(name='new_name')
<more...>
>>> study_setup.get_name()
'new_name'
Returns:

name – The name of the object

Return type:

str

abstract remove_job(job_label: str | None = None) StudiesSetup[source]

Removes a job from the study

Example

To remove a job by label:

>>> from more.api import ApiGateway
>>> api = ApiGateway(proj=proj)
>>> simulation_setup = api.create_simulation_setup()
>>> study_setup = simulation_setup.create_study_setup()
>>> job_setup = study_setup.create_job_setup(job_name='Static Job')
>>> job_setup = job_setup.set_general_job_settings_parameter(parameter_name='label', value='first_job') \
...          .create() \
...          .set_general_job_settings_parameter(parameter_name='label', value='second_job') \
...          .create() \
...          .set_general_job_settings_parameter(parameter_name='label', value='third_job') \
...          .create()
>>> study_setup.remove_job(job_label='second_job') # Remove the second job
<more...>
Parameters:

job_label (str, optional) – The label of the job to remove, if none is specified then the last job will be removed

Returns:

self

Return type:

StudiesSetup

Raises:

NameNotFoundError – Raised if no job with the given label exists

abstract remove_tags(tags: list) StudiesSetup[source]

Remove tags from the available tags

Example

To remove tags to the list available in the program (first tags are added):

>>> from more.api import ApiGateway
>>> api = ApiGateway(proj=proj)
>>> simulation_setup = api.create_simulation_setup()
>>> study_setup = simulation_setup.create_study_setup().set_name(name='study_name')
>>> study_setup.add_tags(['first_tag', 'second_tag', 'third_tag'])
<more...>
>>> study_setup.remove_tags(tags=['first_tag', 'third_tag'])
<more...>
Parameters:

tags (list of strings) – A list of tag names to remove from the available tags

Returns:

self

Return type:

StudiesSetup

Raises:

NameNotFoundError – Raised if a tag with the given name does not exist

abstract set_name(name: str, resolve_duplicate_name: bool = False) StudiesSetup[source]

Changes the name of the study

Example

>>> from more.api import ApiGateway
>>> api = ApiGateway(proj=proj)
>>> simulation_setup = api.create_simulation_setup()
>>> study_setup = simulation_setup.create_study_setup().set_name(name='study_name')
>>> study_setup.set_name(name='new_name')
<more...>
>>> second_study_setup = simulation_setup.create_study_setup() \
...     .set_name(name='new_name', resolve_duplicate_name=True)
>>> second_study_setup.get_name()
'new_name 1'
Parameters:
  • resolve_duplicate_name (bool) – Whether to automatically assign a new name when the chosen one is already taken

  • name (str) – The new name of the study

Returns:

self

Return type:

StudiesSetup

Raises:
  • TypeError – Raised if the given name is not a string

  • NameNotUniqueError – Raised if the given name is not unique

abstract set_study(study) StudiesSetup[source]

Sets the study being edited in this setup object.

Deprecated

set_study will be removed in a future MORe release, it is replaced by the SimulationSetup

Example

This method is invoked internally when using the SimulationSetup

>>> from more.api import ApiGateway
>>> api = ApiGateway(proj=proj)
>>> simulation_setup = api.create_simulation_setup()
>>> study_setup = simulation_setup.get_study_setup(name='study_name') # invoked internally here, the study must already exist
Parameters:

study (StudyTable) – A study instance

Returns:

self

Return type:

StudiesSetup

Raises:

ValueError – Raised if the given study is not an instance of a study

abstract set_study_name(name: str) StudiesSetup[source]

Changes the name of the study

Parameters:

name (str) – The new name of the study

Returns:

self

Return type:

StudiesSetup