scipion-pyworkflow 3.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. pyworkflow/__init__.py +33 -0
  2. pyworkflow/apps/__init__.py +29 -0
  3. pyworkflow/apps/pw_manager.py +37 -0
  4. pyworkflow/apps/pw_plot.py +51 -0
  5. pyworkflow/apps/pw_project.py +113 -0
  6. pyworkflow/apps/pw_protocol_list.py +143 -0
  7. pyworkflow/apps/pw_protocol_run.py +51 -0
  8. pyworkflow/apps/pw_run_tests.py +267 -0
  9. pyworkflow/apps/pw_schedule_run.py +322 -0
  10. pyworkflow/apps/pw_sleep.py +37 -0
  11. pyworkflow/apps/pw_sync_data.py +439 -0
  12. pyworkflow/apps/pw_viewer.py +78 -0
  13. pyworkflow/config.py +536 -0
  14. pyworkflow/constants.py +212 -0
  15. pyworkflow/exceptions.py +18 -0
  16. pyworkflow/gui/__init__.py +36 -0
  17. pyworkflow/gui/browser.py +726 -0
  18. pyworkflow/gui/canvas.py +1190 -0
  19. pyworkflow/gui/dialog.py +976 -0
  20. pyworkflow/gui/form.py +2627 -0
  21. pyworkflow/gui/graph.py +247 -0
  22. pyworkflow/gui/graph_layout.py +271 -0
  23. pyworkflow/gui/gui.py +566 -0
  24. pyworkflow/gui/matplotlib_image.py +233 -0
  25. pyworkflow/gui/plotter.py +247 -0
  26. pyworkflow/gui/project/__init__.py +25 -0
  27. pyworkflow/gui/project/base.py +192 -0
  28. pyworkflow/gui/project/constants.py +139 -0
  29. pyworkflow/gui/project/labels.py +205 -0
  30. pyworkflow/gui/project/project.py +484 -0
  31. pyworkflow/gui/project/searchprotocol.py +154 -0
  32. pyworkflow/gui/project/searchrun.py +181 -0
  33. pyworkflow/gui/project/steps.py +166 -0
  34. pyworkflow/gui/project/utils.py +332 -0
  35. pyworkflow/gui/project/variables.py +179 -0
  36. pyworkflow/gui/project/viewdata.py +472 -0
  37. pyworkflow/gui/project/viewprojects.py +510 -0
  38. pyworkflow/gui/project/viewprotocols.py +2093 -0
  39. pyworkflow/gui/project/viewprotocols_extra.py +560 -0
  40. pyworkflow/gui/text.py +771 -0
  41. pyworkflow/gui/tooltip.py +185 -0
  42. pyworkflow/gui/tree.py +684 -0
  43. pyworkflow/gui/widgets.py +307 -0
  44. pyworkflow/mapper/__init__.py +26 -0
  45. pyworkflow/mapper/mapper.py +222 -0
  46. pyworkflow/mapper/sqlite.py +1578 -0
  47. pyworkflow/mapper/sqlite_db.py +145 -0
  48. pyworkflow/object.py +1512 -0
  49. pyworkflow/plugin.py +712 -0
  50. pyworkflow/project/__init__.py +31 -0
  51. pyworkflow/project/config.py +451 -0
  52. pyworkflow/project/manager.py +179 -0
  53. pyworkflow/project/project.py +1990 -0
  54. pyworkflow/project/scripts/clean_projects.py +77 -0
  55. pyworkflow/project/scripts/config.py +92 -0
  56. pyworkflow/project/scripts/create.py +77 -0
  57. pyworkflow/project/scripts/edit_workflow.py +90 -0
  58. pyworkflow/project/scripts/fix_links.py +39 -0
  59. pyworkflow/project/scripts/load.py +87 -0
  60. pyworkflow/project/scripts/refresh.py +83 -0
  61. pyworkflow/project/scripts/schedule.py +111 -0
  62. pyworkflow/project/scripts/stack2volume.py +41 -0
  63. pyworkflow/project/scripts/stop.py +81 -0
  64. pyworkflow/protocol/__init__.py +38 -0
  65. pyworkflow/protocol/bibtex.py +48 -0
  66. pyworkflow/protocol/constants.py +86 -0
  67. pyworkflow/protocol/executor.py +334 -0
  68. pyworkflow/protocol/hosts.py +313 -0
  69. pyworkflow/protocol/launch.py +270 -0
  70. pyworkflow/protocol/package.py +42 -0
  71. pyworkflow/protocol/params.py +744 -0
  72. pyworkflow/protocol/protocol.py +2554 -0
  73. pyworkflow/resources/Imagej.png +0 -0
  74. pyworkflow/resources/chimera.png +0 -0
  75. pyworkflow/resources/fa-exclamation-triangle_alert.png +0 -0
  76. pyworkflow/resources/fa-info-circle_alert.png +0 -0
  77. pyworkflow/resources/fa-search.png +0 -0
  78. pyworkflow/resources/fa-times-circle_alert.png +0 -0
  79. pyworkflow/resources/file_vol.png +0 -0
  80. pyworkflow/resources/loading.gif +0 -0
  81. pyworkflow/resources/no-image128.png +0 -0
  82. pyworkflow/resources/scipion_bn.png +0 -0
  83. pyworkflow/resources/scipion_icon.png +0 -0
  84. pyworkflow/resources/scipion_icon.svg +397 -0
  85. pyworkflow/resources/scipion_icon_proj.png +0 -0
  86. pyworkflow/resources/scipion_icon_projs.png +0 -0
  87. pyworkflow/resources/scipion_icon_prot.png +0 -0
  88. pyworkflow/resources/scipion_logo.png +0 -0
  89. pyworkflow/resources/scipion_logo_normal.png +0 -0
  90. pyworkflow/resources/scipion_logo_small.png +0 -0
  91. pyworkflow/resources/sprites.png +0 -0
  92. pyworkflow/resources/sprites.xcf +0 -0
  93. pyworkflow/resources/wait.gif +0 -0
  94. pyworkflow/template.py +322 -0
  95. pyworkflow/tests/__init__.py +29 -0
  96. pyworkflow/tests/test_utils.py +25 -0
  97. pyworkflow/tests/tests.py +341 -0
  98. pyworkflow/utils/__init__.py +38 -0
  99. pyworkflow/utils/dataset.py +414 -0
  100. pyworkflow/utils/echo.py +104 -0
  101. pyworkflow/utils/graph.py +196 -0
  102. pyworkflow/utils/log.py +284 -0
  103. pyworkflow/utils/path.py +527 -0
  104. pyworkflow/utils/process.py +132 -0
  105. pyworkflow/utils/profiler.py +92 -0
  106. pyworkflow/utils/progressbar.py +154 -0
  107. pyworkflow/utils/properties.py +627 -0
  108. pyworkflow/utils/reflection.py +129 -0
  109. pyworkflow/utils/utils.py +877 -0
  110. pyworkflow/utils/which.py +229 -0
  111. pyworkflow/viewer.py +328 -0
  112. pyworkflow/webservices/__init__.py +8 -0
  113. pyworkflow/webservices/config.py +11 -0
  114. pyworkflow/webservices/notifier.py +162 -0
  115. pyworkflow/webservices/repository.py +59 -0
  116. pyworkflow/webservices/workflowhub.py +74 -0
  117. pyworkflow/wizard.py +64 -0
  118. pyworkflowtests/__init__.py +51 -0
  119. pyworkflowtests/bibtex.py +51 -0
  120. pyworkflowtests/objects.py +830 -0
  121. pyworkflowtests/protocols.py +154 -0
  122. pyworkflowtests/tests/__init__.py +0 -0
  123. pyworkflowtests/tests/test_canvas.py +72 -0
  124. pyworkflowtests/tests/test_domain.py +45 -0
  125. pyworkflowtests/tests/test_logs.py +74 -0
  126. pyworkflowtests/tests/test_mappers.py +392 -0
  127. pyworkflowtests/tests/test_object.py +507 -0
  128. pyworkflowtests/tests/test_project.py +42 -0
  129. pyworkflowtests/tests/test_protocol_execution.py +72 -0
  130. pyworkflowtests/tests/test_protocol_export.py +78 -0
  131. pyworkflowtests/tests/test_protocol_output.py +158 -0
  132. pyworkflowtests/tests/test_streaming.py +47 -0
  133. pyworkflowtests/tests/test_utils.py +210 -0
  134. scipion_pyworkflow-3.7.0.dist-info/LICENSE.txt +674 -0
  135. scipion_pyworkflow-3.7.0.dist-info/METADATA +107 -0
  136. scipion_pyworkflow-3.7.0.dist-info/RECORD +140 -0
  137. scipion_pyworkflow-3.7.0.dist-info/WHEEL +5 -0
  138. scipion_pyworkflow-3.7.0.dist-info/dependency_links.txt +1 -0
  139. scipion_pyworkflow-3.7.0.dist-info/entry_points.txt +5 -0
  140. scipion_pyworkflow-3.7.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env python
2
+ # **************************************************************************
3
+ # *
4
+ # * Authors: J.M. De la Rosa Trevin (jmdelarosa@cnb.csic.es)
5
+ # *
6
+ # * Unidad de Bioinformatica of Centro Nacional de Biotecnologia, CSIC
7
+ # *
8
+ # * This program is free software; you can redistribute it and/or modify
9
+ # * it under the terms of the GNU General Public License as published by
10
+ # * the Free Software Foundation; either version 3 of the License, or
11
+ # * (at your option) any later version.
12
+ # *
13
+ # * This program is distributed in the hope that it will be useful,
14
+ # * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # * GNU General Public License for more details.
17
+ # *
18
+ # * You should have received a copy of the GNU General Public License
19
+ # * along with this program; if not, write to the Free Software
20
+ # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21
+ # * 02111-1307 USA
22
+ # *
23
+ # * All comments concerning this program package may be sent to the
24
+ # * e-mail address 'scipion@cnb.csic.es'
25
+ # *
26
+ # **************************************************************************
27
+
28
+ import sys
29
+
30
+ import pyworkflow as pw
31
+ from pyworkflow.project import Manager
32
+
33
+
34
+ def usage(error):
35
+ print("""
36
+ ERROR: %s
37
+
38
+ Usage: scipion python -m pyworkflow.project.scripts.clean_projects [SCIPION_USER_DATA] [--delete]
39
+ Clean projects that have expired (now - creation time > life time)
40
+ Optional to pass SCIPION_USER_DATA folder from which to read 'projects'.
41
+ If --delete is not passed, only a message with the projects to be deleted
42
+ will be shown. If used --delete, the projects will be deleted from filesystem.
43
+ """ % error)
44
+ sys.exit(1)
45
+
46
+
47
+ n = len(sys.argv)
48
+
49
+ if n > 3:
50
+ usage("Incorrect number of input parameters")
51
+
52
+ delete = '--delete' in sys.argv
53
+
54
+ arg1 = sys.argv[1]
55
+ if n > 1 and arg1 != '--delete':
56
+ customUserData = arg1
57
+ else:
58
+ customUserData = pw.Config.SCIPION_USER_DATA
59
+
60
+ print("Loading projects from:\n %s" % customUserData)
61
+
62
+ # Create a new project
63
+ manager = Manager(workspace=customUserData)
64
+
65
+ for projInfo in manager.listProjects():
66
+ projName = projInfo.getName()
67
+ proj = manager.loadProject(projName)
68
+ settings = proj.getSettings()
69
+
70
+ leftTime = proj.getLeftTime()
71
+ if (leftTime is not None and
72
+ leftTime.days < 0):
73
+ if delete:
74
+ print("Deleting: %s (%s) " % (projName, leftTime))
75
+ manager.deleteProject(projName)
76
+ else:
77
+ print("Should delete: %s (%s)" % (projName, leftTime))
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env python
2
+ # **************************************************************************
3
+ # *
4
+ # * Authors: J.M. De la Rosa Trevin (jmdelarosa@cnb.csic.es)
5
+ # *
6
+ # * Unidad de Bioinformatica of Centro Nacional de Biotecnologia, CSIC
7
+ # *
8
+ # * This program is free software; you can redistribute it and/or modify
9
+ # * it under the terms of the GNU General Public License as published by
10
+ # * the Free Software Foundation; either version 3 of the License, or
11
+ # * (at your option) any later version.
12
+ # *
13
+ # * This program is distributed in the hope that it will be useful,
14
+ # * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # * GNU General Public License for more details.
17
+ # *
18
+ # * You should have received a copy of the GNU General Public License
19
+ # * along with this program; if not, write to the Free Software
20
+ # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21
+ # * 02111-1307 USA
22
+ # *
23
+ # * All comments concerning this program package may be sent to the
24
+ # * e-mail address 'scipion@cnb.csic.es'
25
+ # *
26
+ # **************************************************************************
27
+
28
+
29
+ import sys
30
+ import os
31
+
32
+ import pyworkflow as pw
33
+ from pyworkflow.project import Manager
34
+ from pyworkflow.object import Boolean
35
+
36
+
37
+ def usage(error):
38
+ print("""
39
+ ERROR: %s
40
+
41
+ Usage: scipion python -m pyworkflow.project.scripts.config ProjectName [readOnly=True|False] [lifeTime=X|None]
42
+ This script shows (or edits) some of the configuration of the project.
43
+ Use readOnly=True (or False) to set/unset read-only property.
44
+ Use lifeTime=X for setting X hours or None to unset lifetime of the project.
45
+ """ % error)
46
+ sys.exit(1)
47
+
48
+
49
+ n = len(sys.argv)
50
+
51
+ if n < 2 or n > 4:
52
+ usage("Incorrect number of input parameters")
53
+
54
+ # Load the given project
55
+ projectsDir = os.path.join(pw.Config.SCIPION_USER_DATA, 'projects')
56
+ projName = sys.argv[1]
57
+ manager = Manager()
58
+ project = manager.loadProject(projName)
59
+
60
+ if project is None:
61
+ usage("Project '%s' does not exist in: \n %s" % (projName, projectsDir))
62
+
63
+ setReadOnly = False
64
+ setLifeTime = False
65
+
66
+ for arg in sys.argv:
67
+ if arg.startswith('readOnly='):
68
+ setReadOnly = True
69
+ value = arg.split('readOnly=')[1]
70
+ b = Boolean(value=value)
71
+ readOnlyValue = b.get()
72
+ elif arg.startswith('lifeTime='):
73
+ setLifeTime = True
74
+ value = arg.split('lifeTime=')[1]
75
+ lifeTimeValue = None if value == 'None' else int(value)
76
+
77
+ if setReadOnly:
78
+ project.setReadOnly(readOnlyValue)
79
+
80
+ if setLifeTime:
81
+ project.settings.setLifeTime(lifeTimeValue)
82
+
83
+ if setReadOnly or setLifeTime:
84
+ # Truly write settings
85
+ project.settings.write()
86
+
87
+ print("Projects: ", projectsDir)
88
+ print("Project name: ", projName)
89
+ print(" Settings: ")
90
+ print(" readOnly = %s" % project.isReadOnly())
91
+ print(" lifeTime = %s (hours)" % project.settings.getLifeTime())
92
+
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env python
2
+ # **************************************************************************
3
+ # *
4
+ # * Authors: Pablo Conesa (pconesa@cnb.csic.es)
5
+ # *
6
+ # * Unidad de Bioinformatica of Centro Nacional de Biotecnologia, CSIC
7
+ # *
8
+ # * This program is free software; you can redistribute it and/or modify
9
+ # * it under the terms of the GNU General Public License as published by
10
+ # * the Free Software Foundation; either version 3 of the License, or
11
+ # * (at your option) any later version.
12
+ # *
13
+ # * This program is distributed in the hope that it will be useful,
14
+ # * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # * GNU General Public License for more details.
17
+ # *
18
+ # * You should have received a copy of the GNU General Public License
19
+ # * along with this program; if not, write to the Free Software
20
+ # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21
+ # * 02111-1307 USA
22
+ # *
23
+ # * All comments concerning this program package may be sent to the
24
+ # * e-mail address 'scipion@cnb.csic.es'
25
+ # *
26
+ # **************************************************************************
27
+
28
+ import sys
29
+ import os
30
+
31
+ from pyworkflow.project import Manager
32
+ import pyworkflow.utils as pwutils
33
+
34
+
35
+ def usage(error):
36
+ print("""
37
+ ERROR: %s
38
+
39
+ Usage: scipion python -m pyworkflow.project.scripts.create NAME [WORKFLOW] [LOCATION]
40
+ NAME: project name
41
+ WORKFLOW: path to a Scipion json workflow
42
+ LOCATION: where to create it, defaults to scipion default location
43
+
44
+ This script will create a project project, optionally based on a workflow file
45
+ """ % error)
46
+ sys.exit(1)
47
+
48
+
49
+ n = len(sys.argv)
50
+
51
+ if n < 2 or n > 4:
52
+ usage("Incorrect number of input parameters")
53
+
54
+ projName = sys.argv[1]
55
+
56
+ jsonFile = None if n < 3 else os.path.abspath(sys.argv[2])
57
+ location = None if n < 4 else sys.argv[3]
58
+
59
+ # This might not be working anymore for python3.
60
+ # I'm getting invalid ELF header triggered by matplotlib -->from . import _tkagg
61
+ # path = pw.join('gui', 'no-tkinter')
62
+ # sys.path.insert(1, path)
63
+
64
+ # Create a new project
65
+ manager = Manager()
66
+
67
+ if manager.hasProject(projName):
68
+ usage("There is already a project with this name: %s"
69
+ % pwutils.red(projName))
70
+
71
+ if jsonFile is not None and not os.path.exists(jsonFile):
72
+ usage("Nonexistent json file: %s" % pwutils.red(jsonFile))
73
+
74
+ project = manager.createProject(projName, location=location)
75
+
76
+ if jsonFile is not None:
77
+ protDict = project.loadProtocols(jsonFile)
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env python
2
+ # **************************************************************************
3
+ # *
4
+ # * Authors: J.M. De la Rosa Trevin (delarosatrevin@scilifelab.se) [1]
5
+ # *
6
+ # * [1] SciLifeLab, Stockholm University
7
+ # *
8
+ # * This program is free software; you can redistribute it and/or modify
9
+ # * it under the terms of the GNU General Public License as published by
10
+ # * the Free Software Foundation; either version 3 of the License, or
11
+ # * (at your option) any later version.
12
+ # *
13
+ # * This program is distributed in the hope that it will be useful,
14
+ # * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # * GNU General Public License for more details.
17
+ # *
18
+ # * You should have received a copy of the GNU General Public License
19
+ # * along with this program; if not, write to the Free Software
20
+ # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21
+ # * 02111-1307 USA
22
+ # *
23
+ # * All comments concerning this program package may be sent to the
24
+ # * e-mail address 'scipion@cnb.csic.es'
25
+ # *
26
+ # **************************************************************************
27
+
28
+
29
+ import sys
30
+ import os
31
+ from datetime import datetime
32
+
33
+ import pyworkflow as pw
34
+ import pyworkflow.utils as pwutils
35
+ from pyworkflow.project import Manager
36
+ from pyworkflow.gui.project import ProjectWindow
37
+
38
+
39
+ def usage(error):
40
+ print("""
41
+ ERROR: %s
42
+
43
+ Usage: scipion python -m pyworkflow.project.scripts.edit_workflow workflow.json
44
+ Edit the provide json file with scipion workflow.
45
+ It will create a project, import the workflow and save
46
+ the workflow back before closing the project.
47
+ After that, the project will be deleted.
48
+ """ % error)
49
+ sys.exit(1)
50
+
51
+
52
+ n = len(sys.argv)
53
+
54
+ if n < 2 or n > 3:
55
+ usage("Incorrect number of input parameters")
56
+
57
+ jsonFn = os.path.abspath(sys.argv[1])
58
+
59
+ now = datetime.now()
60
+ tempSpace = "editor-%s" % now.strftime('%Y%m%d-%H%M%S')
61
+ customUserData = os.path.join(pw.Config.SCIPION_USER_DATA, 'tmp', tempSpace)
62
+
63
+ pwutils.makePath(os.path.join(customUserData, 'projects'))
64
+
65
+ print("Loading projects from:\n", customUserData)
66
+
67
+ # Create a new project
68
+ manager = Manager(workspace=customUserData)
69
+
70
+ projName = os.path.basename(jsonFn)
71
+ proj = manager.createProject(projName)
72
+ projPath = manager.getProjectPath(proj.getShortName())
73
+ proj.loadProtocols(jsonFn)
74
+
75
+
76
+ class EditorProjectWindow(ProjectWindow):
77
+ def close(self, e=None):
78
+ try:
79
+ print("Writing protocols to: ", jsonFn)
80
+ proj.getRunsGraph(refresh=True) # Build project runs graph
81
+ proj.exportProtocols(proj.getRuns(), jsonFn)
82
+ print("Deleting temporary folder: ", customUserData)
83
+ pwutils.cleanPath(customUserData)
84
+ except Exception as ex:
85
+ print("Error saving the workflow: ", ex)
86
+ ProjectWindow.close(self, e)
87
+
88
+
89
+ projWindow = EditorProjectWindow(projPath)
90
+ projWindow.show()
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env python
2
+
3
+ import sys
4
+ import os
5
+ import logging
6
+ logging.basicConfig(level="INFO")
7
+
8
+ from pyworkflow.project import Manager
9
+ import pyworkflow.utils as pwutils
10
+
11
+
12
+ def usage(error):
13
+ print("""
14
+ ERROR: %s
15
+
16
+ Usage: scipion python -m pyworkflow.project.scripts.fix_links PROJECT SEARCH_DIR
17
+ PROJECT: provide the project name to fix broken links in the imports
18
+ SEARCH_DIR: provide a directory where to look for the files and fix the links
19
+ """ % error)
20
+ sys.exit(1)
21
+
22
+
23
+ if len(sys.argv) != 3:
24
+ usage("Incorrect number of input parameters")
25
+
26
+ projName = sys.argv[1]
27
+ searchDir = os.path.abspath(sys.argv[2])
28
+
29
+ # Create a new project
30
+ manager = Manager()
31
+
32
+ if not manager.hasProject(projName):
33
+ usage("Nonexistent project: %s" % pwutils.red(projName))
34
+
35
+ if not os.path.exists(searchDir):
36
+ usage("Nonexistent SEARCH_DIR: %s" % pwutils.red(searchDir))
37
+
38
+ project = manager.loadProject(projName)
39
+ project.fixLinks(searchDir)
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env python
2
+ # **************************************************************************
3
+ # *
4
+ # * Authors: J.M. De la Rosa Trevin (delarosatrevin@scilifelab.se) [1]
5
+ # *
6
+ # * [1] SciLifeLab, Stockholm University
7
+ # *
8
+ # * This program is free software; you can redistribute it and/or modify
9
+ # * it under the terms of the GNU General Public License as published by
10
+ # * the Free Software Foundation; either version 3 of the License, or
11
+ # * (at your option) any later version.
12
+ # *
13
+ # * This program is distributed in the hope that it will be useful,
14
+ # * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # * GNU General Public License for more details.
17
+ # *
18
+ # * You should have received a copy of the GNU General Public License
19
+ # * along with this program; if not, write to the Free Software
20
+ # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21
+ # * 02111-1307 USA
22
+ # *
23
+ # * All comments concerning this program package may be sent to the
24
+ # * e-mail address 'scipion@cnb.csic.es'
25
+ # *
26
+ # **************************************************************************
27
+
28
+
29
+ import sys
30
+ import os
31
+ from datetime import datetime
32
+
33
+ import pyworkflow as pw
34
+ import pyworkflow.utils as pwutils
35
+ from pyworkflow.project import Manager
36
+ from pyworkflow.gui.project import ProjectWindow
37
+
38
+
39
+ def usage(error):
40
+ print("""
41
+ ERROR: %s
42
+
43
+ Usage: scipion python -m pyworkflow.project.scripts.load /path/to/project
44
+ This script allows to quickly load a project folder without
45
+ importing that in the general user data folder
46
+ """ % error)
47
+ sys.exit(1)
48
+
49
+
50
+ n = len(sys.argv)
51
+
52
+ if n < 2 or n > 3:
53
+ usage("Incorrect number of input parameters")
54
+
55
+ pathToProj = os.path.abspath(sys.argv[1])
56
+
57
+ now = datetime.now()
58
+ tempSpace = "loading-%s" % now.strftime('%Y%m%d-%H%M%S')
59
+ customUserData = os.path.join(pw.Config.SCIPION_USER_DATA, 'tmp', tempSpace)
60
+
61
+ projectsDir = os.path.join(customUserData, 'projects')
62
+ pwutils.makePath(projectsDir)
63
+
64
+ print("Loading projects from:\n", projectsDir)
65
+
66
+ projName = os.path.basename(pathToProj)
67
+ pwutils.createAbsLink(pathToProj, os.path.join(projectsDir, projName))
68
+
69
+ # Create a new project
70
+ manager = Manager(workspace=customUserData)
71
+
72
+ proj = manager.loadProject(projName)
73
+ projPath = manager.getProjectPath(projName)
74
+
75
+
76
+ class EditorProjectWindow(ProjectWindow):
77
+ def close(self, e=None):
78
+ try:
79
+ print("Deleting temporary folder: ", customUserData)
80
+ pwutils.cleanPath(customUserData)
81
+ except Exception as ex:
82
+ print("Error: ", ex)
83
+ ProjectWindow.close(self, e)
84
+
85
+
86
+ projWindow = EditorProjectWindow(projPath)
87
+ projWindow.show()
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env python
2
+ # **************************************************************************
3
+ # *
4
+ # * Authors: Yaiza Rancel (yrancel@cnb.csic.es)
5
+ # *
6
+ # * Unidad de Bioinformatica of Centro Nacional de Biotecnologia, CSIC
7
+ # *
8
+ # * This program is free software; you can redistribute it and/or modify
9
+ # * it under the terms of the GNU General Public License as published by
10
+ # * the Free Software Foundation; either version 3 of the License, or
11
+ # * (at your option) any later version.
12
+ # *
13
+ # * This program is distributed in the hope that it will be useful,
14
+ # * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # * GNU General Public License for more details.
17
+ # *
18
+ # * You should have received a copy of the GNU General Public License
19
+ # * along with this program; if not, write to the Free Software
20
+ # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21
+ # * 02111-1307 USA
22
+ # *
23
+ # * All comments concerning this program package may be sent to the
24
+ # * e-mail address 'scipion@cnb.csic.es'
25
+ # *
26
+ # **************************************************************************
27
+
28
+ import sys
29
+ import os
30
+ from time import sleep
31
+
32
+ import pyworkflow as pw
33
+ from pyworkflow.project import Manager
34
+ from pyworkflow.project import Project
35
+ import pyworkflow.utils as pwutils
36
+
37
+
38
+ def usage(error):
39
+ print("""
40
+ ERROR: %s
41
+
42
+ Usage: scipion python -m pyworkflow.scripts.project.refresh project_name [refresh_period]
43
+ This script will refresh the project.sqlite file of the specified project.
44
+ We can specify how often it will refresh in seconds (defaults 60).
45
+ e.g.
46
+ scipion python -m pyworkflow.scripts.project.refresh TestExtractParticles 15
47
+ """ % error)
48
+ sys.exit(1)
49
+
50
+
51
+ n = len(sys.argv)
52
+
53
+ if n > 3:
54
+ usage("This script accepts 2 parameters: the project name (mandatory) and "
55
+ "the refresh period in seconds (optional).")
56
+
57
+ projName = sys.argv[1]
58
+ if n == 3:
59
+ wait = int(sys.argv[2])
60
+ else:
61
+ wait = 60
62
+
63
+ path = pw.join('gui', 'no-tkinter')
64
+ sys.path.insert(1, path)
65
+
66
+ # Create a new project
67
+ manager = Manager()
68
+
69
+ if not manager.hasProject(projName):
70
+ usage("There is no project with this name: %s"
71
+ % pwutils.red(projName))
72
+
73
+ # the project may be a soft link which may be unavailable to the cluster so get the real path
74
+ try:
75
+ projectPath = os.readlink(manager.getProjectPath(projName))
76
+ except:
77
+ projectPath = manager.getProjectPath(projName)
78
+
79
+ project = Project(pw.Config.getDomain(), projectPath)
80
+ project.load()
81
+ while True:
82
+ runs = project.getRuns()
83
+ sleep(wait)
@@ -0,0 +1,111 @@
1
+ # **************************************************************************
2
+ # *
3
+ # * Authors: Pablo Conesa (pconesa@cnb.csic.es)
4
+ # *
5
+ # * Unidad de Bioinformatica of Centro Nacional de Biotecnologia, CSIC
6
+ # *
7
+ # * This program is free software; you can redistribute it and/or modify
8
+ # * it under the terms of the GNU General Public License as published by
9
+ # * the Free Software Foundation; either version 3 of the License, or
10
+ # * (at your option) any later version.
11
+ # *
12
+ # * This program is distributed in the hope that it will be useful,
13
+ # * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # * GNU General Public License for more details.
16
+ # *
17
+ # * You should have received a copy of the GNU General Public License
18
+ # * along with this program; if not, write to the Free Software
19
+ # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20
+ # * 02111-1307 USA
21
+ # *
22
+ # * All comments concerning this program package may be sent to the
23
+ # * e-mail address 'scipion@cnb.csic.es'
24
+ # *
25
+ # **************************************************************************
26
+
27
+
28
+ import sys
29
+ import os
30
+ import time
31
+
32
+ import pyworkflow as pw
33
+ from pyworkflow.project import Manager
34
+ from pyworkflow.project import Project
35
+ import pyworkflow.utils as pwutils
36
+ from pyworkflow.protocol import INITIAL_SLEEP_TIME
37
+
38
+
39
+ def usage(error):
40
+ print("""
41
+ ERROR: %s
42
+
43
+ Usage: scipion python -m pyworkflow.project.scripts.schedule projectName
44
+
45
+ options: --ignore ProtClassName1 ProtClassName2 ProtClassLabel1 ...
46
+
47
+ This script will schedule all the protocols in a project. If '--ignore'
48
+ option is passed, it doesn't schedule those protocols that belongs to
49
+ ProtClassName1 or ProtClassName2 class, also those protocols with a
50
+ objLabel equals to ProtClassLabel1
51
+ """ % error)
52
+ sys.exit(1)
53
+
54
+
55
+ n = len(sys.argv)
56
+
57
+ if n < 2:
58
+ usage("This script accepts 1 mandatory parameter: the project name.")
59
+ elif n > 2 and sys.argv[2] != '--ignore':
60
+ usage("The protocol class names to be ignored must be after a '--ignore' flag.")
61
+
62
+ projName = sys.argv[1]
63
+
64
+ # This fails, since it is triggering matplotlib.pyplot and then import error happens:
65
+ # ... pyworkflow/gui/no-tkinter/_tkinter.py: invalid ELF header. If we want this back we might need to
66
+ # invest some time "faking" tkinter again for python3.
67
+ # path = pw.join('gui', 'no-tkinter')
68
+ # sys.path.insert(1, path)
69
+
70
+ # Create a new project
71
+ manager = Manager()
72
+
73
+ if not manager.hasProject(projName):
74
+ usage("There is no project with this name: %s"
75
+ % pwutils.red(projName))
76
+
77
+ # the project may be a soft link which may be unavailable to the cluster
78
+ # so get the real path
79
+
80
+ try:
81
+ projectPath = os.readlink(manager.getProjectPath(projName))
82
+ except:
83
+ projectPath = manager.getProjectPath(projName)
84
+
85
+ project = Project(pw.Config.getDomain(), projectPath)
86
+ project.load()
87
+
88
+ runGraph = project.getRunsGraph()
89
+ roots = runGraph.getRootNodes()
90
+
91
+ # Now assuming that there is no dependencies between runs
92
+ # and the graph is lineal
93
+
94
+ for root in roots:
95
+ for child in root.getChilds():
96
+ workflow, _ = project._getSubworkflow(child.run)
97
+ for prot, level in workflow.values():
98
+ protLabelName = prot.getObjLabel()
99
+ if prot.forceSchedule.get():
100
+ print(pwutils.blueStr("\nStopping scheduling at '%s'. Force scheduling found.\n"
101
+ % protLabelName))
102
+ sys.exit()
103
+
104
+ protClassName = prot.getClassName()
105
+ if (protClassName not in sys.argv[3:] and
106
+ protLabelName not in sys.argv[3:]):
107
+ project.scheduleProtocol(prot,
108
+ initialSleepTime=level*INITIAL_SLEEP_TIME)
109
+ else:
110
+ print(pwutils.blueStr("\nNot scheduling '%s' protocol named '%s'.\n"
111
+ % (protClassName, protLabelName)))
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env python
2
+
3
+
4
+ import sys
5
+ from glob import glob
6
+
7
+ from pwem.convert import Ccp4Header
8
+ import pyworkflow.utils as pwutils
9
+
10
+
11
+ def usage(error):
12
+ print("""
13
+ ERROR: %s
14
+
15
+ Usage: scipion python -m pyworkflow.project.scripts.stack2volume PATH
16
+ PATH: path to look for stack files
17
+ The script will swap the dimensions in the header of a stack to make them
18
+ volumes. Something like 10 x 1 x 10 x 10 will be changed to 1 x 10 x 10 x 10
19
+ """ % error)
20
+ sys.exit(1)
21
+
22
+
23
+ if len(sys.argv) != 2:
24
+ usage("Incorrect number of input parameters")
25
+
26
+ path = sys.argv[1]
27
+
28
+ print("Looking for files like: %s" % path)
29
+
30
+
31
+ for file in glob(path):
32
+
33
+ print("Changing header of %s" % file)
34
+ try:
35
+ header = Ccp4Header(file, readHeader=True)
36
+ # Flag it as volume.
37
+ header.setISPG(401)
38
+ header.writeHeader()
39
+
40
+ except Exception as e:
41
+ print(pwutils.red("Failed to change header: %s" % e))