project
¶
Spine Toolbox project class.
authors: |
|
---|---|
date: | 10.1.2018 |
Module Contents¶
-
class
project.
SpineToolboxProject
(toolbox, name, description, work_dir=None, ext='.proj')[source]¶ Bases:
metaobject.MetaObject
Class for Spine Toolbox projects.
-
name
¶ Project name
Type: str
-
description
¶ Project description
Type: str
-
work_dir
¶ Project work directory
Type: str
-
ext
¶ Project save file extension(.proj)
Type: str
-
change_name
(self, name)[source]¶ Changes project name and updates project dir and save file name.
Parameters: name (str) – Project (long) name
-
change_filename
(self, new_filename)[source]¶ Change the save filename associated with this project.
Parameters: new_filename (str) – Filename used in saving the project. No full path. Example ‘project.proj’
-
change_work_dir
(self, new_work_path)[source]¶ Change project work directory.
Parameters: new_work_path (str) – Absolute path to new work directory
-
rename_project
(self, name)[source]¶ Save project under a new name. Used with File->Save As… menu command. Checks if given project name is valid.
Parameters: name (str) – New (long) name for project
-
save
(self, tool_def_paths)[source]¶ Collect project information and objects into a dictionary and write to a JSON file.
Parameters: tool_def_paths (list) – List of paths to tool definition files
-
load
(self, item_dict)[source]¶ Populate project item model with items loaded from project file.
Parameters: item_dict (dict) – Dictionary containing all project items in JSON format Returns: Boolean value depending on operation success.
-
load_tool_template_from_file
(self, jsonfile)[source]¶ Create a Tool template according to a tool definition file.
Parameters: jsonfile (str) – Path of the tool template definition file Returns: Instance of a subclass if Tool
-
load_tool_template_from_dict
(self, definition, path)[source]¶ Create a Tool template according to a dictionary.
Parameters: - definition (dict) – Dictionary with the tool definition
- path (str) – Folder of the main program file
Returns: Instance of a subclass if Tool
-
add_data_store
(self, name, description, url, x=0, y=0, set_selected=False, verbosity=True)[source]¶ Adds a Data Store to project item model.
Parameters: - name (str) – Name
- description (str) – Description of item
- url (dict) – Url information
- x (int) – X coordinate of item on scene
- y (int) – Y coordinate of item on scene
- set_selected (bool) – Whether to set item selected after the item has been added to project
- verbosity (bool) – If True, prints message
-
add_data_connection
(self, name, description, references, x=0, y=0, set_selected=False, verbosity=True)[source]¶ Adds a Data Connection to project item model.
Parameters: - name (str) – Name
- description (str) – Description of item
- references (list(str)) – List of file paths
- x (int) – X coordinate of item on scene
- y (int) – Y coordinate of item on scene
- set_selected (bool) – Whether to set item selected after the item has been added to project
- verbosity (bool) – If True, prints message
-
add_tool
(self, name, description, tool_template, use_work=True, x=0, y=0, set_selected=False, verbosity=True)[source]¶ Adds a Tool to project item model.
Parameters: - name (str) – Name
- description (str) – Description of item
- tool_template (ToolTemplate) – Tool template of this tool
- use_work (bool) – Execute in work directory
- x (int) – X coordinate of item on scene
- y (int) – Y coordinate of item on scene
- set_selected (bool) – Whether to set item selected after the item has been added to project
- verbosity (bool) – If True, prints message
-
add_view
(self, name, description, x=0, y=0, set_selected=False, verbosity=True)[source]¶ Adds a View to project item model.
Parameters: - name (str) – Name
- description (str) – Description of item
- x (int) – X coordinate of item on scene
- y (int) – Y coordinate of item on scene
- set_selected (bool) – Whether to set item selected after the item has been added to project
- verbosity (bool) – If True, prints message
-
add_data_interface
(self, name, description, import_file_path='', mappings=None, x=0, y=0, set_selected=False, verbosity=True)[source]¶ Adds a Data Interface to project item model.
Parameters: - name (str) – Name
- description (str) – Description of item
- x (int) – X coordinate of item on scene
- y (int) – Y coordinate of item on scene
- set_selected (bool) – Whether to set item selected after the item has been added to project
- verbosity (bool) – If True, prints message
-
append_connection_model
(self, item_name, category)[source]¶ Adds new item to connection model to keep project and connection model synchronized.
-
set_item_selected
(self, item)[source]¶ Sets item selected and shows its info screen.
Parameters: item (ProjectItem) – Project item to select
-
execute_selected
(self)[source]¶ Starts executing selected directed acyclic graph. Selected graph is determined by the selected project item(s). Aborts, if items from multiple graphs are selected.
-
execute_project
(self)[source]¶ Determines the number of directed acyclic graphs to execute in the project. Determines the execution order of project items in each graph. Creates an instance for executing the first graph and starts executing it.
-
graph_execution_finished
(self, state)[source]¶ Releases resources from previous execution and prepares the next graph for execution if there are still graphs left. Otherwise, finishes the run.
Parameters: state (int) – 0: Ended normally. -1: User pressed Stop button
-
stop
(self)[source]¶ Stops execution of the current DAG. Slot for the main window Stop tool button in the toolbar.
-