JobCreationContext¶
Qualified name: api.simulation.studies.job_setup.JobCreationContext
- class api.simulation.studies.job_setup.JobCreationContext(study_parameters_table_setup, job_name)[source]¶
Bases:
ABC
This class handles the creation of jobs in studies.
Creation of this class should happen through the API Gateway, see the example: The variable ‘job_setup’ will hold a reference to an object of this class
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 >>> print("Available general parameters: {}".format(job_setup.get_general_job_settings_description())) # To check which general settings are available Available general parameters: "job_type": Job type parameter ... >>> print("Available job parameters: {}".format(job_setup.get_job_type_specific_settings_description())) # To check which general settings are available Available job parameters: "single_load_case_choice": Single list choice parameter ...
This class works by first preparing the job and then applying the changes to the study using the
create()
method as in the example given:Example
Assuming that the ‘job_setup’ variable holds the reference from the example above:
>>> lcc_setup = simulation_setup.create_load_case_container_setup().set_name('example_load_case_container')
>>> study_setup.add_tags(tags=['some_tag']) <more...> >>> job_setup = job_setup.set_general_job_settings_parameter(parameter_name='tags', value=['some_tag']) \ ... .set_general_job_settings_parameter(parameter_name='label', value='example_job') \ ... .set_job_specific_parameter(parameter_name='single_load_case_choice', value='example_load_case_container') \ ... .create()
Methods
Adds a job to the Study with the settings that were added before.
Returns a description of which settings are available for this study in the 'Study settings' tab
Returns a description of which settings are available for the current job type
Returns a description of which tunable parameters are available for the given object
Sets a tunable parameter available in the 'Study settings' tab to a specific value for this job
Sets a tunable job specific parameter to a specific value for this job
Adds a tunable parameter to this job
Deprecated version of
set_general_job_settings_parameter()
- abstractmethod create() JobCreationContext [source]¶
Adds a job to the Study with the settings that were added before.
Example
>>> 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.set_general_job_settings_parameter(parameter_name='label', value='first_job') \ ... .create() <more...>
- Returns:
self
- Return type:
- abstractmethod get_general_job_settings_description() str [source]¶
Returns a description of which settings are available for this study in the ‘Study settings’ tab
Example
>>> 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='FRF Job') >>> print("Available general parameters: {}".format(job_setup.get_general_job_settings_description())) # To check which general settings are available Available general parameters: "job_type": Job type parameter ...
- Returns:
A description of the parameters available under the ‘Study settings’ tab including the names they have to be referenced by to use the
set_general_job_settings_parameter()
method.- Return type:
str
- abstractmethod get_job_type_specific_settings_description() str [source]¶
Returns a description of which settings are available for the current job type
Example
>>> 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='FRF Job') >>> print("Available job parameters: {}".format(job_setup.get_job_type_specific_settings_description())) # To check which general settings are available Available job parameters: ...
- Returns:
A description of the parameters available for this job type including the names they have to be referenced by to use the
set_job_specific_parameter()
method.- Return type:
str
- abstractmethod get_tunable_parameters_description_for_object(obj) str [source]¶
Returns a description of which tunable parameters are available for the given object
Example
>>> 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') # Adds a static job and returns a job creation pipeline object
>>> particular_property = proj.comp.find_link_properties(linkpropname='property_name').properties[0] # Assumes that a link property with this names exists and has at least one particular property >>> print(job_setup.get_tunable_parameters_description_for_object(obj=particular_property)) # Shows the parameters available to the supplied object "ku": Float parameter - ...
- Returns:
A description of the tunable parameters available the given object including the names they have to be referenced by to use the
set_parameter()
method.- Return type:
str
- abstractmethod set_general_job_settings_parameter(parameter_name: str, value: Any) JobCreationContext [source]¶
Sets a tunable parameter available in the ‘Study settings’ tab to a specific value for this job
Example
>>> 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='FRF Job') >>> print("Available general parameters: {}".format(job_setup.get_general_job_settings_description())) # To check which general settings are available Available general parameters: "job_type": Job type parameter ... >>> job_setup = job_setup.set_general_job_settings_parameter(parameter_name='save_result', value=False) \ ... .create()
- Parameters:
parameter_name (str) – The name of tunable parameter
value (Any) – The value to set
- Returns:
self
- Return type:
- Raises:
NotCompatibleError – Raised if a wrong value type is given for the general job settings
NameNotFoundError – Raised if the general job settings do not have a parameter with the given name
- abstractmethod set_job_specific_parameter(parameter_name: str, value: Any) JobCreationContext [source]¶
Sets a tunable job specific parameter to a specific value for this job
Example
>>> 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='FRF Job') >>> print("Available job parameters: {}".format(job_setup.get_job_type_specific_settings_description())) # To check which general settings are available Available job parameters: ... >>> job_setup.set_job_specific_parameter(parameter_name='n_points', value=100) \ ... .create() <more...>
- Parameters:
parameter_name (str) – The name of the job specific parameter to set
value (Any) – The value to set for the job specific parameter
- Returns:
self
- Return type:
- Raises:
NotCompatibleError – Raised if a wrong value type is given for the job type specific settings parameter
NameNotFoundError – Raised if the job type specific settings do not have a parameter with the given name
- abstractmethod set_parameter(obj: Any, parameter_name: str, value: Any) JobCreationContext [source]¶
Adds a tunable parameter to this job
Example
>>> 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') # Adds a static job and returns a job creation pipeline object
>>> particular_property = proj.comp.find_link_properties(linkpropname='property_name').properties[0] # Assumes that a link property with this names exists and has at least one particular property >>> print(job_setup.get_tunable_parameters_description_for_object(obj=particular_property)) # Shows the parameters available to the supplied object "ku": Float parameter - ... >>> job_setup.set_parameter(obj=particular_property, parameter_name='ku', value=1e6) \ ... .create() <more...>
>>> # Setup objects are interpreted as if they were their underlying objects >>> load_setup = simulation_setup \ ... .create_load_case_container_setup() \ ... .create_load_case_setup(lc_type='Mechanical load case') \ ... .create_load_setup(load_type='Link load')
>>> job_setup.set_parameter(obj=load_setup, parameter_name='u', value=1e6) <more...>
- Returns:
self
- Return type:
- Raises:
NotCompatibleError – Raised if a wrong value is given for the parameter
NameNotFoundError – Raised if the given object has no parameter with the given name
- abstractmethod set_running_job_settings_parameter(parameter_name: str, value: Any) JobCreationContext [source]¶
Deprecated version of
set_general_job_settings_parameter()
Deprecated
set_running_job_settings_parameter will be removed in a future MORe release, it is replaced by
set_parameter()