spinetoolbox.headless
Contains facilities to open and execute projects without GUI.
Module Contents
Classes
A |
|
A simple project that is available for modification script. |
|
A 'task' which opens Toolbox project and operates on it. |
|
Status codes returned from headless execution. |
Functions
|
Executes a project using |
|
Opens a project. |
|
Loads project item specification dictionaries. |
Makes given path object OS independent. |
- class spinetoolbox.headless.HeadlessLogger[source]
Bases:
PySide6.QtCore.QObject
A
LoggerInterface
compliant logger that uses Python’s standard logging facilities.- msg_proc[source]
Emits a message originating from a subprocess (usually something printed to stdout).
- msg_proc_error[source]
Emits an error message originating from a subprocess (usually something printed to stderr).
- class spinetoolbox.headless.ModifiableProject(project_dir, items_dict, connection_dicts)[source]
A simple project that is available for modification script.
- Parameters
project_dir (Path) – project directory
items_dict (dict) – project item dictionaries
connection_dicts (list of dict) – connection dictionaries
- find_connection(source_name, destination_name)[source]
Searches for a connection between given items.
- Parameters
source_name (str) – source item’s name
destination_name (str) – destination item’s name
- Returns
connection instance or None if there is no connection
- Return type
Connection
- find_item(name)[source]
Searches for a project item.
- Parameters
name (str) – item’s name
- Returns
item dict or None if no such item exists
- Return type
dict
- class spinetoolbox.headless.ActionsWithProject(args, startup_event_type, parent)[source]
Bases:
PySide6.QtCore.QObject
A ‘task’ which opens Toolbox project and operates on it.
The execution of this task is triggered by sending it a ‘startup’ QEvent using e.g. QCoreApplication.postEvent()
- Parameters
args (argparse.Namespace) – parsed command line arguments
startup_event_type (int) – expected type id for the event that starts this task
parent (QObject) – a parent object
- _start[source]
A private signal to actually start execution. Not to be used directly. Post a startup event instead.
- _check_project_version(project_dict)[source]
Checks project dict version.
- Parameters
project_dict (dict) – project dict
- Returns
status code
- Return type
- _exec_mod_script()[source]
Executes project modification script given in command line arguments.
- Returns
status code
- Return type
- _handle_node_execution_started(data)[source]
Starts collecting messages from given node.
- Parameters
data (dict) – execution start data
- _handle_node_execution_finished(data)[source]
Prints messages for finished nodes.
- Parameters
data (dict) – execution end data
- _handle_event_msg(data)[source]
Stores event messages for later printing.
- Parameters
data (dict) – event message data
- _handle_process_msg(data)[source]
Stores process messages for later printing.
- Parameters
data (dict) – process message data
- _handle_standard_execution_msg(data)[source]
Handles standard execution messages.
Currently, these messages are ignored.
- Parameters
data (dict) – execution message data
- _handle_persistent_execution_msg(data)[source]
Handles persistent execution messages.
- Parameters
data (dict) – execution message data
- _handle_kernel_execution_msg(data)[source]
Handles kernel messages.
Currently, these messages are ignored.
- Parameters
data (dict) – message data
- _read_server_config()[source]
Reads the user provided server settings file that the client requires to establish connection.
- Returns
Dictionary containing the EngineClient settings or None if the given config file does not exist.
- Return type
dict
- _insert_remote_engine_settings(settings)[source]
Inserts remote engine client settings into the settings dictionary that is delivered to the engine.
- Parameters
settings (dict) – Original settings dictionary
- Returns
Settings dictionary containing remote engine client settings
- Return type
dict
- _prepare_remote_execution()[source]
If remote execution is enabled, makes an EngineClient for pinging and uploading the project. If ping is successful, the project is uploaded to the server. If the upload is successful, the server responds with a Job id, which is later used by the client to make a ‘start execution’ request.
- Returns
- Job id if server is ready for remote execution, empty string if something went wrong
or “1” if local execution is enabled.
- Return type
str
- spinetoolbox.headless.headless_main(args)[source]
Executes a project using
QCoreApplication
.- Parameters
args (argparser.Namespace) – parsed command line arguments.
- Returns
exit status code; 0 for success, everything else for failure
- Return type
int
- spinetoolbox.headless.open_project(project_dict, project_dir, logger)[source]
Opens a project.
- Parameters
project_dict (dict) – a serialized project dictionary
project_dir (Path) – path to a directory containing the
.spinetoolbox
dirlogger (LoggerInterface) – a logger
- Returns
item dicts, specification dicts, connection dicts, jump dicts and a DagHandler object
- Return type
tuple
- spinetoolbox.headless._specification_dicts(project_dict, project_dir, logger)[source]
Loads project item specification dictionaries.
- Parameters
project_dict (dict) – a serialized project dictionary
project_dir (str) – path to a directory containing the
.spinetoolbox
dirlogger (LoggerInterface) – a logger
- Returns
a mapping from item type to a list of specification dicts
- Return type
dict