pyworkflow.project.project module¶
-
class
pyworkflow.project.project.
Project
(path)[source]¶ Bases:
object
This class will handle all information related with a Project
-
checkPid
(protocol)[source]¶ Check if a running protocol is still alive or not. The check will only be done for protocols that have not been sent to a queue system.
-
continueProtocol
(protocol)[source]¶ This function should be called to mark a protocol that have an interactive step waiting for approval that can continue
-
copyProtocol
(protocol)[source]¶ Make a copy of the protocol, Return a new instance with copied values.
-
create
(runsView=1, readOnly=False, hostsConf=None, protocolsConf=None)[source]¶ Prepare all required paths and files to create a new project. Params:
- hosts: a list of configuration hosts associated to this projects
- (class ExecutionHostConfig)
-
createMapper
(sqliteFn)[source]¶ Create a new SqliteMapper object and pass as classes dict all globals and update with data and protocols from em.
-
deleteProtocolOutput
(protocol, output)[source]¶ Delete a given object from the project. Usually to clean up some outputs.
-
exportProtocols
(protocols, filename)[source]¶ Create a text json file with the info to import the workflow into another project. This methods is very similar to copyProtocol Params:
protocols: a list of protocols to export. filename: the filename where to write the workflow.
-
getCurrentProtocolView
()[source]¶ Select the view that is currently selected. Read from the settings the last selected view and get the information from the self._protocolViews dict.
-
getGraphFromRuns
(runs)[source]¶ - This function will build a dependencies graph from a set
- of given runs.
Parameters: runs – The input runs to build the graph Returns: The graph taking into account run dependencies
-
getProtocolsDict
(protocols=None, namesOnly=False)[source]¶ Create a dict with the information of the given protocols. Params:
protocols: list of protocols or None to include all. namesOnly: the output list will contain only the protocol names.
-
getProtocolsJson
(protocols=None, namesOnly=False)[source]¶ Wraps getProtocolsDict to get a json string Params:
protocols: list of protocols or None to include all. namesOnly: the output list will contain only the protocol names.
-
getRelatedObjects
(relation, obj, direction=0, refresh=False)[source]¶ Get all objects related to obj by a give relation. Params:
relation: the relation name to search for. obj: object from which the relation will be search,
actually not only this, but all other objects connected to this one by the RELATION_TRANSFORM.direction: this say if search for childs or parents in the relation.
-
getRuns
(iterate=False, refresh=True, checkPids=False)[source]¶ Return the existing protocol runs in the project.
-
getRunsGraph
(refresh=True, checkPids=False)[source]¶ Build a graph taking into account the dependencies between different runs, ie. which outputs serves as inputs of other protocols.
-
iterSubclasses
(classesName, objectFilter=None)[source]¶ - Retrieve all objects from the project that are instances
- of any of the classes in classesName list.
- Params:
- classesName: String with commas separated values of classes name. objectFilter: a filter function to discard some of the retrieved objects.
-
launchProtocol
(protocol, wait=False, scheduled=False, force=False)[source]¶ In this function the action of launching a protocol will be initiated. Actions done here are: 1. Store the protocol and assign name and working dir 2. Create the working dir and also the protocol independent db 3. Call the launch method in protocol.job to handle submission:
mpi, thread, queue,and also take care if the execution is remotely.
If the protocol has some prerequisited (other protocols that needs to be finished first), it will be scheduled.
-
launchWorkflow
(initialProtocol, mode=2)[source]¶ This function can launch a workflow from a selected protocol in two modes depending on the ‘mode’ value (RESTART, CONTINUE) Actions done here are: 1. Check if the workflow has active protocols. 2. Fix the workflow if is not properly configured 3. Restart or Continue a workflow starting from the protocol depending
of the ‘mode’ value
-
load
(dbPath=None, hostsConf=None, protocolsConf=None, chdir=True, loadAllConfig=True)[source]¶ Load project data, configuration and settings. Params:
- dbPath: the path to the project database.
- If None, use the project.sqlite in the project folder.
- hosts: where to read the host configuration.
- If None, check if exists in .config/hosts.conf or read from ~/.config/scipion/hosts.conf
- settings: where to read the settings.
- If None, use the settings.sqlite in project folder. If forProtocol is True, the settings and protocols.conf will not be loaded.
-
loadProtocols
(filename=None, jsonStr=None)[source]¶ Load protocols generated in the same format as self.exportProtocols. Params:
filename: the path of the file where to read the workflow. jsonStr: read the protocols from a string instead of file.Note: either filename or jsonStr should be not None.
-
needRefresh
()[source]¶ True if any run is active and its timestamp is older than its corresponding runs.db NOTE: If an external script changes the DB this will fail. It uses only in memory objects.
-
scheduleProtocol
(protocol, prerequisites=[])[source]¶ Schedule a new protocol that will run when the input data is available and the prerequisited finished. Params:
protocol: the protocol that will be scheduled. prerequisites: a list with protocols ids that the scheduled
protocol will wait for.
-