modelon.impact.client.operations package

Subpackages

Submodules

modelon.impact.client.operations.base module

class AsyncOperation(create_entity)

Bases: BaseOperation[Entity]

File operation class containing base functionality.

cancel()

Terminates the operation.

Return type:

None

wait(timeout=None)

Waits until the operation completes. Returns the operation class instance if operation completes.

Parameters:

timeout (Optional[float]) – Time to wait in seconds for achieving the status. By default the timeout is set to ‘None’, which signifies an infinite time to wait until the status is achieved.

Return type:

TypeVar(Entity)

Returns:

Entity class instance if operation completes.

Raises:

OperationTimeOutError if time exceeds set timeout.

Example:

workspace.upload_result('A.mat').wait(timeout = 120)
class AsyncOperationStatus(value)

Bases: Enum

Defines all states for import.

ERROR = 'error'

Status for an async operation that has errors.

READY = 'ready'

Status for an async operation that is ready.

RUNNING = 'running'

Status for an async operation that is running.

done()
Return type:

bool

class BaseOperation(create_entity)

Bases: Generic[Entity]

Abstract base operation class.

abstract cancel()

Terminates the operation.

Return type:

Any

abstract data()

Returns the Entity class.

Return type:

TypeVar(Entity)

abstract property name: str

Name of the operation.

abstract property status: Any

Returns the operation status as an enumeration.

abstract wait(timeout)

Waits for the operation to finish.

Return type:

TypeVar(Entity)

class EntityFromOperation(*args, **kwargs)

Bases: Protocol[Entity]

class ExecutionOperation(create_entity)

Bases: BaseOperation[Entity]

Execution operation class containing base functionality.

is_complete()

Returns True if the operation has completed.

Return type:

bool

Returns:

True, if operation has completed.False, if operation has not completed.

Example:

model.compile(options).is_complete()
workspace.execute(definition).is_complete()
wait(timeout=None, status=Status.DONE)

Waits until the operation achieves the set status. Returns the operation class instance if the set status is achieved.

Parameters:
  • timeout (Optional[float]) – Time to wait in seconds for achieving the status. By default the timeout is set to ‘None’, which signifies an infinite time to wait until the status is achieved.

  • status (Status) – Operation status to be achieved. Default: Status.DONE

Return type:

TypeVar(Entity)

Returns:

Entity class instance if the set status is achieved.

Raises:

OperationTimeOutError if time exceeds set timeout.

Example:

model.compile(compile_options).wait(
    timeout = 120,
    status = Status.CANCELLED
    )
workspace.execute(experiment_definition).wait(timeout = 120)
class Status(value)

Bases: Enum

Class representing an enumeration for the possible operation states.

CANCELLED = 'cancelled'

Status for an operation that has been cancelled.

DONE = 'done'

Status for an operation that has been completed.

PENDING = 'pending'

Status for an operation that is pending.

RUNNING = 'running'

Status for an operation that is running.

STOPPING = 'stopping'

Status for an operation that has been cancelled and is stopping.

modelon.impact.client.operations.case module

class CaseOperation(workspace_id, exp_id, case_id, service, create_entity)

Bases: ExecutionOperation[Entity]

An operation class for the Case class.

cancel()

Terminates the execution process.

Example:

case.execute().cancel()
Return type:

None

data()

Returns a new Case class instance.

Return type:

TypeVar(Entity)

Returns:

An Case class instance.

property id: str

Case id.

property name: str

Return the name of operation.

property status: Status

Returns the execution status as an enumeration.

Returns:

The execution status enum. The status can have the enum values Status.PENDING, Status.RUNNING, Status.STOPPING, Status.CANCELLED or Status.DONE

Example:

case.execute().status

modelon.impact.client.operations.case_result module

class CaseResultImportOperation(location, workspace_id, exp_id, case_id, service, create_entity)

Bases: AsyncOperation[Entity]

An operation class for the Result class.

data()

Returns a new Result class instance.

Return type:

TypeVar(Entity)

Returns:

A Result class instance.

property id: str

Case result import id.

property name: str

Return the name of operation.

property status: AsyncOperationStatus

Returns the upload status as an enumeration.

Returns:

The AsyncOperationStatus enum. The status can have the enum values AsyncOperationStatus.READY, AsyncOperationStatus.RUNNING or AsyncOperationStatus.ERROR

Example:

case.import_result('path/to/result.csv').status

modelon.impact.client.operations.content_import module

class ContentImportOperation(location, service, create_entity)

Bases: AsyncOperation[Entity]

An operation class for the ProjectContent class.

data()

Returns a new ProjectContent class instance.

Return type:

TypeVar(Entity)

Returns:

A ProjectContent class instance.

property id: str

Content import id.

property name: str

Return the name of operation.

property status: AsyncOperationStatus

Returns the upload status as an enumeration.

Returns:

The AsyncOperationStatus enum. The status can have the enum values AsyncOperationStatus.READY, AsyncOperationStatus.RUNNING or AsyncOperationStatus.ERROR

Example:

project.import_content('path/to/model.mo').status

modelon.impact.client.operations.custom_artifact module

class CustomArtifactImportOperation(location, workspace_id, exp_id, case_id, service, create_entity)

Bases: AsyncOperation[Entity]

An operation class for the CustomArtifact class.

data()

Returns a new CustomArtifact class instance.

Return type:

TypeVar(Entity)

Returns:

A CustomArtifact class instance.

property id: str

Custom artifact import id.

property name: str

Return the name of operation.

property status: AsyncOperationStatus

Returns the upload status as an enumeration.

Returns:

The AsyncOperationStatus enum. The status can have the enum values AsyncOperationStatus.READY, AsyncOperationStatus.RUNNING or AsyncOperationStatus.ERROR

Example:

case.import_custom_artifact('path/to/artifact.csv').status

modelon.impact.client.operations.experiment module

class ExperimentOperation(workspace_id, exp_id, service, create_entity)

Bases: ExecutionOperation[Entity]

An operation class for the Experiment class.

cancel()

Terminates the execution process.

Example:

workspace.execute(definition).cancel()
Return type:

None

data()

Returns a new Experiment class instance.

Return type:

TypeVar(Entity)

Returns:

An experiment class instance.

property id: str

Experiment id.

property name: str

Return the name of operation.

property status: Status

Returns the execution status as an enumeration.

Returns:

The execution status enum. The status can have the enum values Status.PENDING, Status.RUNNING, Status.STOPPING, Status.CANCELLED or Status.DONE

Example:

workspace.execute(definition).status

modelon.impact.client.operations.external_result_import module

class ExternalResultImportOperation(location, service, create_entity)

Bases: AsyncOperation[Entity]

An operation class for the ExternalResult class.

data()

Returns a new ExternalResult class instance.

Return type:

TypeVar(Entity)

Returns:

A ExternalResult class instance.

property id: str

Result import id.

property name: str

Return the name of operation.

property status: AsyncOperationStatus

Returns the upload status as an enumeration.

Returns:

The AsyncOperationStatus enum. The status can have the enum values AsyncOperationStatus.READY, AsyncOperationStatus.RUNNING or AsyncOperationStatus.ERROR

Example:

workspace.upload_result('A.mat').status

modelon.impact.client.operations.fmu_import module

class FMUImportOperation(location, workspace_id, project_id, service, create_entity)

Bases: AsyncOperation[Entity]

An operation class for the Model class.

data()

Returns a new Model class instance.

Return type:

TypeVar(Entity)

Returns:

A Model class instance.

property id: str

FMU import id.

property name: str

Return the name of operation.

property status: AsyncOperationStatus

Returns the upload status as an enumeration.

Returns:

The AsyncOperationStatus enum. The status can have the enum values AsyncOperationStatus.READY, AsyncOperationStatus.RUNNING or AsyncOperationStatus.ERROR

Example:

model.import_fmu('test.fmu').status

modelon.impact.client.operations.model_executable module

class CachedModelExecutableOperation(workspace_id, fmu_id, service, create_entity, info=None, modifiers=None)

Bases: ExecutionOperation[Entity]

An operation class for a cached ModelExecutable class.

cancel()

Terminates the operation.

Return type:

None

data()

Returns a new ModelExecutable class instance.

Return type:

TypeVar(Entity)

Returns:

A model_executable class instance.

property id: str

FMU id.

property name: str

Return the name of operation.

property status: Status

Returns the compilation status as an enumeration.

Returns:

The compilation status enum. The status has the enum value Status.DONE as a cached FMU is only possible for a successfully finished compilation.

Example:

model.compile(options).status
wait(timeout=None, status=Status.DONE)

Waits until the operation achieves the set status. Returns the operation class instance if the set status is achieved.

Parameters:
  • timeout (Optional[float]) – Time to wait in seconds for achieving the status.This argument is not accounted for the CachedModelExecutableOperation class as the model has a successfully compiled status(Status.DONE) in this class.

  • status (Status) – Operation status to be achieved. The only possible status for the CachedModelExecutableOperation class is Status.DONE as cached FMU is only available for a successfully compiled model.

Return type:

TypeVar(Entity)

Returns:

Entity class instance if the set status is achieved.

Raises:

OperationTimeOutError if operation status is not set as Status.DONE.

Example:

model.compile(compile_options).wait()
class ModelExecutableOperation(workspace_id, fmu_id, service, create_entity)

Bases: ExecutionOperation[Entity]

An operation class for the ModelExecutable class.

cancel()

Terminates the compilation process.

Example:

model.compile(options).cancel()
Return type:

None

data()

Returns a new ModelExecutable class instance.

Return type:

TypeVar(Entity)

Returns:

A ModelExecutable class instance.

property id: str

FMU id.

property name: str

Return the name of operation.

property status: Status

Returns the compilation status as an enumeration.

Returns:

The compilation status enum. The status can have the enum values Status.PENDING, Status.RUNNING, Status.STOPPING, Status.CANCELLED or Status.DONE

Example:

model.compile(options).status

modelon.impact.client.operations.project_import module

class ProjectImportOperation(location, service, create_entity)

Bases: AsyncOperation[Entity]

An import operation class for the Project class.

data()

Returns a new Project class instance.

Return type:

TypeVar(Entity)

Returns:

A Project class instance.

property id: str

Project import id.

property name: str

Return the name of operation.

property status: AsyncOperationStatus

Returns the upload status as an enumeration.

Returns:

The AsyncOperationStatus enum. The status can have the enum values AsyncOperationStatus.READY, AsyncOperationStatus.RUNNING or AsyncOperationStatus.ERROR

Example:

status = client.import_project_from_zip(path_to_project).status
status = workspace.import_project_from_zip(path_to_project).status

Module contents