pyworkflow.protocol.protocol module¶
-
class
pyworkflow.protocol.protocol.
FunctionStep
(func=None, funcName=None, *funcArgs, **kwargs)[source]¶ Bases:
pyworkflow.protocol.protocol.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:
pyworkflow.protocol.protocol.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.
Protocol
(**kwargs)[source]¶ Bases:
pyworkflow.protocol.protocol.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]¶ Copy all attributes values from one object to the other. The attributes will be created if needed with the corresponding type. Params:
other: the other object from which to make the copy. copyId: if true, the _objId will be also copied. ignoreAttrs: pass a list with attributes names to ignore.
-
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 satified 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
-
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. Params:
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.
-
getOutputFiles
()[source]¶ Return the output files produced by this protocol. This can be used in web to download or in remote executions to copy results back.
-
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.
-
hasLinkedInputs
()[source]¶ Return if True if some of the input pointers are referring to an output that is not ready yet.
-
inputProtocolDict
()[source]¶ This function returns a dictionary of protocols 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: 1. Iterate over the main input Pointer of this protocol
(here, 3 different cases are analyzed)
When the pointer points to a protocol
When the pointer points to another object (INDIRECTLY). - The pointer has an _extended value (new parameters configuration
in the protocol)
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 dictionary
If this pointer points to another object (case B and C): - Iterate over the main attributes of this pointer - if any attribute is a pointer, then we move to PROTOCOL and repeat
this procedure from step 1
-
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.
-
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
-
stepsDone
¶ Return the number of steps executed.
-
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.
-
useQueueForSteps
()[source]¶ This function will return True if the protocol has been set to be launched thorugh 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 the package version specified in configuration file ~/.config/scipion/scipion.conf is among the available options and it is properly installed. Params:
- 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 to added error if found
-
-
class
pyworkflow.protocol.protocol.
RunJobStep
(runJobFunc=None, programName=None, arguments=None, resultFiles=[], **kwargs)[source]¶ Bases:
pyworkflow.protocol.protocol.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
(**kwargs)[source]¶ Bases:
pyworkflow.object.OrderedObject
Basic execution unit. It should defines its Input, Output and define a run method.
-
class
pyworkflow.protocol.protocol.
StepSet
(filename=None, prefix='', mapperClass=None, **kwargs)[source]¶ Bases:
pyworkflow.object.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 … Params:
projectPath: the absolute path to the project directory. protDbPath: path to protocol db relative to projectPath protId: id of the protocol object in db.