Accessing the scenario configuration: components and parameters#
It is possible to access the Scenario of the job,
which contains the configuration of Component
objects, and Parameter objects, related to that
scenario.
Access of scenario, components and parameters#
with JobClient.connect() as job:
my_component = job.scenario.components["my_component"]
my_cool_subcomponents = my_component.components["cool_component_name"]
my_nifty_subcomponents = my_component.components["nifty_component_name"]
cool_result = 0.0
for cool_subcomponent in my_cool_subcomponents:
cool_subcomponent_parameter = cool_subcomponent.parameters["coolness"]
cool_result += cool_subcomponent_parameter.value
... # continue your job code
Accessing subcomponents#
Accessing subcomponents is a bit more complicated. Sub-components exist inside other components, and are grouped by the name of the component type.
with JobClient.connect() as job:
my_component = job.scenario.components["my_component"]
my_cool_subcomponents = my_component.components["cool_component_name"]
my_nifty_subcomponents = my_component.components["nifty_component_name"]
cool_result = 0.0
for cool_subcomponent in my_cool_subcomponents:
cool_subcomponent_parameter = cool_subcomponent.parameters["coolness"]
cool_result += cool_subcomponent_parameter.value
... # continue your job code
Accessing job parameters#
The job itself, and can also have parameters associated with it. They are accessed
through numerous.sdk.connect.job_client.JobClient.parameters, which is a
shortcut for parameters on the numerous.sdk.connect.job_client.JobClient.job
property.
my_job_parameter_id#with JobClient.connect() as job_client:
my_job_parameter = job_client.parameters["my_job_parameter_id"]
my_same_job_parameter = job_client.job.parameters["my_job_parameter_id"] # same!
job_client.log.info("My Job Parameter = %s", my_job_parameter.value)
Accessing parameter values#
You can access a parameters value, with the value property, is is shown in the
examples above.
The type of the value property depends on the parameter type chosen when designing
the tool in numerous.
Some correspond to simple values (e.g. string corresponds to str, and number
corresponds to float), while others are more complex. Below is an overview of the
different parameter types, and how they are mapped into python values.
Parameter type |
Python value type |
Description |
|---|---|---|
number |
|
A simple number value. |
string |
|
A simpel text value. |
boolean |
|
A simple boolean value. |
selecter |
A selection has a value of type |
|
month |
A wrapper for the selected month as an integer number. |
|
config |
||
file |
Has helper methods to read the uploaded files referenced. |
|
table |
Not yet implemented. |
|
time_value |
Contains a |
|
json |
|
Contains the parsed JSON document, as parsed by |