spinetoolbox.spine_engine_manager

Contains SpineEngineManagerBase.

Module Contents

Classes

SpineEngineManagerBase

LocalSpineEngineManager

RemoteSpineEngineManager

Responsible for remote project execution.

Functions

make_engine_manager([remote_execution_enabled, job_id])

Returns either a Local or a remote Spine Engine Manager based on settings.

class spinetoolbox.spine_engine_manager.SpineEngineManagerBase[source]
abstract run_engine(engine_data)[source]

Runs an engine with given data.

Parameters

engine_data (dict) – The engine data.

abstract get_engine_event()[source]

Gets next event from a running engine.

Returns

two element tuple: event type identifier string, and event data dictionary

Return type

tuple(str,dict)

abstract stop_engine()[source]

Stops a running engine.

abstract answer_prompt(prompter_id, answer)[source]

Answers prompt.

Parameters
  • prompter_id (int) – The id of the prompter

  • answer – The user’s decision.

abstract restart_kernel(connection_file)[source]

Restarts the jupyter kernel associated to given connection file.

Parameters

connection_file (str) – path of connection file

abstract shutdown_kernel(connection_file)[source]

Shuts down the jupyter kernel associated to given connection file.

Parameters

connection_file (str) – path of connection file

abstract issue_persistent_command(persistent_key, command)[source]

Issues a command to a persistent process.

Parameters
  • persistent_key (tuple) – persistent identifier

  • command (str) – command to issue

Returns

stdin, stdout, and stderr messages (dictionaries with two keys: type, and data)

Return type

generator

abstract is_persistent_command_complete(persistent_key, command)[source]

Checks whether a command is complete.

Parameters
  • key (tuple) – persistent identifier

  • cmd (str) – command to issue

Returns

bool

abstract restart_persistent(persistent_key)[source]

Restarts a persistent process.

Parameters

persistent_key (tuple) – persistent identifier

Returns

stdout and stderr messages (dictionaries with two keys: type, and data)

Return type

generator

abstract interrupt_persistent(persistent_key)[source]

Interrupts a persistent process.

Parameters

persistent_key (tuple) – persistent identifier

abstract kill_persistent(persistent_key)[source]

Kills a persistent process.

Parameters

persistent_key (tuple) – persistent identifier

abstract get_persistent_completions(persistent_key, text)[source]

Returns a list of auto-completion options from given text.

Parameters
  • persistent_key (tuple) – persistent identifier

  • text (str) – text to complete

Returns

list of str

abstract get_persistent_history_item(persistent_key, text, prefix, backwards)[source]

Returns an item from persistent history.

Parameters

persistent_key (tuple) – persistent identifier

Returns

history item or empty string if none

Return type

str

class spinetoolbox.spine_engine_manager.LocalSpineEngineManager[source]

Bases: SpineEngineManagerBase

run_engine(engine_data)[source]

Runs an engine with given data.

Parameters

engine_data (dict) – The engine data.

get_engine_event()[source]

Gets next event from a running engine.

Returns

two element tuple: event type identifier string, and event data dictionary

Return type

tuple(str,dict)

stop_engine()[source]

Stops a running engine.

answer_prompt(prompter_id, answer)[source]

Answers prompt.

Parameters
  • prompter_id (int) – The id of the prompter

  • answer – The user’s decision.

restart_kernel(connection_file)[source]

Restarts the jupyter kernel associated to given connection file.

Parameters

connection_file (str) – path of connection file

shutdown_kernel(connection_file)[source]

Shuts down the jupyter kernel associated to given connection file.

Parameters

connection_file (str) – path of connection file

kernel_managers()[source]
issue_persistent_command(persistent_key, command)[source]

Issues a command to a persistent process.

Parameters
  • persistent_key (tuple) – persistent identifier

  • command (str) – command to issue

Returns

stdin, stdout, and stderr messages (dictionaries with two keys: type, and data)

Return type

generator

is_persistent_command_complete(persistent_key, command)[source]

Checks whether a command is complete.

Parameters
  • key (tuple) – persistent identifier

  • cmd (str) – command to issue

Returns

bool

restart_persistent(persistent_key)[source]

Restarts a persistent process.

Parameters

persistent_key (tuple) – persistent identifier

Returns

stdout and stderr messages (dictionaries with two keys: type, and data)

Return type

generator

interrupt_persistent(persistent_key)[source]

Interrupts a persistent process.

Parameters

persistent_key (tuple) – persistent identifier

kill_persistent(persistent_key)[source]

Kills a persistent process.

Parameters

persistent_key (tuple) – persistent identifier

get_persistent_completions(persistent_key, text)[source]

Returns a list of auto-completion options from given text.

Parameters
  • persistent_key (tuple) – persistent identifier

  • text (str) – text to complete

Returns

list of str

get_persistent_history_item(persistent_key, text, prefix, backwards)[source]

Returns an item from persistent history.

Parameters

persistent_key (tuple) – persistent identifier

Returns

history item or empty string if none

Return type

str

class spinetoolbox.spine_engine_manager.RemoteSpineEngineManager(job_id='')[source]

Bases: SpineEngineManagerBase

Responsible for remote project execution.

Initializer.

make_engine_client(host, port, security, sec_folder, ping=True)[source]

Creates a client for connecting to Spine Engine Server.

run_engine(engine_data)[source]

Makes an engine client for communicating with the engine server. Starts a thread for monitoring the DAG execution on server.

Parameters

engine_data (dict) – The engine data.

get_engine_event()[source]

Returns the next engine execution event.

clean_up()[source]

Closes EngineClient and joins _runner thread if still active.

stop_engine()[source]

Sends a request to stop execution on Server then waits for _runner thread to end.

_run()[source]

Sends a start execution request to server with the job Id. Sets up a subscribe socket according to the publish port received from server. Passes received events to SpineEngineWorker for processing. After execution has finished, downloads new files from server.

answer_prompt(prompter_id, answer)[source]

See base class.

restart_kernel(connection_file)[source]

See base class.

shutdown_kernel(connection_file)[source]

See base class.

is_persistent_command_complete(persistent_key, command)[source]

Checks whether a command is complete.

Parameters
  • key (tuple) – persistent identifier

  • cmd (str) – command to issue

Returns

bool

issue_persistent_command(persistent_key, command)[source]

Issues a command to a persistent process.

Parameters
  • persistent_key (tuple) – persistent identifier

  • command (str) – command to issue

Returns

stdin, stdout, and stderr messages (dictionaries with two keys: type, and data)

Return type

generator

restart_persistent(persistent_key)[source]

See base class.

interrupt_persistent(persistent_key)[source]

See base class.

kill_persistent(persistent_key)[source]

See base class.

get_persistent_completions(persistent_key, text)[source]

See base class.

get_persistent_history_item(persistent_key, text, prefix, backwards)[source]

Returns an item from persistent history.

Parameters

persistent_key (tuple) – persistent identifier

Returns

history item or empty string if none

Return type

str

spinetoolbox.spine_engine_manager.make_engine_manager(remote_execution_enabled=False, job_id='')[source]

Returns either a Local or a remote Spine Engine Manager based on settings.

Parameters
  • remote_execution_enabled (bool) – True returns a local Spine Engine Manager instance,

  • instance (False returns a remote Spine Engine Manager) –

  • job_id (str) – Server execution job Id