pyworkflow.protocol.protocol module
This modules contains classes required for the workflow execution and tracking like: Step and Protocol
- class pyworkflow.protocol.protocol.FunctionStep(func=None, funcName=None, *funcArgs, wait=False, interactive=False, needsGPU=True)[source]
Bases:
Step
This is a Step wrapper around a normal function This class will ease the insertion of Protocol function steps through the function _insertFunctionStep
- class pyworkflow.protocol.protocol.LegacyProtocol(**kwargs)[source]
Bases:
Protocol
Special subclass of Protocol to be used when a protocol class is not found. It means that have been removed or it is in another development branch. In such, we will use the LegacyProtocol to simply store the parameters and inputs/outputs.
- class pyworkflow.protocol.protocol.ProtImportBase(**kwargs)[source]
Bases:
Protocol
Base Import protocol
- class pyworkflow.protocol.protocol.ProtStreamingBase(**kwargs)[source]
Bases:
Protocol
Base protocol to implement streaming protocols. stepsGeneratorStep should be implemented (see its description) and output should be created at the end of the processing Steps created by the stepsGeneratorStep. To avoid concurrency error, when creating the output, do it in a with self._lock: block. Minimum number of threads is 3 and should run in parallel mode.
- resumableStepGeneratorStep(ts)[source]
This allow to resume protocols. ts is the time stamp so this stap is alway different form previous exceution
- stepsExecutionMode = 1
- class pyworkflow.protocol.protocol.Protocol(**kwargs)[source]
Bases:
Step
The Protocol is a higher type of Step. It also have the inputs, outputs and other Steps properties, but contains a list of steps that are executed
- addSummaryWarning(warningDescription)[source]
Appends the warningDescription param to the list of summaryWarnings. Will be printed in the protocol summary.
- checkSummaryWarnings()[source]
Checks for warnings that we want to tell the user about by adding a warning sign to the run box and a description to the run summary. List of warnings checked: 1. If the folder for this protocol run exists.
- continueFromInteractive()[source]
TODO: REMOVE this function. Check if there is an interactive step and set as finished, this is used now mainly in picking, but we should remove this since is weird for users.
- copy(other, copyId=True, excludeInputs=False)[source]
Copies its attributes into the passed protocol
- Parameters
other – protocol instance to copt the attributes to
copyId – True (default) copies the identifier
excludeInputs – False (default). If true input attributes are excluded
- property cpuTime
Return the sum of all durations of the finished steps
- evalExpertLevel(paramName)[source]
Return the expert level evaluation for a param with the given name.
- evalParamCondition(paramName)[source]
Eval if the condition of paramName in _definition is satisfied with the current values of the protocol attributes.
- evalParamExpertLevel(param)[source]
Return True if the param has an expert level is less than the one for the whole protocol.
- classmethod getClassLabel(prependPackageName=True)[source]
Return a more readable string representing the protocol class
- classmethod getClassPackage()[source]
Return the package module to which this protocol belongs. This function will only work, if for the given Domain, the method Domain.getProtocols() has been called once. After calling this method the protocol classes are registered with it Plugin and Domain info.
- getDefinitionDict()[source]
Similar to getObjDict, but only for those params that are in the form. This function is used for export protocols as json text file.
- getEnumText(paramName)[source]
This function will retrieve the text value of an enum parameter in the definition, taking the actual value in the protocol.
- Parameters
paramName – the name of the enum param.
- Returns
the string value corresponding to the enum choice.
- getHostName()[source]
Get the execution host name. This value is only the key of the host in the configuration file.
- getInputStatus()[source]
Returns if any input pointer is not ready yet and if there is any pointer to an open set
- getLogsLastLines(lastLines=None, logFile=0)[source]
Get the last(lastLines) lines of a log file.
:param lastLines, if None, will try ‘PROT_LOGS_LAST_LINES’ env variable, otherwise 20 :param logFile: Log file to take the lines from, default = 0 (std.out). 1 for stdErr.
- getOutputFiles()[source]
Return the output files produced by this protocol. This can be used in web to download results back.
- getOutputSuffix(outputPrefix)[source]
Return the suffix to be used for a new output. For example: output3DCoordinates7. It should take into account previous outputs and number with a higher value.
- getProtocolsToUpdate()[source]
This function returns a list of protocols ids that need to update their database to launch this protocol (this method is only used when a WORKFLOW is restarted or continued). Actions done here are:
- Iterate over the main input Pointer of this protocol
(here, 3 different cases are analyzed):
A #. When the pointer points to a protocol
- B #. When the pointer points to another object (INDIRECTLY).
The pointer has an _extended value (new parameters configuration in the protocol)
C #. When the pointer points to another object (DIRECTLY).
The pointer has not an _extended value (old parameters configuration in the protocol)
- The PROTOCOL to which the pointer points is determined and saved in
the list
If this pointer points to a set (case B and C):
Iterate over the main attributes of the set - if attribute is a pointer then we add the pointed protocol to the ids list
- getStepsGraph(refresh=True)[source]
Build a graph taking into account the dependencies between steps. In streaming we might find first the createOutputStep (e.g 24) depending on 25
- getSubmitDict()[source]
Return a dictionary with the necessary keys to launch the job to a queue system.
- static hasDefinition(cls)[source]
Check if the protocol has some definition. This can help to detect “abstract” protocol that only serve as base for other, not to be instantiated.
- classmethod isBase()[source]
Return True if this Protocol is a base class. Base classes should be marked with _label = None.
- classmethod isDisabled()[source]
Return True if this Protocol is disabled. Disabled protocols will not be offered in the available protocols.
- iterInputAttributes()[source]
Iterate over the main input parameters of this protocol. Now the input are assumed to be these attribute which are pointers and have no condition.
- iterInputPointers()[source]
This function is similar to iterInputAttributes, but it yields all input Pointers, independently if they have value or not.
- iterOutputAttributes(outputClass=None, includePossible=False)[source]
Iterate over the outputs produced by this protocol.
- property numberOfSteps
- processImportDict(importDict, importDir)[source]
This function is used when we import a workflow from a json to process or adjust the json data for reproducibility purposes e.g. resolve relative paths Params: importDict: Dict of the protocol that we got from the json importDir: dir of the json we’re importing
- property stepsDone
Return the number of steps executed.
- stepsExecutionMode = 0
- updateSteps()[source]
After the steps list is modified, this methods will update steps information. It will save the steps list and also the number of steps.
- useQueueForProtocol()[source]
This function will return True if the protocol has been set to be launched through a queue
- useQueueForSteps()[source]
This function will return True if the protocol has been set to be launched through a queue by steps
- validate()[source]
Check that input parameters are correct. Return a list with errors, if the list is empty, all was ok.
- classmethod validateInstallation()[source]
Check if the installation of this protocol is correct. By default, we will check if the protocols’ package provide a validateInstallation function and use it. Returning an empty list means that the installation is correct and there are not errors. If some errors are found, a list with the error messages will be returned.
- classmethod validatePackageVersion(varName, errors)[source]
Function to validate the package version specified in configuration file ~/.config/scipion/scipion.conf is among the available options and it is properly installed.
- Parameters
package – the package object (ej: eman2 or relion). Package should contain the following methods: getVersion(), getSupportedVersions()
varName – the expected environment var containing the path (and version)
errors – list of strings to add errors if found
- class pyworkflow.protocol.protocol.RunJobStep(runJobFunc=None, programName=None, arguments=None, resultFiles=[], **kwargs)[source]
Bases:
FunctionStep
This Step will wrapper the commonly used function runJob for launching specific programs with some parameters. The runJob function should be provided by the protocol when inserting a new RunJobStep
- class pyworkflow.protocol.protocol.Step(interactive=False, needsGPU=True, **kwargs)[source]
Bases:
Object
Basic execution unit. It should define its Input, Output and define a run method.
- class pyworkflow.protocol.protocol.StepSet(filename=None, prefix='', mapperClass=None, **kwargs)[source]
Bases:
Set
Special type of Set for storing steps.
- pyworkflow.protocol.protocol.getProtocolFromDb(projectPath, protDbPath, protId, chdir=False)[source]
Retrieve the Protocol object from a given .sqlite file and the protocol id.
- pyworkflow.protocol.protocol.getUpdatedProtocol(protocol)[source]
Retrieve the updated protocol and close db connections
- pyworkflow.protocol.protocol.isProtocolUpToDate(protocol)[source]
Check timestamps between protocol lastModificationDate and the corresponding runs.db timestamp
- pyworkflow.protocol.protocol.runProtocolMain(projectPath, protDbPath, protId)[source]
Main entry point when a protocol will be executed. This function should be called when:
scipion runprotocol ...
- Parameters
projectPath – the absolute path to the project directory.
protDbPath – path to protocol db relative to projectPath
protId – id of the protocol object in db.