pyworkflow.project.project module
- class pyworkflow.project.project.Project(domain, path)[source]
Bases:
object
This class will handle all information related with a Project
Create a new Project instance. :param domain: The application domain from where to get objects and
protocols.
- Parameters
path – Path where the project will be created/loaded
- checkJobId(protocol)[source]
Check if a running protocol is still alive or not. The check will only be done for protocols that have been sent to a queue system.
- 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.
- static cleanProjectName(projectName)[source]
Cleans a project name to avoid common errors Use it whenever you want to get the final project name pyworkflow will end up. Spaces will be replaced by _
- 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, comment=None)[source]
Prepare all required paths and files to create a new project.
- Parameters
runsView – default view to associate the project with
readOnly – If True, project will be loaded as read only.
hostsConf – Path to the host.conf to be used when executing protocols
protocolsConf – Not used.
- 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 method is very similar to copyProtocol
- Parameters
protocols – a list of protocols to export.
filename – the filename where to write the workflow.
- 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
- getLocalConfigHosts()[source]
Return the local file where the project will try to read the hosts configuration.
- getProtocol(protId, fromRuns=False)[source]
Returns the protocol with the id=protId or raises an Exception
- Parameters
protId – integer with an existing protocol identifier
fromRuns – If true, it tries to get it from the runs list (memory) avoiding querying the db.
- getProtocolCompatibleOutputs(protocol, classes, condition)[source]
Getting the outputs compatible with an object type. The outputs of the child protocols are excluded.
- getProtocolFromRuns(protId)[source]
Returns the protocol with the id=protId from the runs list (memory) or None
- getProtocolsDict(protocols=None, namesOnly=False)[source]
Creates a dict with the information of the given protocols.
- Parameters
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
- Parameters
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.
- Parameters
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 pwobj.RELATION_TRANSFORM.
direction – Not used
refresh – If True, cached objects will be refreshed
- getRuns(iterate=False, refresh=True, checkPids=False)[source]
Return the existing protocol runs in the project.
- getRunsGraph(refresh=False, 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:
Store the protocol and assign name and working dir
Create the working dir and also the protocol independent db
- Call the launch method in protocol.job to handle submission:
mpi, thread, queue.
If the protocol has some prerequisites (other protocols that needs to be finished first), it will be scheduled.
- Parameters
protocol – Protocol instance to launch
wait – Optional. If true, this method will wait until execution is finished. Used in tests.
scheduled – Optional. If true, run.db and paths already exist and are preserved.
force – Optional. If true, launch is forced, regardless latter dependent executions. Used when restarting many protocols a once.
- launchWorkflow(workflowProtocolList, mode=0)[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:
Check if the workflow has active protocols.
Fix the workflow if is not properly configured
- Restart or Continue a workflow starting from the protocol depending
on the ‘mode’ value
- load(dbPath=None, hostsConf=None, protocolsConf=None, chdir=True, loadAllConfig=True)[source]
Load project data, configuration and settings.
- Parameters
dbPath – the path to the project database. If None, use the project.sqlite in the project folder.
hostsConf – where to read the host configuration. If None, check if exists in .config/hosts.conf or read from ~/.config/scipion/hosts.conf
protocolsConf – Not used
chdir – If True, os.cwd will be set to project’s path.
loadAllConfig – If True, settings from settings.sqlite will also be loaded
- loadProtocols(filename=None, jsonStr=None)[source]
Load protocols generated in the same format as self.exportProtocols.
- Parameters
filename – the path of the file where to read the workflow.
jsonStr –
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.
- resetWorkFlow(workflowProtocolList)[source]
This function can reset a workflow from a selected protocol :param initialProtocol: selected protocol
- scheduleProtocol(protocol, prerequisites=[], initialSleepTime=0)[source]
Schedule a new protocol that will run when the input data is available and the prerequisites are finished.
- Parameters
protocol – the protocol that will be scheduled.
prerequisites – a list with protocols ids that the scheduled protocol will wait for.
initialSleepTime – number of seconds to wait before checking input’s availability