-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_workflow.py
55 lines (38 loc) · 1.51 KB
/
run_workflow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
"""
This script runs a workflow template automatically in an existing project.
TODO:
- Allow to create the project if not exists.
- Check the dependency graph between the runs.
"""
import sys, os
from pyworkflow.manager import Manager
import pyworkflow.utils as pwutils
def usage(error):
print """
ERROR: %s
Usage: scipion run scripts/run_workflows.py PROJECT JSON_FILE [ARGS]
PROJECT: provide the project name in which the workflow will be executed.
JSON_FILE: the json file containing the workflow template to be executed.
[ARGS]: specify some parameters to override the ones in the template.
To change protocol label (protocol id=1) label: 1.object.label="import from A"
To set param filePaths (protocol id=1): 1.filesPath="/path/to/files/"
""" % error
sys.exit(1)
if len(sys.argv) != 3:
usage("Incorrect number of input parameters")
projName = sys.argv[1]
jsonFile = os.path.abspath(sys.argv[2])
args = sys.argv[3:]
# Create a new project
manager = Manager()
if not manager.hasProject(projName):
usage("Unexistent project: %s" % pwutils.red(projName))
if not os.path.exists(jsonFile):
usage("Unexistent json file: %s" % pwutils.red(jsonFile))
project = manager.loadProject(projName)
protDict = project.loadProtocols(jsonFile)
# Now assuming that there is no dependencies between runs
# and the graph is lineal
for protId, prot in protDict.iteritems():
project.launchProtocol(prot, wait=True)