Engine#

class Engine(is_run_only: bool = False, force_local: bool = False, heartbeat_interval: numpy.uint = 30000, allowed_heartbeat_misses: numpy.uint = 3)#

Bases: ansys.modelcenter.workflow.api.IEngine

Provides the gRPC implementation of IEngine.

Overview#

close

Shut down the gRPC server and clear out all objects.

new_workflow

Create a workflow.

load_workflow

Load a workflow from a local file into the engine.

get_formatter

Create an instance of a formatter that can be used to format numbers

get_preference

Get the value of a preference.

set_preference

Set the value of a preference.

get_units

Get available units by category.

get_run_only_mode

Get whether the engine is in run-only mode.

get_server_info

Get information about the server that is serving the request.

is_closed

Flag indicating if this instance has been closed.

is_local

Flag indicating if ModelCenter Desktop was started locally or

channel

Get the gRPC channel used to communicate with ModelCenter Desktop.

process_id

ID of the connected process, which is useful for debugging.

__enter__

Initialization when created in a β€˜with’ statement.

__exit__

Clean up when leaving a β€˜with’ block.

Import detail#

from ansys.modelcenter.workflow.grpc_modelcenter.engine import Engine

Property detail#

property Engine.is_closed: bool#

Flag indicating if this instance has been closed.

property Engine.is_local: bool#

Flag indicating if ModelCenter Desktop was started locally or remotely.

Returns:
bool

True if ModelCenter Desktop was started locally, False otherwise.

property Engine.channel: grpc.Channel | None#

Get the gRPC channel used to communicate with ModelCenter Desktop.

Returns:
grpc.Channel

grpc.Channel object or None if it has not been created.

property Engine.process_id: int#

ID of the connected process, which is useful for debugging.

Returns:
int

Process ID of the connected ModelCenter Desktop.

Method detail#

Engine.__enter__()#

Initialization when created in a β€˜with’ statement.

Engine.__exit__(exc_type, exc_val, exc_tb)#

Clean up when leaving a β€˜with’ block.

Engine.close()#

Shut down the gRPC server and clear out all objects.

Engine.new_workflow(name: str, workflow_type: ansys.modelcenter.workflow.api.WorkflowType = WorkflowType.DATA) ansys.modelcenter.workflow.grpc_modelcenter.workflow.Workflow#

Create a workflow.

Parameters:
namestr

Filename or path where the workflow is to be created.

workflow_typeWorkflowType, optional

Type of workflow. The default is a data workflow.

Returns:
IWorkflow

Created IWorkflow instance.

Engine.load_workflow(file_name: os.PathLike | str, ignore_connection_errors: bool | None = None) ansys.modelcenter.workflow.grpc_modelcenter.workflow.Workflow#

Load a workflow from a local file into the engine.

Engine.get_formatter(fmt: str) ansys.modelcenter.workflow.grpc_modelcenter.format.Format#

Create an instance of a formatter that can be used to format numbers to and from a particular string style.

Parameters:
fmtstr

Specified string format for the IFormat object.

Returns:
IFormat

Format object that formats in the given style.

Engine.get_preference(pref: str) bool | int | float | str#

Get the value of a preference.

Preferences control how the engine behaves in various ways. The data type of the value may be bool, float, int, or str.

Parameters:
prefstr

Name of the preference to return the value for.

Returns:
Union[bool, int, float, str]

Value of the given preference.

Engine.set_preference(pref: str, value: bool | int | float | str) None#

Set the value of a preference.

Preferences control how the engine behaves in various ways. The data type of the value may be bool, float, int, or str.

Parameters:
prefstr

Name of the preference to set.

value: Union[bool, int, float, str]

Value to set.

Engine.get_units() Mapping[str, Collection[str]]#

Get available units by category.

Returns:
Mapping[str, Collection[str]]

Mapping representing the units available in the engine. The keys in the map are the names of unit categories, and the values are collections containing all the unit names for that category.

Engine.get_run_only_mode() bool#

Get whether the engine is in run-only mode.

Run-only mode has lower licensing requirements, but it does not allow for the workflow to be edited.

Returns:
bool

True if in run-only mode, False otherwise.

Engine.get_server_info() ansys.engineeringworkflow.api.WorkflowEngineInfo#

Get information about the server that is serving the request.

Returns:
WorkflowEngineInfo

Object with information about the server that is serving the request.