pyworkflow.project.project module

exception pyworkflow.project.project.MissingProjectDbException[source]

Bases: Exception

exception pyworkflow.project.project.ModificationNotAllowedException[source]

Bases: Exception

class pyworkflow.project.project.Project(domain, 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.

closeMapper()[source]
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.

createSettings(runsView=1, readOnly=False)[source]
deleteProtocol(*protocols)[source]
deleteProtocolOutput(protocol, output)[source]

Delete a given object from the project. Usually to clean up some outputs.

doesProtocolExists(protId)[source]
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.
getCreationTime()[source]

Return the time when the project was created.

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.

getDbLastModificationDate()[source]

Return the last modification date of the database

classmethod getDbName()[source]

Return the name of the database file of projects.

getDbPath()[source]

Return the path to the sqlite db.

getDomain()[source]
getElapsedTime()[source]

Returns the time elapsed from the creation to the last execution time.

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
getHostConfig(hostName)[source]
getHostNames()[source]

Return the list of host name in the project.

getLeftTime()[source]
getLocalConfigHosts()[source]

Return the local file where the project will try to read the hosts configuration.

getLogPath(*paths)[source]
getName()[source]
getObjId()[source]

Return the unique id assigned to this project.

getObject(objId)[source]

Retrieve an object from the db given its id.

getPath(*paths)[source]

Return path from the project root

getProtocol(protId)[source]
getProtocolViews()[source]
getProtocolsByClass(className)[source]
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 pwobj.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.

getSettings()[source]
getSettingsCreationTime()[source]
getShortName()[source]
getSourceChilds(obj)[source]

Return all the objects have used obj as a source.

getSourceGraph(refresh=False)[source]

Get the graph from the SOURCE relation.

getSourceParents(obj)[source]

Return all the objects that are SOURCE of this object.

getTmpPath(*paths)[source]
getTransformGraph(refresh=False)[source]

Get the graph from the TRASNFORM relation.

isInReadOnlyFolder()[source]

Returns if the project path is a link to another folder.

isReadOnly()[source]
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.

newProtocol(protocolClass, **kwargs)[source]

Create a new protocol from a given class.

openedAsReadOnly()[source]
resetProtocol(protocol)[source]

Stop a running protocol

resetWorkFlow(initialProtocol)[source]

This function can reset a workflow from a selected protocol :param initialProtocol: selected protocol

saveProtocol(protocol)[source]
saveSettings()[source]
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.
setDbPath(dbPath)[source]

Set the project db path. This function is used when running a protocol where a project is loaded but using the protocol own sqlite file.

setReadOnly(value)[source]
stopProtocol(protocol)[source]

Stop a running protocol

stopWorkFlow(initialProtocol)[source]

This function can stop a workflow from a selected protocol :param initialProtocol: selected protocol