scipion-pyworkflow 3.10.5__py3-none-any.whl → 3.11.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.
- pyworkflow/config.py +131 -67
- pyworkflow/constants.py +12 -2
- pyworkflow/object.py +3 -2
- pyworkflow/plugin.py +93 -44
- pyworkflow/project/scripts/fix_links.py +4 -1
- pyworkflow/resources/showj/arrowDown.png +0 -0
- pyworkflow/resources/showj/arrowUp.png +0 -0
- pyworkflow/resources/showj/background_section.png +0 -0
- pyworkflow/resources/showj/colRowModeOff.png +0 -0
- pyworkflow/resources/showj/colRowModeOn.png +0 -0
- pyworkflow/resources/showj/delete.png +0 -0
- pyworkflow/resources/showj/doc_icon.png +0 -0
- pyworkflow/resources/showj/download_icon.png +0 -0
- pyworkflow/resources/showj/enabled_gallery.png +0 -0
- pyworkflow/resources/showj/galleryViewOff.png +0 -0
- pyworkflow/resources/showj/galleryViewOn.png +0 -0
- pyworkflow/resources/showj/goto.png +0 -0
- pyworkflow/resources/showj/menu.png +0 -0
- pyworkflow/resources/showj/separator.png +0 -0
- pyworkflow/resources/showj/tableViewOff.png +0 -0
- pyworkflow/resources/showj/tableViewOn.png +0 -0
- pyworkflow/resources/showj/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- pyworkflow/resources/showj/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- pyworkflow/resources/showj/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- pyworkflow/resources/showj/volumeOff.png +0 -0
- pyworkflow/resources/showj/volumeOn.png +0 -0
- pyworkflow/viewer.py +23 -1
- pyworkflowtests/objects.py +2 -2
- pyworkflowtests/protocols.py +1 -3
- {scipion_pyworkflow-3.10.5.dist-info → scipion_pyworkflow-3.11.0.dist-info}/METADATA +21 -25
- scipion_pyworkflow-3.11.0.dist-info/RECORD +71 -0
- {scipion_pyworkflow-3.10.5.dist-info → scipion_pyworkflow-3.11.0.dist-info}/WHEEL +1 -1
- scipion_pyworkflow-3.11.0.dist-info/entry_points.txt +2 -0
- pyworkflow/apps/__init__.py +0 -29
- pyworkflow/apps/pw_manager.py +0 -37
- pyworkflow/apps/pw_plot.py +0 -51
- pyworkflow/apps/pw_project.py +0 -113
- pyworkflow/apps/pw_protocol_list.py +0 -143
- pyworkflow/apps/pw_protocol_run.py +0 -51
- pyworkflow/apps/pw_run_tests.py +0 -267
- pyworkflow/apps/pw_schedule_run.py +0 -322
- pyworkflow/apps/pw_sleep.py +0 -37
- pyworkflow/apps/pw_sync_data.py +0 -439
- pyworkflow/apps/pw_viewer.py +0 -78
- pyworkflow/gui/__init__.py +0 -36
- pyworkflow/gui/browser.py +0 -726
- pyworkflow/gui/canvas.py +0 -1190
- pyworkflow/gui/dialog.py +0 -977
- pyworkflow/gui/form.py +0 -2637
- pyworkflow/gui/graph.py +0 -247
- pyworkflow/gui/graph_layout.py +0 -271
- pyworkflow/gui/gui.py +0 -566
- pyworkflow/gui/matplotlib_image.py +0 -233
- pyworkflow/gui/plotter.py +0 -247
- pyworkflow/gui/project/__init__.py +0 -25
- pyworkflow/gui/project/base.py +0 -192
- pyworkflow/gui/project/constants.py +0 -139
- pyworkflow/gui/project/labels.py +0 -205
- pyworkflow/gui/project/project.py +0 -492
- pyworkflow/gui/project/searchprotocol.py +0 -154
- pyworkflow/gui/project/searchrun.py +0 -181
- pyworkflow/gui/project/steps.py +0 -171
- pyworkflow/gui/project/utils.py +0 -332
- pyworkflow/gui/project/variables.py +0 -179
- pyworkflow/gui/project/viewdata.py +0 -472
- pyworkflow/gui/project/viewprojects.py +0 -510
- pyworkflow/gui/project/viewprotocols.py +0 -2093
- pyworkflow/gui/project/viewprotocols_extra.py +0 -560
- pyworkflow/gui/text.py +0 -771
- pyworkflow/gui/tooltip.py +0 -185
- pyworkflow/gui/tree.py +0 -684
- pyworkflow/gui/widgets.py +0 -307
- pyworkflow/mapper/__init__.py +0 -26
- pyworkflow/mapper/mapper.py +0 -222
- pyworkflow/mapper/sqlite.py +0 -1578
- pyworkflow/mapper/sqlite_db.py +0 -145
- pyworkflow/project/__init__.py +0 -31
- pyworkflow/project/config.py +0 -454
- pyworkflow/project/manager.py +0 -180
- pyworkflow/project/project.py +0 -2010
- pyworkflow/protocol/__init__.py +0 -38
- pyworkflow/protocol/bibtex.py +0 -48
- pyworkflow/protocol/constants.py +0 -87
- pyworkflow/protocol/executor.py +0 -455
- pyworkflow/protocol/hosts.py +0 -313
- pyworkflow/protocol/launch.py +0 -270
- pyworkflow/protocol/package.py +0 -42
- pyworkflow/protocol/params.py +0 -741
- pyworkflow/protocol/protocol.py +0 -2582
- pyworkflow/tests/__init__.py +0 -29
- pyworkflow/tests/test_utils.py +0 -25
- pyworkflow/tests/tests.py +0 -341
- pyworkflow/utils/__init__.py +0 -38
- pyworkflow/utils/dataset.py +0 -414
- pyworkflow/utils/echo.py +0 -104
- pyworkflow/utils/graph.py +0 -169
- pyworkflow/utils/log.py +0 -284
- pyworkflow/utils/path.py +0 -528
- pyworkflow/utils/process.py +0 -132
- pyworkflow/utils/profiler.py +0 -92
- pyworkflow/utils/progressbar.py +0 -154
- pyworkflow/utils/properties.py +0 -631
- pyworkflow/utils/reflection.py +0 -129
- pyworkflow/utils/utils.py +0 -879
- pyworkflow/utils/which.py +0 -229
- pyworkflow/webservices/__init__.py +0 -8
- pyworkflow/webservices/config.py +0 -11
- pyworkflow/webservices/notifier.py +0 -162
- pyworkflow/webservices/repository.py +0 -59
- pyworkflow/webservices/workflowhub.py +0 -74
- pyworkflowtests/tests/__init__.py +0 -0
- pyworkflowtests/tests/test_canvas.py +0 -72
- pyworkflowtests/tests/test_domain.py +0 -45
- pyworkflowtests/tests/test_logs.py +0 -74
- pyworkflowtests/tests/test_mappers.py +0 -392
- pyworkflowtests/tests/test_object.py +0 -507
- pyworkflowtests/tests/test_project.py +0 -42
- pyworkflowtests/tests/test_protocol_execution.py +0 -135
- pyworkflowtests/tests/test_protocol_export.py +0 -78
- pyworkflowtests/tests/test_protocol_output.py +0 -158
- pyworkflowtests/tests/test_streaming.py +0 -47
- pyworkflowtests/tests/test_utils.py +0 -210
- scipion_pyworkflow-3.10.5.dist-info/RECORD +0 -140
- scipion_pyworkflow-3.10.5.dist-info/dependency_links.txt +0 -1
- scipion_pyworkflow-3.10.5.dist-info/entry_points.txt +0 -5
- {scipion_pyworkflow-3.10.5.dist-info → scipion_pyworkflow-3.11.0.dist-info/licenses}/LICENSE.txt +0 -0
- {scipion_pyworkflow-3.10.5.dist-info → scipion_pyworkflow-3.11.0.dist-info}/top_level.txt +0 -0
pyworkflow/utils/log.py
DELETED
@@ -1,284 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python
|
2
|
-
# **************************************************************************
|
3
|
-
# *
|
4
|
-
# * Authors: Antonio Poza (Apr 30, 2013)
|
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
|
-
Module to handle default logging configuration and custom one. Default logging configuration
|
29
|
-
is defined here but optionally, it can be configured with an external json file
|
30
|
-
containing a standard python logging configuration content as documented here:
|
31
|
-
https://docs.python.org/3/howto/logging-cookbook.html#an-example-dictionary-based-configuration
|
32
|
-
To specify a custom logging config file use SCIPION_LOG_CONFIG variable to a json logging configuration file
|
33
|
-
If you just want to change the logger devel use SCIPION_LOG_LEVEL variable (defaults to INFO)
|
34
|
-
See https://docs.python.org/3/howto/logging.html#logging-levels for available levels. Use the literal! not de value.
|
35
|
-
"""
|
36
|
-
import os
|
37
|
-
import sys
|
38
|
-
import logging
|
39
|
-
import logging.config
|
40
|
-
import json
|
41
|
-
from logging import FileHandler
|
42
|
-
|
43
|
-
from pyworkflow.constants import PROJECT_SETTINGS, PROJECT_DBNAME
|
44
|
-
from pyworkflow.utils import Config
|
45
|
-
|
46
|
-
CONSOLE_HANDLER = 'consoleHandler'
|
47
|
-
|
48
|
-
SCIPION_PROT_ID = "SCIPION_PROT_ID"
|
49
|
-
SCIPION_PROJ_ID = "SCIPION_PROJ_ID"
|
50
|
-
|
51
|
-
|
52
|
-
# Constant for extra logging data
|
53
|
-
class STATUS:
|
54
|
-
START = "START"
|
55
|
-
STOP = "STOP"
|
56
|
-
INTERVAL = "INTERVAL"
|
57
|
-
EVENT = "EVENT"
|
58
|
-
|
59
|
-
|
60
|
-
class LevelFilter(object):
|
61
|
-
""" Logging handler filter to filter some levels. e.g.: ERROR """
|
62
|
-
def __init__(self, level):
|
63
|
-
"""
|
64
|
-
|
65
|
-
:param level: Level integer value,from which include messages. Value is compared to record.levelno.
|
66
|
-
"""
|
67
|
-
|
68
|
-
self.level = level
|
69
|
-
|
70
|
-
def filter(self, record):
|
71
|
-
return record.levelno <= self.level
|
72
|
-
|
73
|
-
class LoggingConfigurator:
|
74
|
-
""" Class to configure logging scenarios:
|
75
|
-
|
76
|
-
1.- GUI logging
|
77
|
-
|
78
|
-
2.- Protocol run logging
|
79
|
-
|
80
|
-
3.- Other loggings: tests, sync data"""
|
81
|
-
|
82
|
-
customLoggingActive = False # Holds if a custom logging configuration has taken place.
|
83
|
-
|
84
|
-
@classmethod
|
85
|
-
def setupLogging(cls, logFile=None, console=True):
|
86
|
-
if not cls.loadCustomLoggingConfig():
|
87
|
-
cls.setupDefaultLogging(logFile=logFile, console=console)
|
88
|
-
|
89
|
-
@classmethod
|
90
|
-
def loadCustomLoggingConfig(cls):
|
91
|
-
""" Loads the custom logging configuration file"""
|
92
|
-
from pyworkflow import Config
|
93
|
-
|
94
|
-
if Config.SCIPION_LOG_CONFIG:
|
95
|
-
if os.path.exists(Config.SCIPION_LOG_CONFIG):
|
96
|
-
with open(Config.SCIPION_LOG_CONFIG, 'r') as stream:
|
97
|
-
config = json.load(stream)
|
98
|
-
|
99
|
-
logging.config.dictConfig(config)
|
100
|
-
cls.customLoggingActive = True
|
101
|
-
return True
|
102
|
-
else:
|
103
|
-
print("SCIPION_LOG_CONFIG variable points to a non existing file: %s." % Config.SCIPION_LOG_CONFIG)
|
104
|
-
return False
|
105
|
-
|
106
|
-
@staticmethod
|
107
|
-
def setupDefaultLogging(logFile=None, console=True):
|
108
|
-
""" Configures logging in a default way that is to file (rotating) and console
|
109
|
-
|
110
|
-
:param logFile: Optional, path to the log file. Defaults to SCIPION_LOG variable value. If folder
|
111
|
-
does not exists it will be created.
|
112
|
-
:param console: Optional, defaults to True, so log messages are sent to the terminal as well
|
113
|
-
|
114
|
-
"""
|
115
|
-
from pyworkflow import Config
|
116
|
-
|
117
|
-
logFile = logFile or Config.SCIPION_LOG
|
118
|
-
|
119
|
-
# Log configuration
|
120
|
-
config = {
|
121
|
-
'version': 1,
|
122
|
-
'disable_existing_loggers': False,
|
123
|
-
'formatters': {
|
124
|
-
'standard': {
|
125
|
-
'format': Config.SCIPION_LOG_FORMAT
|
126
|
-
}
|
127
|
-
},
|
128
|
-
'handlers': {
|
129
|
-
'fileHandler': {
|
130
|
-
'level': Config.SCIPION_LOG_LEVEL,
|
131
|
-
'class': 'logging.handlers.RotatingFileHandler',
|
132
|
-
'formatter': 'standard',
|
133
|
-
'filename': logFile,
|
134
|
-
'maxBytes': 1000000,
|
135
|
-
'backupCount': 10
|
136
|
-
},
|
137
|
-
},
|
138
|
-
'loggers': {
|
139
|
-
'': {
|
140
|
-
'handlers': ['fileHandler'],
|
141
|
-
'level': Config.SCIPION_LOG_LEVEL,
|
142
|
-
'propagate': False,
|
143
|
-
'qualname': 'pyworkflow',
|
144
|
-
},
|
145
|
-
}
|
146
|
-
}
|
147
|
-
|
148
|
-
if console:
|
149
|
-
config["handlers"][CONSOLE_HANDLER] = {
|
150
|
-
'level': 'ERROR', #Config.SCIPION_LOG_LEVEL,
|
151
|
-
'class': 'logging.StreamHandler',
|
152
|
-
'formatter': 'standard',
|
153
|
-
}
|
154
|
-
|
155
|
-
config['loggers']['']['handlers'].append(CONSOLE_HANDLER)
|
156
|
-
|
157
|
-
# Create the log folder
|
158
|
-
os.makedirs(os.path.dirname(os.path.abspath(logFile)), exist_ok=True)
|
159
|
-
|
160
|
-
logging.config.dictConfig(config)
|
161
|
-
|
162
|
-
@classmethod
|
163
|
-
def setUpGUILogging(cls, logFile=None):
|
164
|
-
"""Sets up the logging library for the GUI processes: By default all goes to SCIPION_LOG file and console."""
|
165
|
-
cls.setupLogging(logFile=logFile)
|
166
|
-
|
167
|
-
@classmethod
|
168
|
-
def setUpProtocolSchedulingLog(cls, scheduleLogFile):
|
169
|
-
""" Sets up the logging for the scheduling process"""
|
170
|
-
|
171
|
-
# Load custom logging
|
172
|
-
cls.loadCustomLoggingConfig()
|
173
|
-
|
174
|
-
# File handler to the scheduling log file
|
175
|
-
scheduleHandler = FileHandler(scheduleLogFile)
|
176
|
-
|
177
|
-
# Get the root logger
|
178
|
-
rootLogger = logging.getLogger()
|
179
|
-
|
180
|
-
# If there wasn't any custom logging
|
181
|
-
if not cls.customLoggingActive:
|
182
|
-
# Remove the default handler that goes to the terminal
|
183
|
-
rootLogger.handlers.clear()
|
184
|
-
|
185
|
-
# Add the handler
|
186
|
-
rootLogger.addHandler(scheduleHandler)
|
187
|
-
rootLogger.setLevel(Config.SCIPION_LOG_LEVEL)
|
188
|
-
|
189
|
-
# create formatter and add it to the handlers
|
190
|
-
formatter = logging.Formatter(Config.SCIPION_LOG_FORMAT)
|
191
|
-
scheduleHandler.setFormatter(formatter)
|
192
|
-
|
193
|
-
|
194
|
-
@classmethod
|
195
|
-
def setUpProtocolRunLogging(cls, stdoutLogFile, stderrLogFile):
|
196
|
-
""" Sets up the logging library for the protocols run processes, loads the custom configuration plus
|
197
|
-
2 FileHandlers for stdout and stderr"""
|
198
|
-
|
199
|
-
cls.loadCustomLoggingConfig()
|
200
|
-
|
201
|
-
# std out: Only warning, info and debug. Error and critical should go exclusively to stderr handler
|
202
|
-
stdoutHandler = FileHandler(stdoutLogFile)
|
203
|
-
stdoutHandler.addFilter(LevelFilter(logging.WARNING))
|
204
|
-
|
205
|
-
# std err: just errors and critical
|
206
|
-
stderrHandler = FileHandler(stderrLogFile)
|
207
|
-
stderrHandler.setLevel(logging.ERROR)
|
208
|
-
|
209
|
-
# Get the root logger
|
210
|
-
rootLogger = logging.getLogger()
|
211
|
-
|
212
|
-
# If there wasn't any custom logging
|
213
|
-
if not cls.customLoggingActive:
|
214
|
-
# Remove the default handler that goes to the terminal
|
215
|
-
rootLogger.handlers.clear()
|
216
|
-
|
217
|
-
# Add the 2 handlers, remove the
|
218
|
-
rootLogger.addHandler(stderrHandler)
|
219
|
-
rootLogger.addHandler(stdoutHandler)
|
220
|
-
rootLogger.setLevel(Config.SCIPION_LOG_LEVEL)
|
221
|
-
|
222
|
-
# create formatter and add it to the handlers
|
223
|
-
formatter = logging.Formatter(Config.SCIPION_LOG_FORMAT)
|
224
|
-
stdoutHandler.setFormatter(formatter)
|
225
|
-
stderrHandler.setFormatter(formatter)
|
226
|
-
|
227
|
-
# Capture std out and std err and send it to the file handlers
|
228
|
-
rootLogger.info("Logging configured. STDOUT --> %s , STDERR --> %s" % (stdoutLogFile, stderrLogFile))
|
229
|
-
|
230
|
-
# TO IMPROVE: This redirects the std out and stderr to the stream contained by the FileHandlers.
|
231
|
-
# The problem with this is that output stderr and stdout from subprocesses is written directly to the file
|
232
|
-
# and therefore not being formatted or propagated to other loggers in case of a custom logging configuration.
|
233
|
-
# I've (Pablo) have attempted what is described here: https://stackoverflow.com/questions/19425736/how-to-redirect-stdout-and-stderr-to-logger-in-python
|
234
|
-
# but didn't work--> check_call(command, shell=True, stdout=sys.stdout, stderr=sys.stderr ) . This leads to an error cause deep in the code python does this: c2pwrite = stdout.fileno()
|
235
|
-
sys.stderr = stderrHandler.stream
|
236
|
-
sys.stdout = stdoutHandler.stream
|
237
|
-
|
238
|
-
return rootLogger
|
239
|
-
|
240
|
-
|
241
|
-
def restoreStdoutAndErr():
|
242
|
-
sys.stdout = sys.__stdout__
|
243
|
-
sys.stderr = sys.__stderr__
|
244
|
-
|
245
|
-
|
246
|
-
# ******** Extra code to send some log lines to an external performance analysis tool ***********
|
247
|
-
def setDefaultLoggingContext(protId, projId):
|
248
|
-
os.environ[SCIPION_PROT_ID] = str(protId)
|
249
|
-
os.environ[SCIPION_PROJ_ID] = projId
|
250
|
-
|
251
|
-
|
252
|
-
def getFinalProtId(protId):
|
253
|
-
return protId if protId is not None else int(os.environ.get(SCIPION_PROT_ID, "-1"))
|
254
|
-
|
255
|
-
|
256
|
-
def getFinalProjId(projId):
|
257
|
-
return projId if projId is not None else os.environ.get(SCIPION_PROJ_ID, "unknown")
|
258
|
-
|
259
|
-
|
260
|
-
def getExtraLogInfo(measurement, status, project_name=None, prot_id=None, prot_name=None, step_id=None, duration=None,
|
261
|
-
dbfilename=None):
|
262
|
-
try:
|
263
|
-
# Add TS!! optionally
|
264
|
-
if dbfilename:
|
265
|
-
splitDb = dbfilename.split("/")
|
266
|
-
dbName = splitDb[-1]
|
267
|
-
runName = ""
|
268
|
-
# project.sqlite and settings.sqlite may not have elements
|
269
|
-
if dbName not in [PROJECT_SETTINGS, PROJECT_DBNAME, ":memory:"]:
|
270
|
-
runName = splitDb[1]
|
271
|
-
dbfilename = os.path.join(runName, dbName)
|
272
|
-
|
273
|
-
return {"measurement": measurement,
|
274
|
-
"status": status,
|
275
|
-
"project_name": getFinalProjId(project_name),
|
276
|
-
"prot_id": getFinalProtId(prot_id),
|
277
|
-
"prot_name": prot_name,
|
278
|
-
"step_id": step_id,
|
279
|
-
"duration": duration,
|
280
|
-
"dbfilename": dbfilename
|
281
|
-
}
|
282
|
-
|
283
|
-
except Exception as e:
|
284
|
-
print("getExtraLogInfo failed: %s.Params were: dbFilename %s" % (e, dbfilename))
|