Skip to main content
Version: 2.0.1

sdk

create

def create(staging: bool = False,
already_uploaded: bool = False,
sim_id: str | None = None,
logger: Callable[[str], None] = print,
path: str = ".",
flags: dict = {},
max_attempts: int = 1,
montecarlo_id: str | None = None,
priority: int = 0) -> 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.
  • already_uploaded bool, optional - The files for the simulation have already been uploaded. When specifying this, you also need to specify the sim_id.
  • 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.
  • priority int, optional - The priority of the simulation, the maximum value is 99. Defaults to 0.

Raises:


  • already_uploaded0 - The project ID is not set to the product or staging project ID
  • already_uploaded0 - The project ID is not set to the product or staging project ID
  • already_uploaded2 - The configuration.yaml file was not found.
  • already_uploaded2 - The validation.json file was not found.
  • already_uploaded4 - Validation error
  • already_uploaded4 - Failed to parse GCS link
  • already_uploaded4 - GCs file doesn't exist
  • already_uploaded7 - The parameter name was not found in the configuration.yaml
  • already_uploaded7 - The parameter name was not found in the configuration.yaml
  • already_uploaded9 - Something went wrong while generating IDs, no new ones were found.
  • already_uploaded0 - The sim_id input does not conform to the required UUID4 format. Also, the first character must be a lower case letter.
  • sim_id1 - Storage blob in gcs already exists with this sim_id
  • already_uploaded4 - Validation error

Returns:


  • sim_id3 - The ID of the simulation that was created.

create_montecarlo

def create_montecarlo(run_specifications: list[object] | None = None,
staging: bool = False,
already_uploaded: bool = False,
montecarlo_id: str | None = None,
logger: Callable[[str], None] = print,
path: str = ".",
flags: dict = {},
max_attempts: int = 2,
priority: int = 0) -> 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 a run_specification.json file. Defaults to [].
  • staging bool, optional - Staging flag to use the staging environment instead of the default production environment. Defaults to False.
  • already_uploaded bool, optional - The files for the simulation have already been uploaded. When specifying this, you also need to specify the montecarlo_id.
  • montecarlo_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 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 underlying simulations. Defaults to 1.
  • run_specification.json0 int, optional - The priority of the simulation, the maximum value is 99. Defaults to 0.

Returns:


  • run_specification.json1 - 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 simulation
  • logger 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 ID
  • exceptions.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 ID
  • exceptions.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

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.