scipion-pyworkflow 3.11.0__py3-none-any.whl → 3.11.2__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.
- pyworkflow/apps/__init__.py +29 -0
- pyworkflow/apps/pw_manager.py +37 -0
- pyworkflow/apps/pw_plot.py +51 -0
- pyworkflow/apps/pw_project.py +130 -0
- pyworkflow/apps/pw_protocol_list.py +143 -0
- pyworkflow/apps/pw_protocol_run.py +51 -0
- pyworkflow/apps/pw_run_tests.py +268 -0
- pyworkflow/apps/pw_schedule_run.py +322 -0
- pyworkflow/apps/pw_sleep.py +37 -0
- pyworkflow/apps/pw_sync_data.py +440 -0
- pyworkflow/apps/pw_viewer.py +78 -0
- pyworkflow/constants.py +1 -1
- pyworkflow/gui/__init__.py +36 -0
- pyworkflow/gui/browser.py +768 -0
- pyworkflow/gui/canvas.py +1190 -0
- pyworkflow/gui/dialog.py +981 -0
- pyworkflow/gui/form.py +2727 -0
- pyworkflow/gui/graph.py +247 -0
- pyworkflow/gui/graph_layout.py +271 -0
- pyworkflow/gui/gui.py +571 -0
- pyworkflow/gui/matplotlib_image.py +233 -0
- pyworkflow/gui/plotter.py +247 -0
- pyworkflow/gui/project/__init__.py +25 -0
- pyworkflow/gui/project/base.py +193 -0
- pyworkflow/gui/project/constants.py +139 -0
- pyworkflow/gui/project/labels.py +205 -0
- pyworkflow/gui/project/project.py +491 -0
- pyworkflow/gui/project/searchprotocol.py +240 -0
- pyworkflow/gui/project/searchrun.py +181 -0
- pyworkflow/gui/project/steps.py +171 -0
- pyworkflow/gui/project/utils.py +332 -0
- pyworkflow/gui/project/variables.py +179 -0
- pyworkflow/gui/project/viewdata.py +472 -0
- pyworkflow/gui/project/viewprojects.py +519 -0
- pyworkflow/gui/project/viewprotocols.py +2141 -0
- pyworkflow/gui/project/viewprotocols_extra.py +562 -0
- pyworkflow/gui/text.py +774 -0
- pyworkflow/gui/tooltip.py +185 -0
- pyworkflow/gui/tree.py +684 -0
- pyworkflow/gui/widgets.py +307 -0
- pyworkflow/mapper/__init__.py +26 -0
- pyworkflow/mapper/mapper.py +226 -0
- pyworkflow/mapper/sqlite.py +1583 -0
- pyworkflow/mapper/sqlite_db.py +145 -0
- pyworkflow/object.py +1 -0
- pyworkflow/plugin.py +4 -4
- pyworkflow/project/__init__.py +31 -0
- pyworkflow/project/config.py +454 -0
- pyworkflow/project/manager.py +180 -0
- pyworkflow/project/project.py +2095 -0
- pyworkflow/project/usage.py +165 -0
- pyworkflow/protocol/__init__.py +38 -0
- pyworkflow/protocol/bibtex.py +48 -0
- pyworkflow/protocol/constants.py +87 -0
- pyworkflow/protocol/executor.py +515 -0
- pyworkflow/protocol/hosts.py +318 -0
- pyworkflow/protocol/launch.py +277 -0
- pyworkflow/protocol/package.py +42 -0
- pyworkflow/protocol/params.py +781 -0
- pyworkflow/protocol/protocol.py +2712 -0
- pyworkflow/resources/protlabels.xcf +0 -0
- pyworkflow/resources/sprites.png +0 -0
- pyworkflow/resources/sprites.xcf +0 -0
- pyworkflow/template.py +1 -1
- pyworkflow/tests/__init__.py +29 -0
- pyworkflow/tests/test_utils.py +25 -0
- pyworkflow/tests/tests.py +342 -0
- pyworkflow/utils/__init__.py +38 -0
- pyworkflow/utils/dataset.py +414 -0
- pyworkflow/utils/echo.py +104 -0
- pyworkflow/utils/graph.py +169 -0
- pyworkflow/utils/log.py +293 -0
- pyworkflow/utils/path.py +528 -0
- pyworkflow/utils/process.py +154 -0
- pyworkflow/utils/profiler.py +92 -0
- pyworkflow/utils/progressbar.py +154 -0
- pyworkflow/utils/properties.py +618 -0
- pyworkflow/utils/reflection.py +129 -0
- pyworkflow/utils/utils.py +880 -0
- pyworkflow/utils/which.py +229 -0
- pyworkflow/webservices/__init__.py +8 -0
- pyworkflow/webservices/config.py +8 -0
- pyworkflow/webservices/notifier.py +152 -0
- pyworkflow/webservices/repository.py +59 -0
- pyworkflow/webservices/workflowhub.py +86 -0
- pyworkflowtests/tests/__init__.py +0 -0
- pyworkflowtests/tests/test_canvas.py +72 -0
- pyworkflowtests/tests/test_domain.py +45 -0
- pyworkflowtests/tests/test_logs.py +74 -0
- pyworkflowtests/tests/test_mappers.py +392 -0
- pyworkflowtests/tests/test_object.py +507 -0
- pyworkflowtests/tests/test_project.py +42 -0
- pyworkflowtests/tests/test_protocol_execution.py +146 -0
- pyworkflowtests/tests/test_protocol_export.py +78 -0
- pyworkflowtests/tests/test_protocol_output.py +158 -0
- pyworkflowtests/tests/test_streaming.py +47 -0
- pyworkflowtests/tests/test_utils.py +210 -0
- {scipion_pyworkflow-3.11.0.dist-info → scipion_pyworkflow-3.11.2.dist-info}/METADATA +2 -2
- scipion_pyworkflow-3.11.2.dist-info/RECORD +162 -0
- scipion_pyworkflow-3.11.0.dist-info/RECORD +0 -71
- {scipion_pyworkflow-3.11.0.dist-info → scipion_pyworkflow-3.11.2.dist-info}/WHEEL +0 -0
- {scipion_pyworkflow-3.11.0.dist-info → scipion_pyworkflow-3.11.2.dist-info}/entry_points.txt +0 -0
- {scipion_pyworkflow-3.11.0.dist-info → scipion_pyworkflow-3.11.2.dist-info}/licenses/LICENSE.txt +0 -0
- {scipion_pyworkflow-3.11.0.dist-info → scipion_pyworkflow-3.11.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
|
2
|
+
import time
|
3
|
+
instances = {}
|
4
|
+
elapsedTime = {}
|
5
|
+
|
6
|
+
|
7
|
+
def getInstancesCount():
|
8
|
+
return instances
|
9
|
+
|
10
|
+
|
11
|
+
def instanceCreated(cls):
|
12
|
+
instances[cls] = instances.get(cls, 0) + 1
|
13
|
+
|
14
|
+
|
15
|
+
def instanceDestroyed(cls):
|
16
|
+
instances[cls] = instances.get(cls, 0) - 1
|
17
|
+
|
18
|
+
|
19
|
+
def printInstances():
|
20
|
+
for k, v in instances.items():
|
21
|
+
print("%s: %d", k, v)
|
22
|
+
|
23
|
+
|
24
|
+
def waitForDebugger(seconds=20):
|
25
|
+
print("Waiting for debugger %d seconds." % seconds)
|
26
|
+
from pyworkflow.utils import printTraceBack
|
27
|
+
printTraceBack()
|
28
|
+
|
29
|
+
while seconds > 0:
|
30
|
+
time.sleep(1)
|
31
|
+
# Set seconds to 0:
|
32
|
+
# Execute this in the debugger: seconds = 0
|
33
|
+
print(str(seconds) + " seconds left.")
|
34
|
+
seconds -= 1
|
35
|
+
|
36
|
+
|
37
|
+
# From: https://www.huyng.com/posts/python-performance-analysis
|
38
|
+
|
39
|
+
|
40
|
+
class Timer(object):
|
41
|
+
indentation = 0
|
42
|
+
blackList = []
|
43
|
+
whiteList = []
|
44
|
+
minms = 1
|
45
|
+
|
46
|
+
def __init__(self, name=None, verbose=True):
|
47
|
+
self.verbose = verbose
|
48
|
+
self.name = name
|
49
|
+
Timer.indentation += 1
|
50
|
+
|
51
|
+
def __enter__(self):
|
52
|
+
self.start = time.time()
|
53
|
+
return self
|
54
|
+
|
55
|
+
def __exit__(self, *args):
|
56
|
+
self.end = time.time()
|
57
|
+
self.secs = self.end - self.start
|
58
|
+
self.msecs = self.secs * 1000 # millisecs
|
59
|
+
Timer.indentation -= 1
|
60
|
+
|
61
|
+
toPrint = (len(Timer.whiteList) == 0)
|
62
|
+
|
63
|
+
if any(self.name.startswith(s) for s in Timer.blackList):
|
64
|
+
toPrint = False
|
65
|
+
|
66
|
+
if any(self.name.startswith(s) for s in Timer.whiteList):
|
67
|
+
toPrint = True
|
68
|
+
|
69
|
+
if self.verbose and toPrint and self.msecs > Timer.minms:
|
70
|
+
print('{0}{1:10.0f}\tms\t{2}'.format('\t' * Timer.indentation, self.msecs, self.name))
|
71
|
+
|
72
|
+
# To monitor memory leaks:
|
73
|
+
# 1.- Check you have installed pympler: scipion run pip install pympler
|
74
|
+
# 2.- Uncomment lines below
|
75
|
+
# 3.- Add a with statement like:
|
76
|
+
# with monitor.MemoryMonitor():
|
77
|
+
# <code to analyze>
|
78
|
+
# from pympler.tracker import SummaryTracker
|
79
|
+
#
|
80
|
+
#
|
81
|
+
# class MemoryMonitor(object):
|
82
|
+
#
|
83
|
+
# def __init__(self):
|
84
|
+
# self.tracker = None
|
85
|
+
#
|
86
|
+
# def __enter__(self):
|
87
|
+
# self.tracker = SummaryTracker()
|
88
|
+
# self.tracker.print_diff()
|
89
|
+
# return self
|
90
|
+
#
|
91
|
+
# def __exit__(self, *args):
|
92
|
+
# self.tracker.print_diff()
|
@@ -0,0 +1,154 @@
|
|
1
|
+
# **************************************************************************
|
2
|
+
# *
|
3
|
+
# * Authors: Roberto Marabini (roberto@cnb.csic.es) [1]
|
4
|
+
# * J.M. De la Rosa Trevin (delarosatrevin@scilifelab.se) [2]
|
5
|
+
# *
|
6
|
+
# * [1] Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
|
7
|
+
# * [2] SciLifeLab, Stockholm University
|
8
|
+
# *
|
9
|
+
# * This program is free software; you can redistribute it and/or modify
|
10
|
+
# * it under the terms of the GNU General Public License as published by
|
11
|
+
# * the Free Software Foundation; either version 3 of the License, or
|
12
|
+
# * (at your option) any later version.
|
13
|
+
# *
|
14
|
+
# * This program is distributed in the hope that it will be useful,
|
15
|
+
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# * GNU General Public License for more details.
|
18
|
+
# *
|
19
|
+
# * You should have received a copy of the GNU General Public License
|
20
|
+
# * along with this program; if not, write to the Free Software
|
21
|
+
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
22
|
+
# * 02111-1307 USA
|
23
|
+
# *
|
24
|
+
# * All comments concerning this program package may be sent to the
|
25
|
+
# * e-mail address 'scipion@cnb.csic.es'
|
26
|
+
# *
|
27
|
+
# **************************************************************************
|
28
|
+
|
29
|
+
|
30
|
+
import sys
|
31
|
+
import re
|
32
|
+
|
33
|
+
|
34
|
+
class ProgressBar(object):
|
35
|
+
""" Text progress bar class for Python.
|
36
|
+
|
37
|
+
A text progress bar is typically used to display the progress of a long-running
|
38
|
+
operation, providing a visual cue that processing is underway.
|
39
|
+
|
40
|
+
Example::
|
41
|
+
|
42
|
+
N = 1000
|
43
|
+
pb = ProgressBar(N, fmt=ProgressBar.FULL)
|
44
|
+
pb.start()
|
45
|
+
for x in range(N):
|
46
|
+
pb.update(x+1)
|
47
|
+
sleep(0.1)
|
48
|
+
pb.finish()
|
49
|
+
|
50
|
+
Optionally you can pass a step param (default to 10000) and call increase in each loop. Only when the step is reached, the progress is printed.
|
51
|
+
"""
|
52
|
+
DEFAULT = 'Progress: %(bar)s %(percent)3d%%'
|
53
|
+
FULL = '%(bar)s %(current)d/%(total)d (%(percent)3d%%) %(remaining)d to go'
|
54
|
+
# scipion uses variable fonts so the bar size changes
|
55
|
+
# since the space width is different from the = width
|
56
|
+
NOBAR = '%(current)d/%(total)d (%(percent)3d%%) %(remaining)d to go'
|
57
|
+
OBJID = '%(bar)s %(current)d/%(total)d (%(percent)3d%%) (objectId=%(objectId)d)'
|
58
|
+
DOT = '.'
|
59
|
+
|
60
|
+
def __init__(self, total, width=40, fmt=DEFAULT, symbol='=',
|
61
|
+
output=None, extraArgs=None, step=10000):
|
62
|
+
"""
|
63
|
+
Create a new ProgressBar object.
|
64
|
+
|
65
|
+
:param total: The total amount that will be running the progress bar.
|
66
|
+
The value in the update() method can no go greater than this value.
|
67
|
+
:param width: progress bar width (without the percentage and number of
|
68
|
+
iterations loop)
|
69
|
+
:param fmt: predefined format string, so far DEFAULT, FULL, OBJID and
|
70
|
+
DOT are defined.
|
71
|
+
:param symbol: progress bar is made with this symbol
|
72
|
+
:param output:
|
73
|
+
:param extraArgs: Additional arguments that can be passed to be used
|
74
|
+
the fmt format. (e.g extraArgs={'objectId': 1} for fmt=OBJID
|
75
|
+
:param step: interval between printing progress. Use in combination with "increase"
|
76
|
+
"""
|
77
|
+
if len(symbol) != 1:
|
78
|
+
raise Exception("Symbol should be only 1 character length. ")
|
79
|
+
|
80
|
+
self._total = total
|
81
|
+
self._width = width
|
82
|
+
self._symbol = symbol
|
83
|
+
self._output = output or sys.stdout
|
84
|
+
self._current = -1
|
85
|
+
self._extraArgs = extraArgs or {}
|
86
|
+
self._fmt = fmt
|
87
|
+
self._directPrint = fmt == self.DOT
|
88
|
+
self.step = step
|
89
|
+
|
90
|
+
if not self._directPrint:
|
91
|
+
# This line computes the number of digits
|
92
|
+
# in total and rewrites the fmt string
|
93
|
+
# so if total = 100, %d is converted to %3d
|
94
|
+
self._fmt = re.sub(r'(?P<name>%\(.+?\))d',
|
95
|
+
r'\g<name>%dd' % len(str(total)), fmt)
|
96
|
+
|
97
|
+
def __getStr(self):
|
98
|
+
""" Internal function to return the current string value.
|
99
|
+
It should be called after the value has being set.
|
100
|
+
"""
|
101
|
+
if self._directPrint: # print just a dot
|
102
|
+
return self._fmt if self._current else ''
|
103
|
+
|
104
|
+
percent = self._current / float(self._total)
|
105
|
+
size = int(self._width * percent)
|
106
|
+
remaining = self._total - self._current
|
107
|
+
bar = '[' + self._symbol * size + ' ' * (self._width - size) + ']'
|
108
|
+
|
109
|
+
args = {
|
110
|
+
'total': self._total,
|
111
|
+
'bar': bar,
|
112
|
+
'current': self._current,
|
113
|
+
'percent': percent * 100,
|
114
|
+
'remaining': remaining,
|
115
|
+
}
|
116
|
+
args.update(self._extraArgs)
|
117
|
+
|
118
|
+
return '\r' + self._fmt % args
|
119
|
+
|
120
|
+
def start(self):
|
121
|
+
""" Print empty progress bar. """
|
122
|
+
self.update(0)
|
123
|
+
|
124
|
+
def update(self, value):
|
125
|
+
"""
|
126
|
+
Update the current value and print the progress.
|
127
|
+
|
128
|
+
:param value: New value, should be greater than the previous
|
129
|
+
value and less or equal the total value
|
130
|
+
:return:
|
131
|
+
"""
|
132
|
+
if value < 0 or value <= self._current or value > self._total:
|
133
|
+
raise Exception("Incorrect value provided. It should be greater "
|
134
|
+
"than previous value and between 0 and total. ")
|
135
|
+
self._current = value
|
136
|
+
self._output.write(self.__getStr())
|
137
|
+
self._output.flush()
|
138
|
+
|
139
|
+
def increase(self):
|
140
|
+
""" Increase the value by 1. Is new value matches the step. update is called"""
|
141
|
+
nextValue = self._current + 1
|
142
|
+
if (nextValue) % self.step == 0:
|
143
|
+
self.update(nextValue)
|
144
|
+
else:
|
145
|
+
self._current=nextValue
|
146
|
+
|
147
|
+
def finish(self, printNewLine=True):
|
148
|
+
""" Finalize the progress and
|
149
|
+
print last update with 100% complete message """
|
150
|
+
if self._current < self._total:
|
151
|
+
self.update(self._total)
|
152
|
+
# print a new line
|
153
|
+
if printNewLine:
|
154
|
+
self._output.write("\n")
|