modelon.impact.client.entities package

Subpackages

Submodules

modelon.impact.client.entities.asserts module

assert_successful_operation(is_successful, operation_name='Operation')
Return type:

None

assert_variable_in_result(variables, result_variables)
Return type:

None

modelon.impact.client.entities.case module

class Case(case_id, workspace_id, exp_id, service, info)

Bases: CaseReference

Class containing Case functionalities.

execute(sync_case_changes=True)

Executes a case. Returns an CaseOperation class object.

Parameters:
  • sync_case_changes (bool) – Boolean specifying if to sync case changes

  • True. (against the server before executing the case. Default is) –

Return type:

CaseOperation

Returns:

An CaseOperation class object.

Example:

case = experiment.get_case('case_1')
case.input.parametrization = {'PI.k': 120}
case.sync()
case_ops = case.execute()
case_ops.cancel()
case_ops.status
case_ops.wait()
classmethod from_operation(operation, **kwargs)
Return type:

Case

classmethod from_reference(reference)
Return type:

Case

get_artifact(artifact_id, download_as=None)

Returns a CustomArtifact class for a finished case.

Return type:

CustomArtifact

Returns:

The CustomArtifact class object.

Raises:
  • OperationNotCompleteError if simulation process is in progress.

  • OperationFailureError if simulation process has failed or was cancelled.

Example:

custom_artifact = case.get_artifact(artifact_id)
get_artifacts()

Returns a list of CustomArtifact classes for a finished case.

Return type:

List[CustomArtifact]

Returns:

A list of CustomArtifact class objects.

Raises:
  • OperationNotCompleteError if simulation process is in progress.

  • OperationFailureError if simulation process has failed or was cancelled.

Example:

custom_artifacts = case.get_artifacts()
get_definition()

Get an experiment definition that can be used to reproduce this case result.

Return type:

SimpleModelicaExperimentDefinition

Returns:

An instance of SimpleModelicaExperimentDefinition class.

Example:

definition = case.get_definition()
get_fmu()

Returns the ModelExecutable class object simulated for the case.

Return type:

ModelExecutable

Returns:

ModelExecutable class object.

Example:

case = experiment.get_case('case_1')
fmu = case.get_fmu()
fmus = set(case.get_fmu() for case in exp.get_cases())
get_log()

Returns the log class object for a finished case.

Return type:

Log

Returns:

The case execution log class object.

Example:

log = case.get_log()
log.show()
get_result(format='mat')

Returns the result stream and the file name for a finished case.

Parameters:

format (str) – The file format to download the result in. The only possible values are ‘mat’ and ‘csv’. Default: ‘mat’

Return type:

Tuple[Union[bytes, str], str]

Returns:

A tuple containing, respectively, the result byte stream. and the filename for the result. This name could be used to write the result stream.

Raises:
  • OperationNotCompleteError if simulation process is in progress.

  • OperationFailureError if simulation process has failed or was cancelled.

  • TypeError if the variable is not a list object.

  • ValueError if trajectory variable is not present in the result.

Example:

result, file_name = case.get_result(format = 'csv')
with open(file_name, "w") as f:
    f.write(result)
get_trajectories()

Returns result(Mapping) object containing the result trajectories.

Return type:

Result

Returns:

A Result object (mapping) that allows requesting trajectory data given a variable name.

Raises:
  • OperationNotCompleteError if simulation process is in progress.

  • OperationFailureError if simulation process was cancelled.

Example:

result = case.get_trajectories()
result_variables = result.keys()
height = result['h']
time = res['time']
property info: Dict[str, Any]

Deprecated, use ‘run_info’ attribute.

property initialize_from_case: Case | None

Get(if any) or set the case to initialize from.

Example:

# Set the case to  initialize from
# Fetching the successful case
case_1 = experiment.get_case('case_1')

# Fetching the failed case
case_2 = experiment.get_case('case_2')

# Initializing from successful case
case_2.initialize_from_case = case_1

# Re-executing the case after initializing
case_init_successful = case_2.execute().wait()


# Get the case set to initialize from
initialized_from_case = case.initialize_from_case
property initialize_from_external_result: ExternalResult | None

Get(if any) or set the external result file to initialize from.

Example:

# Set the external result file to  initialize from
result = workspace.upload_result(path_to_result="<path_to_result>/
result.mat", label = "result_to_init", description= "Converged
result file").wait()

# Initializing from external result
case_2.initialize_from_external_result = result

# Re-executing the case after initializing
case_init_successful = case_2.execute().wait()


# Get the external result file to initialize from
initialize_from_external_result = case.initialize_from_external_result
property input: CaseInput

Case input attributes.

Example:

case.input.analysis.parameters = {'start_time': 0, 'final_time': 90}
case.input.analysis.simulation_options = {'ncp': 600}
case.input.analysis.solver_options = {'atol': 1e-8}
case.input.parametrization = {'PI.k': 120}
case.sync()

help(case.input.analysis) # See help for attribute
dir(case.input) # See nested attributes
is_successful()

Returns True if a case has completed successfully.

Return type:

bool

Returns:

True, if the case has executed successfully, False, if the case has failed execution.

Example:

case.is_successful()
property meta: CaseMeta

Case meta attributes.

Example:

case.meta.label = 'Cruise condition'
case.sync()

help(case.meta) # See help for attribute
dir(case.input) # See nested attributes
property run_info: CaseRunInfo

Case run information.

sync()

Sync case state against server, pushing any changes that has been done to the object client side.

Return type:

None

Example::

case.input.parametrization = {‘PI.k’: 120} case.sync()

class CaseAnalysis(analysis)

Bases: object

Class containing Case analysis configuration.

property analysis_function: str

Custom function name.

Returns:

The name of the custom function.

Example:

analysis_function = case.input.analysis.analysis_function
property parameters: Dict[str, Any]

Get or set parameters for the custom function. Parameters are a dictionary containing the custom function parameters.

Example:

# Set the custom function parameters
case.input.analysis.parameters = {'start_time': 0, 'final_time': 90}


# Get the custom function parameters
parameters = case.input.analysis.parameters
property simulation_log_level: str

Get or set the simulation log level. Supported options are- ‘WARNING’, ‘ERROR’, ‘DEBUG’, ‘INFO’ and ‘VERBOSE’.

Example:

# Set the solver options
case.input.analysis.simulation_log_level = "WARNING"

# Get the solver options
simulation_log_level = case.input.analysis.simulation_log_level
property simulation_options: Dict[str, Any]

Get or set the simulation options. Options are key-value pairs of simulation options.

Example:

# Set the custom function parameters
case.input.analysis.simulation_options = {'ncp': 600}

# Get the custom function parameters
simulation_options = case.input.analysis.simulation_options
property solver_options: Dict[str, Any]

Get or set the simulation options. Options are key-value pairs of solver options.

Example:

# Set the solver options
case.input.analysis.solver_options = {'atol': 1e-9}


# Get the solver options
solver_options = case.input.analysis.solver_options
class CaseInput(data)

Bases: object

Class containing Case input.

property analysis: CaseAnalysis
property fmu_base_parametrization: Dict[str, Any]

This is some base parametrization that must be applied to the FMU for it to be valid running this case.

It often comes as a result from of caching to reuse the FMU.

property fmu_id: str

Reference ID to the compiled model used running the case.

property parametrization: Dict[str, Any]

Get or set the parametrization of the case. Parameterization is defined as a dict of key value pairs where key is variable name and value is the value to use for that variable.

Example:

# Set the case parametrization
case.input.parametrization = {'PI.k': 120}


# Get the case parametrization
parametrization = case.input.parametrization
property structural_parametrization: Dict[str, Any]

Structural parametrization of the case, a list of key value pairs where key is variable name and value is the value to use for that variable.

These are values that cannot be applied to the FMU/Model after compilation.

class CaseMeta(data)

Bases: object

Class containing Case meta.

property label: str

Get or set the label for the case.

Example:

# Set the case label
case.meta.label = 'Cruise condition'

# Get the case label
label = case.meta.label
class CaseRunInfo(status, consistent, datetime_started, datetime_finished)

Bases: object

Class containing Case run info.

property consistent: bool

True if the case has not been synced since it was executed, false otherwise.

property finished: datetime | None

Case execution finish time.

Returns None if case execution hasn’t finished.

property started: datetime | None

Case execution start time.

Returns None if case execution hasn’t started.

property status: CaseStatus

Status info for a Case.

Note

For tracing status changes of a running case execution, the CaseOperation status property must be used and not Case entities run info(CaseRunInfo) status property. See example for usage.

Example:

# To get the case entity run info status
status = case.run_info.status

# To get the status updates of a running case execution
case_ops = case.execute()
status = case_ops.status
class CustomArtifact(workspace_id, experiment_id, case_id, artifact_id, download_as, exp_sal)

Bases: object

CustomArtifact class.

download(path=None)

Downloads a custom artifact. Returns the local path to the downloaded artifact.

Parameters:

path (Optional[str]) – The local path to the directory to store the downloaded custom artifact. Default: None. If no path is given, custom artifact will be downloaded in a temporary directory.

Returns:

Local path to the downloaded custom artifact.

Return type:

path

Example:

artifact_path = artifact.download()
artifact_path = artifact.download('/home/Downloads')
property download_as: str

File name for the downloaded artifact.

get_data()

Returns the custom artifact stream.

Returns:

The artifact byte stream.

Return type:

artifact

Example:

artifact = case.get_artifact("ABCD")
data = artifact.get_data() # may raise exception on communication error
with open(artifact.download_as, "wb") as f:
    f.write(data)
property id: str

Id of the custom artifact.

modelon.impact.client.entities.content module

class ContentType(value)

Bases: Enum

Supported content types in a project.

CUSTOM_FUNCTIONS = 'CUSTOM_FUNCTIONS'
EXPERIMENT_DEFINITIONS = 'EXPERIMENT_DEFINITIONS'
FAVORITES = 'FAVORITES'
GENERIC = 'GENERIC'
MODELICA = 'MODELICA'
REFERENCE_RESULTS = 'REFERENCE_RESULTS'
VIEWS = 'VIEWS'
class ProjectContent(content, project_id, service)

Bases: object

Content entry in a project.

property content_type: ContentType

Type of content.

property default_disabled: str
delete()

Deletes a project content.

Example:

content.delete()
Return type:

None

classmethod from_operation(operation, **kwargs)
Return type:

ProjectContent

property id: str

Content ID.

property name: str | None

Modelica library name.

property relpath: Path

Relative path in the project.

Can be file (e.g., SomeLib.mo) or folder

modelon.impact.client.entities.custom_function module

class CustomFunction(workspace_id, name, parameter_data, service)

Bases: CustomFunctionInterface

Class containing CustomFunction functionalities.

get_compiler_options(use_defaults=False)

Return a modelon.impact.client.options.CompilerOptions object.

Parameters:

use_defaults (bool) – If True, default compiler options are used.

Return type:

CompilerOptions

Returns:

A CompilerOptions object.

Example:

opts = custom_function.get_compiler_options()
compiler_options = opts.with_values(c_compiler='gcc')
get_options(use_defaults=False)

Get project execution option.

Parameters:

use_defaults (Optional[bool]) – If true, default compiler options are used.

Return type:

ProjectExecutionOptions

Example:

opts = custom_function.get_compiler_options()
opts_2 = opts.compiler_options.with_values(c_compiler='gcc')
get_runtime_options(use_defaults=False)

Return a RuntimeOptions object.

Parameters:

use_defaults (bool) – If True, default compiler options are used.

Return type:

RuntimeOptions

Returns:

A RuntimeOptions object.

Example:

opts = custom_function.get_runtime_options()
opts_2 = opts.with_values(cs_solver=0)
get_simulation_options(use_defaults=False)

Return a SimulationOptions object.

Parameters:

use_defaults (bool) – If True, default compiler options are used.

Return type:

SimulationOptions

Returns:

A SimulationOptions object.

Example:

opts = custom_function.get_simulation_options()
opts_2 = opts.with_values(ncp=500)
get_solver_options(use_defaults=False)

Return a modelon.impact.client.options.SolverOptions object.

Parameters:

use_defaults (bool) – If True, default compiler options are used.

Return type:

SolverOptions

Returns:

A SolverOptions object.

Example:

opts = custom_function.get_solver_options()
opts_2 = opts.with_values(rtol=1e-7)
property name: str

Custom function name

property parameter_values: ParameterDict

Custom_function parameters and value as a dictionary.

with_parameters(**modified)

Sets/updates the custom_function parameters for an experiment.

Parameters:

parameters – A key-worded, variable-length argument list of custom_function parameters.

Return type:

CustomFunction

Example:

custom_function.with_parameters(start_time=0.0, final_time=2.0)
class ParameterDict

Bases: dict

as_raw_dict()
Return type:

Dict[str, Any]

modelon.impact.client.entities.experiment module

class Experiment(workspace_id, exp_id, service, info=None)

Bases: ExperimentReference

Class containing Experiment functionalities.

property custom_function: str

Returns the custom function name.

delete()

Deletes an experiment.

Example:

experiment.delete()
Return type:

None

execute(with_cases=None, sync_case_changes=True)

Executes an experiment. Returns an ExperimentOperation class object.

Parameters:
  • with_cases (Optional[List[Case]]) – A list of cases objects to execute.

  • sync_case_changes (bool) – Boolean specifying if to sync the cases given with the ‘with_cases’ argument against the server before executing the experiment. Default is True.

Return type:

ExperimentOperation

Returns:

An ExperimentOperation class object.

Example:

experiment = workspace.create_experiment(experiment_definition)
experiment_ops = experiment.execute()
experiment_ops.cancel()
experiment_ops.status
experiment_ops.wait()

generate_cases = experiment.execute(with_cases=[]).wait()
cases_to_execute =  generate_cases.get_case('case_2')
experiment = experiment.execute(with_cases=[cases_to_execute]).wait()
classmethod from_operation(operation, **kwargs)
Return type:

Experiment

classmethod from_reference(reference)
Return type:

Experiment

get_case(case_id)

Returns a case object for a given case_id.

Parameters:

case_id (str) – The case_id for the case.

Return type:

Case

Returns:

An case object.

Example:

experiment.get_case('case_1')
get_cases()

Returns a list of case objects for an experiment.

Return type:

List[Case]

Returns:

An list of case objects.

Example:

experiment.get_cases()
get_cases_with_label(case_label)

Returns a list of case objects for an experiment with the label.

Parameters:

case_label (str) – The case_label for the case.

Return type:

List[Case]

Returns:

An list of case objects.

Example:

experiment.get_cases_with_label('Cruise condition')
get_class_name()

Return the model class name.

Return type:

str

get_compiler_options()

Return a CompilerOptions object.

Return type:

CompilerOptions

get_definition()

Get an experiment definition that can be used to reproduce this experiment result.

Return type:

Union[SimpleModelicaExperimentDefinition, SimpleFMUExperimentDefinition]

Returns:

An instance of SimpleFMUExperimentDefinition or SimpleModelicaExperimentDefinition class.

Example:

definition = experiment.get_definition()
get_last_point(variables=None)

Returns a ExperimentResultPoint class for a list of result variables for all the cases.

Parameters:

variables (Optional[List[str]]) – An optional list of variables to fetch results for.

Return type:

ExperimentResultPoint

Returns:

An ExperimentResultPoint class object.

Raises:
  • OperationNotCompleteError if simulation process is in progress.

  • OperationFailureError if simulation process was cancelled.

  • TypeError if the variable is not a list object.

  • ValueError if trajectory variable is not present in the result.

Example:

result = experiment.get_last_point(['h', 'time'])

# Convert to Pandas data frame
df = pd.DataFrame(data=result.as_lists(), columns=result.variables,
    index=result.cases)
df.index.name = "Cases"
get_runtime_options()

Return a RuntimeOptions object.

Return type:

RuntimeOptions

get_simulation_options()

Return a SimulationOptions object.

Return type:

SimulationOptions

get_solver_options()

Return a SolverOptions object.

Return type:

SolverOptions

get_trajectories(variables)

Returns a dictionary containing the result trajectories for a list of result variables for all the cases.

Parameters:

variables (List[str]) – A list of result variables to fetch trajectories for.

Return type:

Dict[str, Any]

Returns:

A dictionary object containing the result trajectories for all cases.

Raises:
  • OperationNotCompleteError if simulation process is in progress.

  • OperationFailureError if simulation process was cancelled.

  • TypeError if the variable is not a list object.

  • ValueError if trajectory variable is not present in the result.

Example:

result = experiment.get_trajectories(['h', 'time'])
height = result['case_1']['h']
time = result['case_1']['time']
get_variables()

Returns a list of variables available in the result.

Return type:

List[str]

Returns:

An list of result variables.

Raises:
  • OperationNotCompleteError if simulation process is in progress.

  • OperationFailureError if simulation process has failed or was cancelled.

Example:

experiment.get_variables()
property info: Dict[str, Any]

Deprecated, use ‘run_info’ attribute.

is_successful()

Returns True if the Experiment is done and no cases has failed. Use the ‘run_info’ attribute to get more info.

Return type:

bool

Returns:

True, if execution process has completed successfully. False, if execution process has failed, is cancelled or still running.

Example:

experiment.is_successful()
property label: str | None

Returns the experiment label if it exists.

property metadata: ExperimentMetaData

Experiment metadata.

Returns:

A ExperimentMetaData class object.

Example:

user_data = experiment.metadata.user_data
property run_info: ExperimentRunInfo

Experiment run information.

Returns:

A ExperimentRunInfo class object.

Example:

status = experiment.run_info.status
set_label(label)

Sets a label (string) for an experiment to distinguish it. To get the label, you could call the experiment.label property.

Example:

experiment.set_label("Engine run with Oil type B")
label = experiment.label
Return type:

None

class ExperimentMetaData(meta_data)

Bases: object

Class containing experiment metadata.

property label: str | None

Experiment label.

property user_data: Dict[str, Any]

User data dictionary object attached to experiment, if any.

class ExperimentResultPoint(trajectories, variables)

Bases: object

Value class with the single time instance data in a experiment.

as_lists()

Return a list of results per case.

None indicates that the case was not run or failed. None value for a variable indicated that the variable is not present in the specific case output.

Example:

result_data = result.as_lists()
Return type:

List[Optional[List[Union[float, int, str, None]]]]

property cases: List[str]

List of case ids.

property variables: List[str]

List of variables.

class ExperimentRunInfo(status, errors, failed, successful, cancelled, not_started)

Bases: object

Class containing experiment run information.

property cancelled: int

Number of cases in experiment that are cancelled.

property errors: List[str]

A list of errors.

Is empty unless ‘status’ attribute is ‘FAILED’

property failed: int

Number of cases in experiment thar have failed.

property not_started: int

Number of cases in experiment that have not yet started.

property status: ExperimentStatus

Status info for an Experiment.

Note

For tracing status changes of a running experiment execution, the ExperimentOperation status property must be used and not Experiment entities run info(ExperimentRunInfo) status property. See example for usage.

Example:

# To get the case entity run info status
status = experiment.run_info.status

# To get the status updates of a running experiment execution
experiment_ops = experiment.execute()
status = experiment_ops.status
property successful: int

Number of cases in experiment that are successful.

modelon.impact.client.entities.external_result module

class ExternalResult(result_id, service)

Bases: ExternalResultInterface

Class containing external result.

delete()
Return type:

None

classmethod from_operation(operation, **kwargs)
Return type:

ExternalResult

property id: str

Result id.

property metadata: ExternalResultMetaData

External result metadata.

class ExternalResultMetaData(id, name, description, workspace_id)

Bases: object

Class containing external result metadata.

property description: str

Description of the result.

property id: str

Result id.

property name: str

Label for result.

property workspace_id: str

Name of workspace.

modelon.impact.client.entities.log module

class Log

Bases: str

Log class inheriting from string object.

show()

Prints the formatted log.

Return type:

None

modelon.impact.client.entities.model module

class Model(class_name, workspace_id, project_id, service)

Bases: ModelInterface

Class containing Model functionalities.

compile(compiler_options, runtime_options=None, compiler_log_level='warning', fmi_target='me', fmi_version='2.0', platform='auto', force_compilation=False)

Compiles the model to an FMU. Returns an ModelExecutableOperation class object.

Parameters:
  • compiler_options (Union[CompilerOptions, Dict[str, Any]]) – An compilation options class instance of CompilerOptions or a dictionary object containing the compiler options.

  • runtime_options (Union[RuntimeOptions, Dict[str, Any], None]) – An runtime options class instance of RuntimeOptions or a dictionary object containing the runtime options. Default: None.

  • compiler_log_level (str) – The logging for the compiler. Possible values are “error”, “warning”, “info”, “verbose” and “debug”. Default: ‘warning’.

  • fmi_target (str) – Compiler target. Possible values are ‘me’ and ‘cs’. Default: ‘me’.

  • fmi_version (str) – The FMI version. Valid options are ‘1.0’ and ‘2.0’. Default: ‘2.0’.

  • platform (str) –

    Platform for FMU binary.The OS running the Impact server must match the environment that runs the compiled FMU. This is necessary as the binaries packaged with the FMU are based on the platform generating the FMU. For example, if the Impact server is running Linux the binary in the downloaded FMU is compiled for Linux. The downloaded FMU can then not be simulated on Windows. Default: ‘auto’. Supported options are:-

    • ‘auto’: platform is selected automatically

    • ”linux64”: generate a 32 bit FMU

    • ”win64”: generate a 64 bit FMU

  • force_compilation (bool) – Force a model compilation.

Return type:

Union[ModelExecutableOperation, CachedModelExecutableOperation]

Returns:

An ModelExecutableOperation class object.

Example:

compile_ops=model.compile(compiler_options)
compile_ops.cancel()
compile_ops.status
compiler_options=custom_function.get_compiler_options().with_values(c_compiler='gcc')
runtime_options={'cs_solver':0}
model.compile(compiler_options, runtime_options).wait()
model.compile({'c_compiler':'gcc'}).wait()
classmethod from_operation(operation, **kwargs)
Return type:

Model

import_fmu(fmu_path, class_name=None, overwrite=False, include_patterns=None, exclude_patterns=None, top_level_inputs=None, step_size=0.0)

Uploads a FMU.

Parameters:
  • fmu_path (str) – The path for the FMU to be imported.

  • class_name (Optional[str]) – Qualified name of generated class. By default, ‘class_name’ is set to the name of the library followed by a name based on the filename of the imported FMU.

  • overwrite (bool) – Determines if any already existing files should be overwritten. Default: False.

  • include_patterns (Union[str, List[str], None]) – Specifies what variables from the FMU to include and/or exclude in the wrapper model. These two arguments are patterns or lists of patterns as the same kind as the argument ‘filter’ for the function ‘get_model_variables’ in PyFMI. If both ‘include_patterns’ and ‘exclude_patterns’ are given, then all variables that matches ‘include_patterns’ but does not match ‘exclude_patterns’ are included. Derivatives and variables with a leading underscore in the name are always excluded. Default value: None (which means to include all the variables).

  • exclude_patterns (Union[str, List[str], None]) – Specifies what variables from the FMU to include and/or exclude in the wrapper model. These two arguments are patterns or lists of patterns as the same kind as the argument ‘filter’ for the function ‘get_model_variables’ in PyFMI. If both ‘include_patterns’ and ‘exclude_patterns’ are given, then all variables that matches ‘include_patterns’ but does not match ‘exclude_patterns’ are included. Derivatives and variables with a leading underscore in the name are always excluded. Default value: None (which means to include all the variables).

  • top_level_inputs (Union[str, List[str], None]) – Specify what inputs that should be kept as inputs, i.e. with or without the input keyword. The argument is a pattern similar to the arguments include_patterns and exclude_patterns. Example: If top_level_inputs = ‘my_inputs*’, then all input variables matching the pattern ‘my_inputs*’ will be generated as inputs, and all other inputs not matching the pattern as model variables. If top_level_inputs = ‘’, then no input is imported as an input. Default value: None (which means all inputs are kept as inputs) Type: str or a list of strings

  • step_size (float) – Specify what value to set for the parameter for step size in the generated model. By default the parameter is set to zero, which means that the step size will be set during simulation based on simulation properties such as the time interval. This can also be manually set to any real non-negative number. The value of the step size parameter can also be set via the function set_step_size, which must be invoked before importing the model. Default value: 0.0 (which during simulation is set according to the description above).

Return type:

FMUImportOperation

Example:

workspace = client.get_workspace("test")
package = workspace.get_model('MyPackage')
fmu_content = package.import_fmu('C:/A.fmu').wait()
fmu_content = package.import_fmu('C:/B.fmu',
    class_name="MyPackage.Model").wait()
property name: str

Class name.

new_experiment_definition(custom_function, *, fmi_target='me', fmi_version='2.0', platform='auto', compiler_log_level='warning', compiler_options=None, runtime_options=None, solver_options=None, simulation_options=None, simulation_log_level='WARNING', initialize_from=None)

Returns a new experiment definition using this Model.

Parameters:
  • custom_function (CustomFunction) – The custom function to use for this experiment.

  • fmi_target (str) – Compiler target. Possible values are ‘me’ and ‘cs’.

  • Default – ‘me’.

  • fmi_version (str) – The FMI version. Valid options are ‘1.0’ and ‘2.0’.

  • Default – ‘2.0’.

  • platform (str) –

    Platform for FMU binary.The OS running the Impact server must match the environment that runs the compiled FMU. This is necessary as the binaries packaged with the FMU are based on the platform generating the FMU. For example, if the Impact server is running Linux the binary in the downloaded FMU is compiled for Linux. The downloaded FMU can then not be simulated on Windows. Default: ‘auto’. Supported options are:-

    • ‘auto’: platform is selected automatically

    • ”linux64”: generate a 32 bit FMU

    • ”win64”: generate a 64 bit FMU

  • compiler_log_level (str) – The logging for the compiler. Possible values are “error”, “warning”, “info”, “verbose” and “debug”. Default: ‘warning’.

  • compiler_options (Union[CompilerOptions, Dict[str, Any], None]) – An compilation options class instance of CompilerOptions or a dictionary object containing the compiler options.

  • runtime_options (Union[RuntimeOptions, Dict[str, Any], None]) – An runtime options class instance of RuntimeOptions or a dictionary object containing the runtime options. Default: None.

  • solver_options (Union[SolverOptions, Dict[str, Any], None]) – The solver options to use for this experiment. By default the options is set to None, which means the default options for the custom_function input is used.

  • simulation_options (Union[SimulationOptions, Dict[str, Any], None]) – The simulation_options to use for this experiment. By default the options is set to None, which means the default options for the custom_function input is used.

  • simulation_log_level (str) – Simulation log level for this experiment. Default is ‘WARNING’.

  • initialize_from (Union[Case, Experiment, ExternalResult, None]) – Optional entity to initialize from. An instance of Case or Experiment or ExternalResult. Default: None

Return type:

SimpleModelicaExperimentDefinition

Example:

model = workspace.get_model("Modelica.Blocks.Examples.PID_Controller")
dynamic = workspace.get_custom_function('dynamic')
solver_options = {'atol':1e-8}
simulation_options = dynamic.get_simulation_options().
with_values(ncp=500)
experiment_definition = model.new_experiment_definition(
    dynamic,
    solver_options=solver_options,
    simulation_options=simulation_options
)
experiment = workspace.execute(experiment_definition).wait()

modelon.impact.client.entities.model_executable module

class ModelDescription

Bases: str

ModelDescription class inheriting from string object.

download(path=None)

Downloads the formatted xml.

Parameters:

path (Optional[str]) – The local path to store the downloaded model description. Default: None. If no path is given, model description will be downloaded in a temporary directory.

Return type:

str

Returns:

Local path to the model description file.

Example:

model_description = fmu.get_model_description()
model_description.show()
model_description.download()
show()

Prints the formatted xml.

Return type:

None

class ModelExecutable(workspace_id, fmu_id, service, info=None, modifiers=None)

Bases: ModelExecutableInterface

Class containing ModelExecutable functionalities.

delete()

Deletes an FMU.

Example:

fmu.delete()
Return type:

None

download(path=None)

Downloads an FMU binary that is compiled. Returns the local path to the downloaded FMU archive.

Parameters:

path (Optional[str]) – The local path to store the downloaded FMU. Default: None. If no path is given, FMU will be downloaded in a temporary directory.

Return type:

str

Returns:

Local path to the downloaded FMU.

Raises:
  • OperationNotCompleteError if compilation process is in progress.

  • OperationFailureError if compilation process has failed or was cancelled.

Example:

fmu =  model.compile().wait()
if fmu.is_successful():
    fmu_path = fmu.download()
    fmu_path = fmu.download('~/Downloads')
classmethod from_operation(operation, **kwargs)
Return type:

ModelExecutable

get_class_name()

Return the model class name.

Return type:

str

get_log()

Returns the compilation log object.

Return type:

Log

Returns:

The compilation log object.

Raises:
  • OperationNotCompleteError if compilation process is in progress.

  • OperationFailureError if compilation process was cancelled.

Example:

log = fmu.get_log()
log.show()
get_model_description()

Returns the model description object.

Return type:

ModelDescription

Returns:

The ModelDescription class object.

Example:

model_description = fmu.get_model_description()

# Print the formatted xml
model_description.show()

# Download the formatted xml
model_description.download()

# Parse the xml
from xml.etree import ElementTree

tree = ElementTree.fromstring(model_description)
model_variables =tree.find('ModelVariables')
variable_names = [child.attrib.get('name') for child in model_variables]
get_settable_parameters()

Returns a list of settable parameters for the FMU.

Return type:

List[str]

Returns:

A list of parameters that can be set on the FMU.

Raises:
  • OperationNotCompleteError if compilation process is in progress.

  • OperationFailureError if compilation process has failed or was cancelled.

Example:

fmu.get_settable_parameters()
property id: str

FMU id.

property info: Dict[str, Any]

Deprecated, use ‘run_info’ attribute.

property input: ModelExecutableInput

ModelExecutable input attributes.

Example:

compiled_platform = fmu.input.platform

help(fmu.input.platform) # See help for attribute
dir(fmu.input) # See nested attributes
is_successful()

Returns True if the model has compiled successfully. Use the ‘run_info’ attribute to get more info.

Return type:

bool

Returns:

True, if model has compiled successfully. False, if compilation process has failed, is running or is cancelled.

Example:

fmu.is_successful()
property metadata: Dict[str, Any]

FMU metadata.

Returns the ‘iteration_variable_count’ and ‘residual_variable_count’ only for steady state model compiled as an FMU

new_experiment_definition(custom_function, solver_options=None, simulation_options=None, simulation_log_level='WARNING')

Returns a new experiment definition using this FMU.

Parameters:
  • custom_function (CustomFunction) – The custom function to use for this experiment.

  • solver_options (Union[SolverOptions, Dict[str, Any], None]) – The solver options to use for this experiment. By default the options is set to None, which means the default options for the custom_function input is used.

  • simulation_options (Union[SimulationOptions, Dict[str, Any], None]) – The simulation_options to use for this experiment. By default the options is set to None, which means the default options for the custom_function input is used.

  • simulation_log_level (str) – Simulation log level for this experiment. Default is ‘WARNING’.

Return type:

SimpleFMUExperimentDefinition

Example:

fmu = model.compile().wait()
dynamic = workspace.get_custom_function('dynamic')
solver_options = {'atol':1e-8}
simulation_options = dynamic.get_simulation_options().
with_values(ncp=500)
experiment_definition = fmu.new_experiment_definition(
    dynamic, solver_options, simulation_options)
experiment = workspace.execute(experiment_definition).wait()
property run_info: ModelExecutableRunInfo

Compilation run information.

class ModelExecutableInput(data)

Bases: object

Class containing ModelExecutable input.

property class_name: str

Returns the model class name.

property compiler_log_level: str

Returns the compiler log level.

property compiler_options: Dict[str, Any]

Returns the compiler options dict.

property fmi_target: str

Returns the FMI target.

property fmi_version: str

Returns the FMI version.

property platform: str

Returns the platform the FMU was compiled for.

property runtime_options: Dict[str, Any]

Returns the runtime options dict.

class ModelExecutableRunInfo(status, errors)

Bases: object

property errors: List[str]

A list of errors.

Is empty unless ‘status’ attribute is ‘FAILED’

property status: ModelExecutableStatus

Status info for a Model-Executable.

Note

For tracing status changes of a running compilation, the ModelExecutableOperation status property must be used and not ModelExecutable entities run info(ModelExecutableRunInfo) status property. See example for usage.

Example:

# To get the case entity run info status
status = fmu.run_info.status

# To get the status updates of a running compilation
compile_ops = = model.compile()
status = compile_ops.status

modelon.impact.client.entities.project module

class GitRepoURL(url, refname='', sha1='')

Bases: object

GitRepoURL represents a project referenced in a git repository String representation is url[@[refname][:sha1]]

classmethod from_dict(data)
Return type:

GitRepoURL

refname: str = ''

Reference name (branch, tag or similar)

sha1: str = ''

Commit hash.

url: str

URL without protocol part, e.g., gitlab.modelon.com/group/project/repository.

class Project(project_id, project_type, storage_location, vcs_uri, service)

Bases: object

Class containing Project functionalities.

property definition: ProjectDefinition

Project definition.

delete()

Deletes a project.

Example:

project.delete()
Return type:

None

classmethod from_operation(operation, **kwargs)
Return type:

Project

get_content(content_id)

Gets the project content with the given ID.

Parameters:

content_id (str) – The ID of the workspace.

Return type:

ProjectContent

Example:

project.get_content("79sd8-3n2a4-e3t24")
get_content_by_name(name, content_type=None)

Gets the first matching project content with the given name.

Parameters:
  • name (str) – The name of the content.

  • content_type (Optional[ContentType]) – The type of the project content.

Return type:

Optional[ProjectContent]

Example:

from modelon.impact.client import ContentType
project.get_content_by_name(name, ContentType.MODELICA)
get_contents()

Get project contents.

Example:

project.get_contents()
Return type:

Iterable[ProjectContent]

get_modelica_library_by_name(name)

Gets the first matching Modelica library with the given name.

Parameters:

name (str) – The Modelica library name.

Return type:

Optional[ProjectContent]

Example:

project.get_content_by_name(name)
get_options(custom_function, use_defaults=False)

Get project execution option.

Parameters:
  • custom_function (CustomFunction) – The CustomFunction class object.

  • use_defaults (Optional[bool]) – If true, default options are used.

Return type:

ProjectExecutionOptions

Example:

dynamic = workspace.get_custom_function('dynamic')
project.get_options(dynamic)
property id: str

Project id.

import_content(path_to_content, content_type)

Upload content to a project.

Parameters:
  • path_to_content (str) – The path for the content to be imported.

  • content_type (ContentType) – The type of the imported content.

Return type:

ContentImportOperation

Example:

from modelon.impact.client import ContentType

project.import_content('/home/test.mo', ContentType.MODELICA).wait()
import_modelica_library(path_to_lib)

Uploads/adds a non-encrypted Modelica library or a Modelica model to the project.

Parameters:

path_to_lib (str) – The path for the library to be imported. Only ‘.mo’ or ‘.zip’ file extension are supported for upload.

Return type:

ContentImportOperation

Example:

content  = project.import_modelica_library('A.mo').wait()
content  = project.import_modelica_library('B.zip').wait()
property name: str

Project name.

property project_type: ProjectType
rename(new_name)

Renames a project.

Parameters:

name – The new name for the project.

Return type:

None

Example:

project.rename('renamed project')
property size: float

Project size in bytes.

property storage_location: StorageLocation
property vcs_uri: VcsUri | None

Project vcs uri.

class ProjectDefinition(data)

Bases: object

Impact project definition.

property content: list
property dependencies: List[ProjectDependency]
property execution_options: List[ProjectExecutionOptions]
property format: str
property name: str
to_dict()
Return type:

Dict[str, Any]

property version: str | None
class ProjectDependency(data)

Bases: object

Dependency entry for a project.

property name: str | None

The name of the project dependency.

property version_specifier: str | None

Version specifier.

class ProjectType(value)

Bases: Enum

Type of project.

LOCAL = 'LOCAL'
RELEASED = 'RELEASED'
SYSTEM = 'SYSTEM'
class StorageLocation(value)

Bases: Enum

The storage location of the project.

APPMODE = 'APPMODE'
SYSTEM = 'SYSTEM'
USERSPACE = 'USERSPACE'
class SvnRepoURL(root_url, branch='', url_from_root='', rev='')

Bases: object

SvnRepoURL represents a project referenced in a Subversion repository String representation is url/trunk/subdir[@[rev]]

branch: str = ''

Non-empty if it’s standard layout and can be either trunk or branches/name or tags/name.

classmethod from_dict(data)
Return type:

SvnRepoURL

get_rev()
Return type:

str

rev: str = ''

Revision number or empty (means HEAD)

root_url: str

URL without protocol part up to branch part, e.g., svn.modelon.com/PNNN/

url_from_root: str = ''

URL segment after branch (could be saved in subdir as well)

class VcsUri(service_kind, service_url, repourl, protocol, subdir)

Bases: object

classmethod from_dict(data)
Return type:

VcsUri

protocol: str
repourl: Union[GitRepoURL, SvnRepoURL]
service_kind: str
service_url: str
subdir: str

modelon.impact.client.entities.result module

class Result(variables, case_id, workspace_id, exp_id, service)

Bases: Mapping

Result class containing base functionality.

keys() a set-like object providing a view on D's keys

modelon.impact.client.entities.status module

class CaseStatus(value)

Bases: Enum

Class representing an enumeration for the possible Case run info states.

CANCELLED = 'cancelled'

Status for experiment execution that has not yet started.

FAILED = 'failed'

Status for case execution that has failed.

NOT_STARTED = 'not_started'

Status for experiment execution that has not yet started.

STARTED = 'started'

Status for case that has started execution.

SUCCESSFUL = 'successful'

Status for case that has been executed successfully.

class ExperimentStatus(value)

Bases: Enum

Class representing an enumeration for the possible experiment run info states.

CANCELLED = 'cancelled'

Status for a cancelled experiment execution.

DONE = 'done'

Status for a completed experiment execution.

FAILED = 'failed'

Status for a failed experiment execution.

NOTSTARTED = 'not_started'

Status for experiment execution that has not yet started.

class ModelExecutableStatus(value)

Bases: Enum

Class representing an enumeration for the possible model-executable run info states.

CANCELLED = 'cancelled'

Status for a cancelled compilation.

FAILED = 'failed'

Status for a failed compilation.

NOTSTARTED = 'not_started'

Status for compilation that has not yet started.

SUCCESSFUL = 'successful'

Status for a successful compilation.

modelon.impact.client.entities.workspace module

class AccessSettings(group_names=None)

Bases: object

group_names: Optional[List[str]] = None
class AppMode(model)

Bases: object

model: str
class OwnerData(data)

Bases: object

property tenant_id: str
property username: str
class ProjectEntry(data)

Bases: object

property disabled: bool
property disabled_content: bool
property id: str
property reference: ReleasedProjectReference | VcsReference | Reference
class PublishedWorkspace(id, definition, service)

Bases: object

Class containing published workspace functionalities.

property created_at: int

Published Workspace timestamp.

property definition: PublishedWorkspaceDefinition

Published workspace definition.

delete()

Deletes the published workspace.

Example:

published_workspace.delete()
Return type:

None

property id: str

Published Workspace id.

import_to_userspace(update_if_available=False)

Imports a published workspace to userspace.

Parameters:
  • update_if_available (bool) – If true, the workspace is updated with the

  • False. (latest copy from the cloud. Default is) –

Return type:

Workspace

Returns:

The workspace class object.

Example::

pw_client = client.get_published_workspaces_client() published_workspace = pw_client.find(owner=”sasuke”, name=”A workspace”)[0] workspace = published_workspace.import_to_userspace()

property name: str

Get or set the name for the published workspace.

Example:

# Get the published workspace name
name = published_workspace.name

# Set the published workspace name
published_workspace.name = 'My workspace'
class PublishedWorkspaceACL(role_names, group_names, shared_with, requested_by)

Bases: object

classmethod from_dict(acl)
Return type:

PublishedWorkspaceACL

group_names: List[str]
requested_by: List[PublishedWorkspaceRequester]
role_names: List[str]
shared_with: List[PublishedWorkspaceRequester]
class PublishedWorkspaceDefinition(name, tenant_id, size, status, owner_username, created_at, app_mode=None)

Bases: object

app_mode: Optional[AppMode] = None
created_at: int
classmethod from_dict(data)
Return type:

PublishedWorkspaceDefinition

name: str
owner_username: str
size: int
status: PublishedWorkspaceUploadStatus
tenant_id: str
class PublishedWorkspaceRequester(id, username)

Bases: object

classmethod from_dict(userdata)
Return type:

PublishedWorkspaceRequester

id: str
username: str
class PublishedWorkspaceType(value)

Bases: Enum

An enumeration.

APP_MODE = 'APP_MODE'
ARCHIVE = 'ARCHIVE'
class PublishedWorkspaceUploadStatus(value)

Bases: Enum

An enumeration.

CREATED = 'created'
DELETING = 'deleting'
INITIALIZING = 'initializing'
class ReceivedFrom(data)

Bases: object

property created_at: int
property owner: OwnerData
property sharing_id: str
property workspace_name: str
class ReceivedFromWorkspace(workspace)

Bases: object

get_workspace()

Return the published workspace from which the workspace was imported from. Returns None if workspace is not linked to any published workspace.

Return type:

Optional[PublishedWorkspace]

Returns:

An PublishedWorkspace class object.

Example:

published_ws = workspace.received_from.get_workspace()
has_updates()

Return True if there are updates available for the published workspace corresponding to the local workspace(if any) else False.

Example:

has_updates = workspace.received_from.has_updates()
Return type:

Optional[bool]

property metadata: ReceivedFrom

Reference metadata for the published workspace.

update_userspace()

Returns the workspaces updated from the latest published one.

Example:

updated_workspace = workspace.received_from.update_userspace()
Return type:

Workspace

class Reference(id)

Bases: object

id: str
class ReleasedProjectReference(id, name, version=None, build=None)

Bases: object

build: Optional[str] = None
id: str
name: str
version: Optional[str] = None
class VcsReference(id, vcs_uri)

Bases: object

id: str
vcs_uri: str
class Workspace(workspace_id, service)

Bases: WorkspaceInterface

Class containing Workspace functionalities.

create_experiment(definition, user_data=None)

Creates an experiment. Returns an Experiment class object.

Parameters:
  • definition (Union[BaseExperimentDefinition, Dict[str, Any]]) – A parametrized experiment definition class of type SimpleModelicaExperimentDefinition or SimpleFMUExperimentDefinition.

  • user_data (Optional[Dict[str, Any]]) – Optional dictionary object with custom data to attach to the experiment.

Return type:

Experiment

Returns:

Experiment class object.

Example:

workspace.create_experiment(definition)
create_project(name)

Creates a new project in the workspace.

Return type:

Project

Returns:

A Project class object.

Example:

project = workspace.create_project("test")
property definition: WorkspaceDefinition

Workspace definition.

delete()

Deletes a workspace.

Example:

workspace.delete()
Return type:

None

download(path)

Downloads the workspace as a binary compressed archive. Returns the local path to the downloaded workspace archive. Similar to export, but does the entire setup and download in one go.

Parameters:

path (str) – The local path to store the downloaded workspace.

Return type:

str

Returns:

Local path to the downloaded workspace archive.

Example:

workspace.download(path)
execute(definition, user_data=None)

Executes an experiment.

Parameters:
  • definition (Union[BaseExperimentDefinition, Dict[str, Any]]) – An experiment definition class instance of SimpleFMUExperimentDefinition or SimpleModelicaExperimentDefinition or a dictionary object containing the definition.

  • user_data (Optional[Dict[str, Any]]) – Optional dictionary object with custom data to attach to the experiment.

Return type:

ExperimentOperation

Returns:

An ExperimentOperation class object.

Example:

experiment_ops = workspace.execute(definition)
experiment_ops.cancel()
experiment_ops.status
experiment_ops.wait()
export(publish=False, class_path=None, access=None)

Exports the workspace as a binary compressed archive. Similar to download, but gives more control for getting the workspace async. Returns an modelon.impact.client.operations.workspace.exports .WorkspaceExportOperation class object. The binary archive is stored to cloud storage if the publish argument is set to True.

Parameters:
  • publish (bool) – To export the workspace and save it to cloud storage.

  • class_path (Optional[str]) – The Modelica class path of the model. If specified, the workspace is exported in app mode.

  • access (Optional[AccessSettings]) – The access control settings for the workspace.

Return type:

WorkspaceExportOperation

Returns:

An WorkspaceExportOperation class object.

Example:

path = workspace.export().wait().download_as('/home/workspace.zip')

# Publish a workspace
workspace.export(publish=True,
    class_path='Modelica.Blocks.Examples.PID_Controller').wait()

# Publish a workspace without sharing with group
from modelon.impact.client import AccessSettings

workspace.export(publish=True,
    class_path='Modelica.Blocks.Examples.PID_Controller',
    access=AccessSettings(group_names=[]).wait()
)
classmethod from_conversion_operation(operation, **kwargs)
Return type:

Workspace

classmethod from_import_operation(operation, **kwargs)
Return type:

Workspace

get_custom_function(name)

Returns a CustomFunction class object.

Parameters:

name (str) – The name of the custom function.

Return type:

CustomFunction

Returns:

The CustomFunction class object.

Example:

workspace.get_custom_function('dynamic')
get_custom_functions()

Returns a list of CustomFunctions class objects.

Return type:

List[CustomFunction]

Returns:

A list of CustomFunction class objects.

Example:

workspace.get_custom_functions()
get_default_project()

Return the default project for a workspace.

Return type:

Project

Returns:

An Project class object.

Example:

project = workspace.get_default_project()
get_dependencies(vcs_info=True, include_disabled=False)

Return the list of project dependencies for a workspace.

Parameters:
  • vcs_info (bool) – If True, the versioning details are returned for the

  • project (if under version control) –

  • include_disabled (bool) – If True, projects disabled in the workspace

  • listed. (are also) –

Return type:

List[Project]

Returns:

A list of Project class object.

Example:

dependencies = workspace.get_dependencies()
get_experiment(experiment_id)

Returns an Experiment class object.

Parameters:

experiment_id (str) – The ID of the experiment.

Return type:

Experiment

Returns:

Experiment class object.

Example:

workspace.get_experiment(experiment_id)
get_experiments(class_path=None)

Returns a list of Experiment class objects.

Parameters:

-- (class_path) – The modelica class path. If given, only the experiments generated for model with the specified class path are returned.

Return type:

List[Experiment]

Returns:

List of Experiment class objects.

Example:

workspace.get_experiments()
get_fmu(fmu_id)

Returns a ModelExecutable class object.

Return type:

ModelExecutable

Returns:

ModelExecutable class object.

Example:

workspace.get_fmu(fmu_id)
get_fmus()

Returns a list of ModelExecutable class objects.

Return type:

List[ModelExecutable]

Returns:

List of ModelExecutable class objects.

Example:

workspace.get_fmus()
get_model(class_name, project=None)

Returns a Model class object.

Parameters:
  • class_name (str) – The Modelica class path of the model.

  • project (Optional[Project]) – Project class object

Return type:

Model

Returns:

Model class object.

Example:

workspace.get_model(class_name)
get_projects(vcs_info=True, include_disabled=False)

Return the list of projects for a workspace.

Parameters:
  • vcs_info (bool) – If True, the versioning details are returned for the

  • project (if under version control) –

  • include_disabled (bool) – If True, projects disabled in the workspace

  • listed. (are also) –

Return type:

List[Project]

Returns:

A list of Project class objects.

Example:

projects = workspace.get_projects()
get_published_workspace(model_name=None)

Returns the published workspace with the name matching this workspace.

Parameters:

model_name (Optional[str]) – Class path of the Modelica model. If specified, an app mode published workspace corresponding to the local workspace is returned(if it exists).

Return type:

Optional[PublishedWorkspace]

Returns:

An PublishedWorkspace class object.

Example:

published_ws = workspace.get_published_workspace()
get_shared_definition(strict=False)

Return the shared definition for a workspace.

Parameters:

strict (bool) – If True, the version control URIs for workspace projects and dependencies are to specific commits or not.

Return type:

WorkspaceDefinition

Returns:

An WorkspaceDefinition class object.

Example:

definition = workspace.get_shared_definition()
property id: str

Workspace id.

import_dependency_from_zip(path_to_dependency)

Imports a Project dependency from a compressed(.zip) project file and adds it to the workspace. Returns the project class object.

Parameters:
  • path_to_dependency (str) – The path for the compressed project(.zip) to be

  • uploaded.

Return type:

ProjectImportOperation

Returns:

An ProjectImportOperation class object.

Example:

workspace.import_dependency_from_zip(path_to_project).wait()
import_project_from_zip(path_to_project)

Imports a Project from a compressed(.zip) project file and adds it to the workspace. Returns the project class object.

Parameters:

path_to_project (str) – The path for the compressed project(.zip) to be uploaded.

Return type:

ProjectImportOperation

Returns:

A ProjectImportOperation class object.

Example:

workspace.import_project_from_zip(path_to_project).wait()
property name: str

Workspace name.

property received_from: ReceivedFromWorkspace

Returns an instance of ReceivedFromWorkspace class.

rename(new_name)

Renames a workspace.

Parameters:

name – The new name for the workspace.

Return type:

None

Example:

workspace.rename('renamed workspace')
property size: float

Workspace size in bytes.

upload_result(path_to_result, label=None, description=None)

Uploads a ‘.mat’ result file to the workspace.

Parameters:
  • path_to_result (str) – The path for the result file to be imported.

  • label (Optional[str]) – The label of the result file. Default: None.

  • description (Optional[str]) – The description of the result file. Default: None.

Return type:

ExternalResultImportOperation

Example:

workspace.upload_result('A.mat')
workspace.upload_result('B.mat', label = "result_for_PID.mat",
description = "This is a result file for PID controller")
class WorkspaceDefinition(data)

Bases: object

property created_by: str

User ID of the workspace creator.

property default_project_id: str

Project ID of the default workspace project.

property dependencies: List[ProjectEntry]

List of workspace dependencies.

property description: str

Workspace description.

property format: str

Workspace definition format.

classmethod from_file(path)

Constructs WorkspaceDefinition class from JSON file.

Parameters:

path (str) – The path of the JSON file.

Return type:

WorkspaceDefinition

Returns:

The WorkspaceDefinition class object.

Example:

definition = workspace.from_file('/home/definition.json')
property name: str

Workspace name.

property projects: List[ProjectEntry]

List of workspace projects.

property received_from: ReceivedFrom | None

Received from information for the workspace, if imported from cloud.

to_dict()

Returns the workspace definition as a dict.

Return type:

Dict[str, Any]

to_file(path)

Writes the workspace definition as a JSON file.

Parameters:

path (str) – The path of the folder to store the file at.

Return type:

str

Returns:

The file path of the created JSON file.

Example:

file = workspace.to_file('/home/workspace/definition')

Module contents