sdk
create
def create(staging: bool = False,
parameters: object | None = [],
gcs_link: str | None = None,
sim_id: str | None = None,
logger: Callable[[str], None] = print,
path: str = ".",
flags: dict = {},
max_attempts: int = 1,
montecarlo_id: str | None = None) -> str
Creates a simulation using the specified parameters.
Arguments:
staging
bool, optional - Staging flag to use the staging environment instead of the default production environment. Defaults to False.parameters
object | None, optional - Overwrite parameters set in the configuration of the simulation. Defaults to {}.gcs_link
str | None, optional - Instead of using a local configuration file you can provide a GCS URI to one which can be used instead. Defaults to None.sim_id
str | None, optional - Provide a sim id, has to be a UUIDv4 format starting with a lowercase letter. Defaults to None.logger
Callable[[str], None], optional - The logger will determine how all information from the sdk is logged. This has to be a function. Defaults to print.path
str, optional - The path where the configuration file is located. Defaults to ".". Supports relative and absolute paths.flags
dict, optional - Flags to be passed to the simulation. Defaults to {}.max_attempts
int, optional - The maximum number of attempts to run the simulation. Defaults to 1.montecarlo_id
str, optional - The id that connects this simulation to a montecarlo simulation. Defaults to None.
Raises:
ValueError
- The project ID is not set to the product or staging project IDValueError
- The project ID is not set to the product or staging project IDparameters
1 - The configuration.yaml.dist file was not found.parameters
1 - The validation.json file was not found.parameters
3 - Validation errorparameters
3 - Failed to parse GCS linkparameters
3 - GCs file doesn't existparameters
6 - The parameter name was not found in the configuration.yaml.distparameters
6 - The parameter name was not found in the configuration.yaml.distparameters
8 - Something went wrong while generating IDs, no new ones were found.ValueError
- The sim_id input does not conform to the required UUID4 format. Also, the first character must be a lower case letter.gcs_link
0 - Storage blob in gcs already exists with this sim_idparameters
3 - Validation error
Returns:
gcs_link
2 - The ID of the simulation that was created.
create_montecarlo
def create_montecarlo(run_specifications: list[object] | None = None,
run_specifications_gcs_link: str | None = None,
staging: bool = False,
gcs_link: str | None = None,
montecarlo_id: str | None = None,
logger: Callable[[str], None] = print,
path: str = ".",
flags: dict = {},
max_attempts: int = 2) -> str
Creates a montecarlo simulation using the specified parameters.
Arguments:
run_specifications
list, optional - Overwrite value set in the configuration, for every object a simulation will be made. Only specify this if you don't already have arun_specification.json
file. Defaults to [].run_specifications_gcs_link
str, optional - Instead of using a localrun_specifications.json
file you can provide a GCS URI to one which can be used instead. Defaults to None.staging
bool, optional - Staging flag to use the staging environment instead of the default production environment. Defaults to False.gcs_link
str | None, optional - Instead of using a local configuration.yaml.dist you can provide a GCS URI to one which can be used instead. Defaults to None.sim_id
str | None, optional - Provide a montecarlo id, has to be UUIDv4 format. Defaults to None, will generate random and return.logger
Callable[[str], None], optional - The logger will determine how all information from the sdk is logged. This has to be a function. Defaults to print.path
str, optional - The path where the configuration.yaml.dist is located. Defaults to ".". Supports relative and absolute paths.flags
dict, optional - Flags to be passed to the simulation. Defaults to {}.run_specification.json
0 int, optional - The maximum number of attempts to run the underlying simulations. Defaults to 1.
Returns:
run_specification.json
1 - description
kill
def kill(simulation_type: SimulationType,
sim_id: str,
logger: Callable[[str], None] = print,
staging: bool = False,
kill_reason: str = '') -> bool
Delete a simulation with the specified ID.
Arguments:
simulation_type(SimulationType)
- The type of simulation to get (RUN, SINGLE, MONTECARLO, OPTIMIZATION)sim_id
str - UUID of the simulationlogger
Callable[[str], None], optional - Defaults to print.staging
bool, optional - Whether to use the staging environment or not. Defaults to False.kill_reason
str, optional - String to give to the GCP delete job for logs. Defaults to ''.
get
def get(
simulation_type: SimulationType,
document_id: str,
logger: Callable[[str], None] = print,
staging: bool = False
) -> SimulationGetResult | SimulationRunGetResult | MonteCarloGetResult | None
Retrieve information about a simulation with the specified ID.
Arguments:
simulation_type(SimulationType)
- The type of simulation to get (RUN, SINGLE, MONTECARLO, OPTIMIZATION)document_id
str - The ID of the simulation to get.logger
Callable[[str], None], optional - The logger will determine how all information from the sdk is logged. This has to be a function. Defaults to print.staging
bool, optional - Whether to use the staging environment or not. Defaults to False.
Raises:
ValueError
- The project ID is not set to the product or staging project IDexceptions.NotFound
- The simulation wasn't found
Returns:
SimulationGetResult | SimulationRunGetResult | MonteCarloGetResult | None: The relative simulation result object.
result
def result(simulation_type: SimulationType,
id: str,
logger: Callable[[str], None] = print,
staging: bool = False) -> str | None
Gets the result of the simulation with the specified ID.
Arguments:
simulation_type(SimulationType)
- The type of simulation to get the result of (RUN, SINGLE, MONTECARLO, OPTIMIZATION)id
str - The ID of the simulation to get the result of.logger
Callable[[str], None], optional - The logger will determine how all information from the sdk is logged. This has to be a function. Defaults to print.staging
bool, optional - Whether to use the staging environment or not. Defaults to False.
Raises:
ValueError
- The project ID is not set to the product or staging project IDexceptions.NotFound
- The simulation wasn't found
Returns:
str
- The result of the simulation.None
- If the simulation hasn't finished yet or didn't report a result.
logs
def logs(simulation_type: SimulationType,
simulation_id,
logger: Callable[[str], None] = print,
staging: bool = False) -> Iterator[str]
Gets the logs of the simulation run with the specified ID.
Arguments:
simulation_id
type - The ID of the simulation run to get the logs of.logger
Callable[[str], None], optional - The logger will determine how all information from the sdk is logged. This has to be a function. Defaults to print.staging
bool, optional - Whether to use the staging environment or not. Defaults to False.
Raises:
ValueError
- description
compile
def compile(folder: str, logger: Callable[[str], None] = print) -> None
Compiles the configuration.yaml file into a single file that can be uploaded to the simulator.
Arguments:
folder
str - The directory of the folderlogger
Callable[[str], None], optional - The logger will determine how all information from the sdk is logged. This has to be a function. Defaults to print.
get_metrics
def get_metrics(simulation_type: SimulationType,
simulation_id: str,
logger: Callable[[str], None] = print,
staging: bool = False) -> list[object]
Gets the metrics of the simulation with the specified ID.
Arguments:
simulation_type(SimulationType)
- The type of simulation to get the metrics of (RUN, SINGLE, MONTECARLO, OPTIMIZATION)simulation_id
str - The ID of the simulation to get the metrics of.logger
Callable[[str], None], optional - The logger will determine how all information from the sdk is logged. This has to be a function. Defaults to print.staging
bool, optional - Whether to use the staging environment or not. Defaults to False.