pyworkflow-engine 0.1.9__py3-none-any.whl → 0.1.10__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/__init__.py +1 -1
- pyworkflow/config.py +94 -17
- {pyworkflow_engine-0.1.9.dist-info → pyworkflow_engine-0.1.10.dist-info}/METADATA +1 -1
- {pyworkflow_engine-0.1.9.dist-info → pyworkflow_engine-0.1.10.dist-info}/RECORD +8 -8
- {pyworkflow_engine-0.1.9.dist-info → pyworkflow_engine-0.1.10.dist-info}/WHEEL +0 -0
- {pyworkflow_engine-0.1.9.dist-info → pyworkflow_engine-0.1.10.dist-info}/entry_points.txt +0 -0
- {pyworkflow_engine-0.1.9.dist-info → pyworkflow_engine-0.1.10.dist-info}/licenses/LICENSE +0 -0
- {pyworkflow_engine-0.1.9.dist-info → pyworkflow_engine-0.1.10.dist-info}/top_level.txt +0 -0
pyworkflow/__init__.py
CHANGED
pyworkflow/config.py
CHANGED
|
@@ -5,8 +5,9 @@ Provides global configuration for runtime, storage, and default settings.
|
|
|
5
5
|
|
|
6
6
|
Configuration is loaded in this priority order:
|
|
7
7
|
1. Values set via pyworkflow.configure() (highest priority)
|
|
8
|
-
2.
|
|
9
|
-
3.
|
|
8
|
+
2. Environment variables (PYWORKFLOW_*)
|
|
9
|
+
3. Values from pyworkflow.config.yaml in current directory
|
|
10
|
+
4. Default values
|
|
10
11
|
|
|
11
12
|
Usage:
|
|
12
13
|
>>> import pyworkflow
|
|
@@ -15,8 +16,26 @@ Usage:
|
|
|
15
16
|
... default_durable=False,
|
|
16
17
|
... storage=InMemoryStorageBackend(),
|
|
17
18
|
... )
|
|
19
|
+
|
|
20
|
+
Environment Variables:
|
|
21
|
+
PYWORKFLOW_STORAGE_TYPE: Storage backend type (file, memory, sqlite, postgres, mysql)
|
|
22
|
+
PYWORKFLOW_STORAGE_PATH: Path for file/sqlite backends
|
|
23
|
+
PYWORKFLOW_POSTGRES_HOST: PostgreSQL host
|
|
24
|
+
PYWORKFLOW_POSTGRES_PORT: PostgreSQL port
|
|
25
|
+
PYWORKFLOW_POSTGRES_USER: PostgreSQL user
|
|
26
|
+
PYWORKFLOW_POSTGRES_PASSWORD: PostgreSQL password
|
|
27
|
+
PYWORKFLOW_POSTGRES_DATABASE: PostgreSQL database
|
|
28
|
+
PYWORKFLOW_MYSQL_HOST: MySQL host
|
|
29
|
+
PYWORKFLOW_MYSQL_PORT: MySQL port
|
|
30
|
+
PYWORKFLOW_MYSQL_USER: MySQL user
|
|
31
|
+
PYWORKFLOW_MYSQL_PASSWORD: MySQL password
|
|
32
|
+
PYWORKFLOW_MYSQL_DATABASE: MySQL database
|
|
33
|
+
PYWORKFLOW_CELERY_BROKER: Celery broker URL
|
|
34
|
+
PYWORKFLOW_CELERY_RESULT_BACKEND: Celery result backend URL
|
|
35
|
+
PYWORKFLOW_RUNTIME: Default runtime (local, celery)
|
|
18
36
|
"""
|
|
19
37
|
|
|
38
|
+
import os
|
|
20
39
|
import warnings
|
|
21
40
|
from dataclasses import dataclass
|
|
22
41
|
from pathlib import Path
|
|
@@ -26,6 +45,54 @@ if TYPE_CHECKING:
|
|
|
26
45
|
from pyworkflow.storage.base import StorageBackend
|
|
27
46
|
|
|
28
47
|
|
|
48
|
+
def _load_env_storage_config() -> dict[str, Any] | None:
|
|
49
|
+
"""
|
|
50
|
+
Load storage configuration from environment variables.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
Storage configuration dict if PYWORKFLOW_STORAGE_TYPE is set, None otherwise
|
|
54
|
+
"""
|
|
55
|
+
storage_type = os.getenv("PYWORKFLOW_STORAGE_TYPE") or os.getenv("PYWORKFLOW_STORAGE_BACKEND")
|
|
56
|
+
if not storage_type:
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
storage_type = storage_type.lower()
|
|
60
|
+
|
|
61
|
+
if storage_type == "postgres":
|
|
62
|
+
return {
|
|
63
|
+
"type": "postgres",
|
|
64
|
+
"host": os.getenv("PYWORKFLOW_POSTGRES_HOST", "localhost"),
|
|
65
|
+
"port": int(os.getenv("PYWORKFLOW_POSTGRES_PORT", "5432")),
|
|
66
|
+
"user": os.getenv("PYWORKFLOW_POSTGRES_USER", "pyworkflow"),
|
|
67
|
+
"password": os.getenv("PYWORKFLOW_POSTGRES_PASSWORD", ""),
|
|
68
|
+
"database": os.getenv("PYWORKFLOW_POSTGRES_DATABASE", "pyworkflow"),
|
|
69
|
+
}
|
|
70
|
+
elif storage_type == "mysql":
|
|
71
|
+
return {
|
|
72
|
+
"type": "mysql",
|
|
73
|
+
"host": os.getenv("PYWORKFLOW_MYSQL_HOST", "localhost"),
|
|
74
|
+
"port": int(os.getenv("PYWORKFLOW_MYSQL_PORT", "3306")),
|
|
75
|
+
"user": os.getenv("PYWORKFLOW_MYSQL_USER", "pyworkflow"),
|
|
76
|
+
"password": os.getenv("PYWORKFLOW_MYSQL_PASSWORD", ""),
|
|
77
|
+
"database": os.getenv("PYWORKFLOW_MYSQL_DATABASE", "pyworkflow"),
|
|
78
|
+
}
|
|
79
|
+
elif storage_type == "sqlite":
|
|
80
|
+
return {
|
|
81
|
+
"type": "sqlite",
|
|
82
|
+
"base_path": os.getenv("PYWORKFLOW_STORAGE_PATH", "./pyworkflow_data/pyworkflow.db"),
|
|
83
|
+
}
|
|
84
|
+
elif storage_type == "memory":
|
|
85
|
+
return {"type": "memory"}
|
|
86
|
+
elif storage_type == "file":
|
|
87
|
+
return {
|
|
88
|
+
"type": "file",
|
|
89
|
+
"base_path": os.getenv("PYWORKFLOW_STORAGE_PATH", "./pyworkflow_data"),
|
|
90
|
+
}
|
|
91
|
+
else:
|
|
92
|
+
# Unknown type, return as-is and let config_to_storage handle it
|
|
93
|
+
return {"type": storage_type}
|
|
94
|
+
|
|
95
|
+
|
|
29
96
|
def _load_yaml_config() -> dict[str, Any]:
|
|
30
97
|
"""
|
|
31
98
|
Load configuration from pyworkflow.config.yaml in current directory.
|
|
@@ -101,23 +168,33 @@ class PyWorkflowConfig:
|
|
|
101
168
|
event_warning_interval: int = 100 # Log warning every N events after soft limit
|
|
102
169
|
|
|
103
170
|
|
|
104
|
-
def
|
|
105
|
-
"""
|
|
106
|
-
|
|
171
|
+
def _config_from_env_and_yaml() -> PyWorkflowConfig:
|
|
172
|
+
"""
|
|
173
|
+
Create a PyWorkflowConfig from environment variables and YAML file.
|
|
107
174
|
|
|
108
|
-
|
|
109
|
-
|
|
175
|
+
Priority:
|
|
176
|
+
1. Environment variables (PYWORKFLOW_*)
|
|
177
|
+
2. YAML config file (pyworkflow.config.yaml)
|
|
178
|
+
3. Defaults
|
|
179
|
+
"""
|
|
180
|
+
yaml_config = _load_yaml_config()
|
|
181
|
+
env_storage_config = _load_env_storage_config()
|
|
110
182
|
|
|
111
|
-
#
|
|
112
|
-
runtime = yaml_config.get("runtime", "local")
|
|
183
|
+
# Runtime: env var > yaml > default
|
|
184
|
+
runtime = os.getenv("PYWORKFLOW_RUNTIME") or yaml_config.get("runtime", "local")
|
|
113
185
|
durable = runtime == "celery" # Celery runtime defaults to durable
|
|
114
186
|
|
|
115
|
-
#
|
|
116
|
-
|
|
187
|
+
# Storage: env var > yaml > None
|
|
188
|
+
if env_storage_config:
|
|
189
|
+
storage = _create_storage_from_config(env_storage_config)
|
|
190
|
+
elif yaml_config.get("storage"):
|
|
191
|
+
storage = _create_storage_from_config(yaml_config.get("storage", {}))
|
|
192
|
+
else:
|
|
193
|
+
storage = None
|
|
117
194
|
|
|
118
|
-
#
|
|
195
|
+
# Celery broker: env var > yaml > None
|
|
119
196
|
celery_config = yaml_config.get("celery", {})
|
|
120
|
-
celery_broker = celery_config.get("broker")
|
|
197
|
+
celery_broker = os.getenv("PYWORKFLOW_CELERY_BROKER") or celery_config.get("broker")
|
|
121
198
|
|
|
122
199
|
return PyWorkflowConfig(
|
|
123
200
|
default_runtime=runtime,
|
|
@@ -288,16 +365,16 @@ def get_config() -> PyWorkflowConfig:
|
|
|
288
365
|
"""
|
|
289
366
|
Get the current configuration.
|
|
290
367
|
|
|
291
|
-
If not yet configured, loads from
|
|
292
|
-
|
|
368
|
+
If not yet configured, loads from environment variables and
|
|
369
|
+
pyworkflow.config.yaml (env vars take priority).
|
|
293
370
|
|
|
294
371
|
Returns:
|
|
295
372
|
Current PyWorkflowConfig instance
|
|
296
373
|
"""
|
|
297
374
|
global _config, _config_loaded_from_yaml
|
|
298
375
|
if _config is None:
|
|
299
|
-
#
|
|
300
|
-
_config =
|
|
376
|
+
# Load from env vars and YAML config file
|
|
377
|
+
_config = _config_from_env_and_yaml()
|
|
301
378
|
_config_loaded_from_yaml = True
|
|
302
379
|
return _config
|
|
303
380
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
pyworkflow/__init__.py,sha256=
|
|
2
|
-
pyworkflow/config.py,sha256=
|
|
1
|
+
pyworkflow/__init__.py,sha256=x1UEkpGJteYrluuAL54uE2I3rk2TRRcGeTuH5ZSMH7s,6281
|
|
2
|
+
pyworkflow/config.py,sha256=yw_3sJNzBanI9xIqU0kh__QL4hs3UVUBXkeCEmw5cfA,14164
|
|
3
3
|
pyworkflow/discovery.py,sha256=snW3l4nvY3Nc067TGlwtn_qdzTU9ybN7YPr8FbvY8iM,8066
|
|
4
4
|
pyworkflow/aws/__init__.py,sha256=Ak_xHcR9LTRX-CwcS0XecYmzrXZw4EM3V9aKBBDEmIk,1741
|
|
5
5
|
pyworkflow/aws/context.py,sha256=Vjyjip6U1Emg-WA5TlBaxFhcg15rf9mVJiPfT4VywHc,8217
|
|
@@ -83,9 +83,9 @@ pyworkflow/storage/sqlite.py,sha256=oBzJnnOp2uk0-U7hMTQk9QgJq3RBwXPQfrmYpivjdgE,
|
|
|
83
83
|
pyworkflow/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
84
84
|
pyworkflow/utils/duration.py,sha256=C-itmiSQQlplw7j6XB679hLF9xYGnyCwm7twO88OF8U,3978
|
|
85
85
|
pyworkflow/utils/schedule.py,sha256=dO_MkGFyfwZpb0LDlW6BGyZzlPuQIA6dc6j9nk9lc4Y,10691
|
|
86
|
-
pyworkflow_engine-0.1.
|
|
87
|
-
pyworkflow_engine-0.1.
|
|
88
|
-
pyworkflow_engine-0.1.
|
|
89
|
-
pyworkflow_engine-0.1.
|
|
90
|
-
pyworkflow_engine-0.1.
|
|
91
|
-
pyworkflow_engine-0.1.
|
|
86
|
+
pyworkflow_engine-0.1.10.dist-info/licenses/LICENSE,sha256=Y49RCTZ5ayn_yzBcRxnyIFdcMCyuYm150aty_FIznfY,1080
|
|
87
|
+
pyworkflow_engine-0.1.10.dist-info/METADATA,sha256=8mRzFtjSIFyJmSui5vzZzzl1jf8KmDM-wQ2gCRKeDbA,19628
|
|
88
|
+
pyworkflow_engine-0.1.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
89
|
+
pyworkflow_engine-0.1.10.dist-info/entry_points.txt,sha256=3IGAfuylnS39U0YX0pxnjrj54kB4iT_bNYrmsiDB-dE,51
|
|
90
|
+
pyworkflow_engine-0.1.10.dist-info/top_level.txt,sha256=FLTv9pQmLDBXrQdLOhTMIS3njFibliMsQEfumqmdzBE,11
|
|
91
|
+
pyworkflow_engine-0.1.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|