scipion-pyworkflow 3.11.0__py3-none-any.whl → 3.11.1__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 (98) hide show
  1. pyworkflow/apps/__init__.py +29 -0
  2. pyworkflow/apps/pw_manager.py +37 -0
  3. pyworkflow/apps/pw_plot.py +51 -0
  4. pyworkflow/apps/pw_project.py +113 -0
  5. pyworkflow/apps/pw_protocol_list.py +143 -0
  6. pyworkflow/apps/pw_protocol_run.py +51 -0
  7. pyworkflow/apps/pw_run_tests.py +267 -0
  8. pyworkflow/apps/pw_schedule_run.py +322 -0
  9. pyworkflow/apps/pw_sleep.py +37 -0
  10. pyworkflow/apps/pw_sync_data.py +439 -0
  11. pyworkflow/apps/pw_viewer.py +78 -0
  12. pyworkflow/constants.py +1 -1
  13. pyworkflow/gui/__init__.py +36 -0
  14. pyworkflow/gui/browser.py +760 -0
  15. pyworkflow/gui/canvas.py +1190 -0
  16. pyworkflow/gui/dialog.py +979 -0
  17. pyworkflow/gui/form.py +2726 -0
  18. pyworkflow/gui/graph.py +247 -0
  19. pyworkflow/gui/graph_layout.py +271 -0
  20. pyworkflow/gui/gui.py +566 -0
  21. pyworkflow/gui/matplotlib_image.py +233 -0
  22. pyworkflow/gui/plotter.py +247 -0
  23. pyworkflow/gui/project/__init__.py +25 -0
  24. pyworkflow/gui/project/base.py +192 -0
  25. pyworkflow/gui/project/constants.py +139 -0
  26. pyworkflow/gui/project/labels.py +205 -0
  27. pyworkflow/gui/project/project.py +491 -0
  28. pyworkflow/gui/project/searchprotocol.py +238 -0
  29. pyworkflow/gui/project/searchrun.py +181 -0
  30. pyworkflow/gui/project/steps.py +171 -0
  31. pyworkflow/gui/project/utils.py +332 -0
  32. pyworkflow/gui/project/variables.py +179 -0
  33. pyworkflow/gui/project/viewdata.py +472 -0
  34. pyworkflow/gui/project/viewprojects.py +510 -0
  35. pyworkflow/gui/project/viewprotocols.py +2116 -0
  36. pyworkflow/gui/project/viewprotocols_extra.py +562 -0
  37. pyworkflow/gui/text.py +771 -0
  38. pyworkflow/gui/tooltip.py +185 -0
  39. pyworkflow/gui/tree.py +684 -0
  40. pyworkflow/gui/widgets.py +307 -0
  41. pyworkflow/mapper/__init__.py +26 -0
  42. pyworkflow/mapper/mapper.py +222 -0
  43. pyworkflow/mapper/sqlite.py +1581 -0
  44. pyworkflow/mapper/sqlite_db.py +145 -0
  45. pyworkflow/project/__init__.py +31 -0
  46. pyworkflow/project/config.py +454 -0
  47. pyworkflow/project/manager.py +180 -0
  48. pyworkflow/project/project.py +2095 -0
  49. pyworkflow/project/usage.py +165 -0
  50. pyworkflow/protocol/__init__.py +38 -0
  51. pyworkflow/protocol/bibtex.py +48 -0
  52. pyworkflow/protocol/constants.py +87 -0
  53. pyworkflow/protocol/executor.py +483 -0
  54. pyworkflow/protocol/hosts.py +317 -0
  55. pyworkflow/protocol/launch.py +277 -0
  56. pyworkflow/protocol/package.py +42 -0
  57. pyworkflow/protocol/params.py +781 -0
  58. pyworkflow/protocol/protocol.py +2707 -0
  59. pyworkflow/tests/__init__.py +29 -0
  60. pyworkflow/tests/test_utils.py +25 -0
  61. pyworkflow/tests/tests.py +341 -0
  62. pyworkflow/utils/__init__.py +38 -0
  63. pyworkflow/utils/dataset.py +414 -0
  64. pyworkflow/utils/echo.py +104 -0
  65. pyworkflow/utils/graph.py +169 -0
  66. pyworkflow/utils/log.py +293 -0
  67. pyworkflow/utils/path.py +528 -0
  68. pyworkflow/utils/process.py +153 -0
  69. pyworkflow/utils/profiler.py +92 -0
  70. pyworkflow/utils/progressbar.py +154 -0
  71. pyworkflow/utils/properties.py +617 -0
  72. pyworkflow/utils/reflection.py +129 -0
  73. pyworkflow/utils/utils.py +880 -0
  74. pyworkflow/utils/which.py +229 -0
  75. pyworkflow/webservices/__init__.py +8 -0
  76. pyworkflow/webservices/config.py +8 -0
  77. pyworkflow/webservices/notifier.py +152 -0
  78. pyworkflow/webservices/repository.py +59 -0
  79. pyworkflow/webservices/workflowhub.py +74 -0
  80. pyworkflowtests/tests/__init__.py +0 -0
  81. pyworkflowtests/tests/test_canvas.py +72 -0
  82. pyworkflowtests/tests/test_domain.py +45 -0
  83. pyworkflowtests/tests/test_logs.py +74 -0
  84. pyworkflowtests/tests/test_mappers.py +392 -0
  85. pyworkflowtests/tests/test_object.py +507 -0
  86. pyworkflowtests/tests/test_project.py +42 -0
  87. pyworkflowtests/tests/test_protocol_execution.py +146 -0
  88. pyworkflowtests/tests/test_protocol_export.py +78 -0
  89. pyworkflowtests/tests/test_protocol_output.py +158 -0
  90. pyworkflowtests/tests/test_streaming.py +47 -0
  91. pyworkflowtests/tests/test_utils.py +210 -0
  92. {scipion_pyworkflow-3.11.0.dist-info → scipion_pyworkflow-3.11.1.dist-info}/METADATA +2 -2
  93. scipion_pyworkflow-3.11.1.dist-info/RECORD +161 -0
  94. scipion_pyworkflow-3.11.0.dist-info/RECORD +0 -71
  95. {scipion_pyworkflow-3.11.0.dist-info → scipion_pyworkflow-3.11.1.dist-info}/WHEEL +0 -0
  96. {scipion_pyworkflow-3.11.0.dist-info → scipion_pyworkflow-3.11.1.dist-info}/entry_points.txt +0 -0
  97. {scipion_pyworkflow-3.11.0.dist-info → scipion_pyworkflow-3.11.1.dist-info}/licenses/LICENSE.txt +0 -0
  98. {scipion_pyworkflow-3.11.0.dist-info → scipion_pyworkflow-3.11.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,180 @@
1
+ # **************************************************************************
2
+ # *
3
+ # * Authors: J.M. De la Rosa Trevin (jmdelarosa@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
+ This modules handles the System management
28
+ """
29
+
30
+ import os
31
+
32
+ import pyworkflow as pw
33
+ import pyworkflow.utils as pwutils
34
+ from .project import Project
35
+
36
+
37
+ class ProjectInfo(object):
38
+ """Class to store some information about the project"""
39
+ def __init__(self, projName, mTime, cTime, path):
40
+ """At least it receives the Project Name and its modification time"""
41
+ self.projName = projName
42
+ self.mTime = mTime
43
+ self.cTime = cTime
44
+ self.path = path
45
+
46
+ def __str__(self):
47
+ return "%s - %s" % (self.projName, self.path)
48
+
49
+ def getName(self):
50
+ return self.projName
51
+
52
+ def getModificationTime(self):
53
+ return self.mTime
54
+
55
+ def getCreationTime(self):
56
+ return self.cTime
57
+
58
+ def isLink(self):
59
+ return os.path.islink(self.path)
60
+
61
+ def realPath(self):
62
+ return os.path.realpath(self.path)
63
+
64
+
65
+ class Manager(object):
66
+ """ Manage all projects of a given workspace, for a given Domain.
67
+ (i.e, listing projects, creating, deleting or querying info)
68
+ """
69
+ def __init__(self, workspace=None):
70
+ """
71
+ Params:
72
+ workspace: path to where the user's workspace is. A subfolder
73
+ named 'projects' is expected. If workspace is None, the workspace
74
+ will be taken from the global configuration.
75
+ """
76
+ ws = workspace or pw.Config.SCIPION_USER_DATA
77
+ self.PROJECTS = os.path.join(ws, 'projects')
78
+
79
+ def getProjectPath(self, projectName):
80
+ """Return the project path given the name"""
81
+ return os.path.join(self.PROJECTS, projectName)
82
+
83
+ def listProjects(self, sortByDate=True):
84
+ """Return a list with all existing projects
85
+ And some other project info
86
+ If sortByData is True, recently modified projects will be first"""
87
+ projList = []
88
+ pw.utils.makePath(self.PROJECTS)
89
+ for f in os.listdir(self.PROJECTS):
90
+ p = self.getProjectPath(f)
91
+ if os.path.isdir(p):
92
+ stat = os.stat(p)
93
+ projList.append(ProjectInfo(f, stat.st_mtime, stat.st_ctime, p))
94
+
95
+ if sortByDate:
96
+ projList.sort(key=lambda k: k.mTime, reverse=True)
97
+ return projList
98
+
99
+ def createProject(self, projectName, runsView=1,
100
+ hostsConf=None, protocolsConf=None, location=None, comment=None):
101
+ """Create a new project.
102
+ confs dict can contain customs .conf files
103
+ for: menus, protocols, or hosts
104
+ """
105
+ # Clean project name from undesired characters
106
+ projectName = Project.cleanProjectName(projectName)
107
+
108
+ # If location is not None create project on it (if exists)
109
+ if location is None:
110
+ projectPath = self.getProjectPath(projectName)
111
+ else:
112
+ projectPath = os.path.join(location, projectName)
113
+
114
+ # JMRT: Right now the project.create function change the current
115
+ # working dir (cwd) to the project location, let's store the cwd
116
+ # and restored after the creation
117
+ cwd = os.getcwd()
118
+ project = Project(pw.Config.getDomain(), projectPath)
119
+ project.create(runsView=runsView,
120
+ hostsConf=hostsConf,
121
+ protocolsConf=protocolsConf,
122
+ comment=comment)
123
+ # If location is not the default one create a symlink on self.PROJECTS directory
124
+ if projectPath != self.getProjectPath(projectName):
125
+ # JMRT: Let's create the link to the absolute path, since relative
126
+ # can be broken in systems with different mount points
127
+ pw.utils.createAbsLink(os.path.abspath(projectPath),
128
+ self.getProjectPath(projectName))
129
+
130
+ os.chdir(cwd) # Restore cwd before project creation
131
+
132
+ return project
133
+
134
+ def importProject(self, fromLocation, copyFiles=True, projectName=None, searchLocation=None):
135
+ """ Import a project that is somewhere else in the FS
136
+ Folder can be copied (default) or linked
137
+ Optionally a name can be specified, otherwise name will match location folder name
138
+ Project will always be created in the default project folder.
139
+ """
140
+ # If projectName is None...
141
+ if projectName is None:
142
+ # use same name as the import location
143
+ projectName = os.path.basename(fromLocation)
144
+
145
+ projectPath = self.getProjectPath(projectName)
146
+
147
+ # If need to copyFiles
148
+ if copyFiles:
149
+ # Copy the whole folder
150
+ pw.utils.copyTree(os.path.abspath(fromLocation), os.path.abspath(projectPath))
151
+
152
+ else:
153
+ # Link the folder
154
+ pw.utils.createAbsLink(os.path.abspath(fromLocation), projectPath)
155
+
156
+ project = self.loadProject(projectName)
157
+
158
+ if searchLocation:
159
+ project.fixLinks(searchLocation)
160
+
161
+ return project
162
+
163
+ def loadProject(self, projId, **kwargs):
164
+ """ Retrieve a project object, given its id. """
165
+ project = Project(pw.Config.getDomain(), self.getProjectPath(projId))
166
+ project.load(**kwargs)
167
+ return project
168
+
169
+ def deleteProject(self, projectName):
170
+ pw.utils.cleanPath(self.getProjectPath(projectName))
171
+
172
+ def renameProject(self, oldName, newName):
173
+ os.rename(self.getProjectPath(oldName), self.getProjectPath(newName))
174
+
175
+ def hasProject(self, projectName):
176
+ """Return True if exists a project with projectName"""
177
+ for projInfo in self.listProjects():
178
+ if projectName == projInfo.projName:
179
+ return True
180
+ return False