spinetoolbox.project_items.tool.tool_instance

Contains ToolInstance class.

authors:
  1. Savolainen (VTT), E. Rinne (VTT)
date:

1.2.2018

Module Contents

Classes

ToolInstance Tool instance base class.
GAMSToolInstance Class for GAMS Tool instances.
JuliaToolInstance Class for Julia Tool instances.
PythonToolInstance Class for Python Tool instances.
ExecutableToolInstance Class for Executable Tool instances.
class spinetoolbox.project_items.tool.tool_instance.ToolInstance(tool_specification, basedir, settings, logger)[source]

Bases: PySide2.QtCore.QObject

Tool instance base class.

Parameters:
  • tool_specification (ToolSpecification) – the tool specification for this instance
  • basedir (str) – the path to the directory where this instance should run
  • settings (QSettings) – Toolbox settings
  • logger (LoggerInterface) – a logger instance
instance_finished[source]

Signal to emit when a Tool instance has finished processing

is_running(self)[source]
terminate_instance(self)[source]

Terminates Tool instance execution.

remove(self)[source]

[Obsolete] Removes Tool instance files from work directory.

prepare(self, optional_input_files, input_database_urls, output_database_urls, tool_args)[source]

Prepares this instance for execution.

Implement in subclasses to perform specific initialization.

Parameters:
  • optional_input_files (list) – list of tool’s optional input files
  • input_database_urls (dict) – a mapping from upstream Data Store name to database URL
  • output_database_urls (dict) – a mapping from downstream Data Store name to database URL
  • tool_args (list) – Tool cmd line args
execute(self, **kwargs)[source]

Executes a prepared instance. Implement in subclasses.

handle_execution_finished(self, ret)[source]

Handles execution finished.

Parameters:ret (int) –
append_cmdline_args(self, optional_input_files, input_database_urls, output_database_urls, tool_args)[source]

Appends Tool specification command line args into instance args list.

Parameters:
  • optional_input_files (list) – list of tool’s optional input files
  • input_database_urls (dict) – a mapping from upstream Data Store name to database URL
  • output_database_urls (dict) – a mapping from downstream Data Store name to database URL
  • tool_args (list) – List of Tool cmd line args
class spinetoolbox.project_items.tool.tool_instance.GAMSToolInstance(tool_specification, basedir, settings, logger)[source]

Bases: spinetoolbox.project_items.tool.tool_instance.ToolInstance

Class for GAMS Tool instances.

Parameters:
  • tool_specification (ToolSpecification) – the tool specification for this instance
  • basedir (str) – the path to the directory where this instance should run
  • settings (QSettings) – Toolbox settings
  • logger (LoggerInterface) – a logger instance
prepare(self, optional_input_files, input_database_urls, output_database_urls, tool_args)[source]

See base class.

execute(self, **kwargs)[source]

Executes a prepared instance.

handle_execution_finished(self, ret)[source]

Handles execution finished.

Parameters:ret (int) –
class spinetoolbox.project_items.tool.tool_instance.JuliaToolInstance(tool_specification, basedir, settings, embedded_julia_console, logger)[source]

Bases: spinetoolbox.project_items.tool.tool_instance.ToolInstance

Class for Julia Tool instances.

Parameters:
  • tool_specification (ToolSpecification) – the tool specification for this instance
  • basedir (str) – the path to the directory where this instance should run
  • settings (QSettings) – Toolbox settings
  • embedded_julia_console (JuliaREPLWidget) – a Julia console for execution in the embedded console
  • logger (LoggerInterface) – a logger instance
prepare(self, optional_input_files, input_database_urls, output_database_urls, tool_args)[source]

See base class.

execute(self, **kwargs)[source]

Executes a prepared instance.

handle_repl_execution_finished(self, ret)[source]

Handles repl-execution finished.

Parameters:ret (int) – Tool specification process return value
handle_execution_finished(self, ret)[source]

Handles execution finished.

Parameters:ret (int) – Tool specification process return value
class spinetoolbox.project_items.tool.tool_instance.PythonToolInstance(tool_specification, basedir, settings, embedded_python_console, logger)[source]

Bases: spinetoolbox.project_items.tool.tool_instance.ToolInstance

Class for Python Tool instances.

Parameters:
  • tool_specification (ToolSpecification) – the tool specification for this instance
  • basedir (str) – the path to the directory where this instance should run
  • settings (QSettings) – Toolbox settings
  • embedded_python_console (PythonReplWidget) – a Python console widget for execution in embedded console
  • logger (LoggerInterface) – A logger instance
prepare(self, optional_input_files, input_database_urls, output_database_urls, tool_args)[source]

See base class.

execute(self, **kwargs)[source]

Executes a prepared instance.

handle_console_execution_finished(self, ret)[source]

Handles console-execution finished.

Parameters:ret (int) – Tool specification process return value
handle_execution_finished(self, ret)[source]

Handles execution finished.

Parameters:ret (int) – Tool specification process return value
class spinetoolbox.project_items.tool.tool_instance.ExecutableToolInstance(tool_specification, basedir, settings, logger)[source]

Bases: spinetoolbox.project_items.tool.tool_instance.ToolInstance

Class for Executable Tool instances.

Parameters:
  • tool_specification (ToolSpecification) – the tool specification for this instance
  • basedir (str) – the path to the directory where this instance should run
  • settings (QSettings) – Toolbox settings
  • logger (LoggerInterface) – a logger instance
prepare(self, optional_input_files, input_database_urls, output_database_urls, tool_args)[source]

See base class.

execute(self, **kwargs)[source]

Executes a prepared instance.

handle_execution_finished(self, ret)[source]

Handles execution finished.

Parameters:ret (int) – Tool specification process return value