tool_instance

Contains ToolInstance class.

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

1.2.2018

Module Contents

class tool_instance.ToolInstance(tool_template, toolbox, tool_output_dir, project, execute_in_work)[source]

Bases: PySide2.QtCore.QObject

Class for Tool instances.

Parameters:
  • tool_template (ToolTemplate) – Tool for which this instance is created
  • toolbox (ToolboxUI) – QMainWindow instance
  • tool_output_dir (str) – Directory where results are saved
  • project (SpineToolboxProject) – Current project
  • execute_in_work (bool) – True executes instance in work dir, False executes in Tool template source dir
Class Variables:
instance_finished_signal (Signal): Signal to emit when a Tool instance has finished processing
instance_finished_signal[source]
_checkout[source]

Copies Tool template files to work directory.

execute(self)[source]

Starts executing Tool template instance in Julia Console, Python Console or in a sub-process.

julia_repl_tool_finished(self, ret)[source]

Runs when Julia tool using Julia Console has finished processing.

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

Runs when Julia tool from command line (without REPL) has finished processing.

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

Runs when Python Tool in Python Console has finished processing.

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

Runs when Python tool from command line has finished processing.

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

Runs when GAMS tool has finished processing.

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

Runs when an executable tool has finished processing.

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

Creates a timestamped result directory for Tool template output files. Starts copying Tool template output files from work directory to result directory and print messages to Event Log depending on how the operation went.

Parameters:ret (int) – Tool template process return value
terminate_instance(self)[source]

Terminates Tool instance execution.

remove(self)[source]

[Obsolete] Removes Tool instance files from work directory.

copy_output(self, target_dir)[source]

Copies Tool template output files from work directory to given target directory.

Parameters:target_dir (str) – Destination directory for Tool template output files
Returns:Contains two lists. The first list contains paths to successfully copied files. The second list contains paths (or patterns) of Tool template output files that were not found.
Return type:tuple
Raises:OSError – If creating a directory fails.
make_work_output_dirs(self)[source]

Makes sure that work directory has the necessary output directories for Tool output files. Checks only “outputfiles” list. Alternatively you can add directories to “inputfiles” list in the tool definition file.

Returns:True for success, False otherwise.
Return type:bool
Raises:OSError – If creating an output directory to work fails.