streamflow-postgresql 0.0.7__tar.gz → 0.0.9__tar.gz
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.
- {streamflow_postgresql-0.0.7/streamflow_postgresql.egg-info → streamflow_postgresql-0.0.9}/PKG-INFO +19 -16
- {streamflow_postgresql-0.0.7 → streamflow_postgresql-0.0.9}/README.md +1 -1
- streamflow_postgresql-0.0.9/bandit-requirements.txt +1 -0
- streamflow_postgresql-0.0.9/lint-requirements.txt +5 -0
- {streamflow_postgresql-0.0.7 → streamflow_postgresql-0.0.9}/pyproject.toml +11 -7
- streamflow_postgresql-0.0.9/requirements.txt +2 -0
- {streamflow_postgresql-0.0.7/streamflow_postgresql → streamflow_postgresql-0.0.9/streamflow/plugins/unito/postgresql}/database.py +159 -64
- {streamflow_postgresql-0.0.7/streamflow_postgresql → streamflow_postgresql-0.0.9/streamflow/plugins/unito/postgresql}/plugin.py +1 -1
- {streamflow_postgresql-0.0.7/streamflow_postgresql → streamflow_postgresql-0.0.9/streamflow/plugins/unito/postgresql}/schemas/postgresql.sql +25 -15
- streamflow_postgresql-0.0.9/streamflow/plugins/unito/postgresql/version.py +1 -0
- {streamflow_postgresql-0.0.7 → streamflow_postgresql-0.0.9/streamflow_postgresql.egg-info}/PKG-INFO +19 -16
- {streamflow_postgresql-0.0.7 → streamflow_postgresql-0.0.9}/streamflow_postgresql.egg-info/SOURCES.txt +6 -6
- streamflow_postgresql-0.0.9/streamflow_postgresql.egg-info/entry_points.txt +2 -0
- streamflow_postgresql-0.0.9/streamflow_postgresql.egg-info/requires.txt +18 -0
- streamflow_postgresql-0.0.9/streamflow_postgresql.egg-info/top_level.txt +1 -0
- streamflow_postgresql-0.0.9/test-requirements.txt +4 -0
- streamflow_postgresql-0.0.9/tests/test_cwl_persistence.py +1007 -0
- {streamflow_postgresql-0.0.7 → streamflow_postgresql-0.0.9}/tests/test_database.py +16 -25
- streamflow_postgresql-0.0.9/tests/test_persistence.py +346 -0
- streamflow_postgresql-0.0.7/bandit-requirements.txt +0 -1
- streamflow_postgresql-0.0.7/lint-requirements.txt +0 -4
- streamflow_postgresql-0.0.7/requirements.txt +0 -2
- streamflow_postgresql-0.0.7/streamflow_postgresql/version.py +0 -1
- streamflow_postgresql-0.0.7/streamflow_postgresql.egg-info/entry_points.txt +0 -2
- streamflow_postgresql-0.0.7/streamflow_postgresql.egg-info/requires.txt +0 -17
- streamflow_postgresql-0.0.7/streamflow_postgresql.egg-info/top_level.txt +0 -1
- streamflow_postgresql-0.0.7/test-requirements.txt +0 -4
- streamflow_postgresql-0.0.7/tests/test_cwl_persistence.py +0 -53
- streamflow_postgresql-0.0.7/tests/test_persistence.py +0 -336
- {streamflow_postgresql-0.0.7 → streamflow_postgresql-0.0.9}/LICENSE +0 -0
- {streamflow_postgresql-0.0.7 → streamflow_postgresql-0.0.9}/MANIFEST.in +0 -0
- {streamflow_postgresql-0.0.7 → streamflow_postgresql-0.0.9}/setup.cfg +0 -0
- {streamflow_postgresql-0.0.7/streamflow_postgresql → streamflow_postgresql-0.0.9/streamflow/plugins/unito/postgresql}/__init__.py +0 -0
- {streamflow_postgresql-0.0.7/streamflow_postgresql → streamflow_postgresql-0.0.9/streamflow/plugins/unito/postgresql}/schemas/postgresql.json +0 -0
- {streamflow_postgresql-0.0.7 → streamflow_postgresql-0.0.9}/streamflow_postgresql.egg-info/dependency_links.txt +0 -0
- {streamflow_postgresql-0.0.7 → streamflow_postgresql-0.0.9}/streamflow_postgresql.egg-info/zip-safe +0 -0
{streamflow_postgresql-0.0.7/streamflow_postgresql.egg-info → streamflow_postgresql-0.0.9}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: streamflow-postgresql
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.9
|
|
4
4
|
Summary: StreamFlow PostgreSQL plugin
|
|
5
5
|
Author-email: Iacopo Colonnelli <iacopo.colonnelli@unito.it>
|
|
6
6
|
License: LGPL-3.0-or-later
|
|
@@ -14,29 +14,32 @@ Classifier: Operating System :: POSIX
|
|
|
14
14
|
Classifier: Operating System :: MacOS
|
|
15
15
|
Classifier: Programming Language :: Python
|
|
16
16
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.9
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
22
|
Classifier: Topic :: Scientific/Engineering
|
|
22
23
|
Classifier: Topic :: System :: Distributed Computing
|
|
23
|
-
Requires-Python: >=3.
|
|
24
|
+
Requires-Python: >=3.9
|
|
24
25
|
Description-Content-Type: text/markdown
|
|
25
26
|
License-File: LICENSE
|
|
26
|
-
Requires-Dist: asyncpg==0.
|
|
27
|
-
Requires-Dist: streamflow==0.2.0.
|
|
27
|
+
Requires-Dist: asyncpg==0.30.0
|
|
28
|
+
Requires-Dist: streamflow==0.2.0.dev13
|
|
28
29
|
Provides-Extra: bandit
|
|
29
|
-
Requires-Dist: bandit==1.
|
|
30
|
+
Requires-Dist: bandit==1.8.6; extra == "bandit"
|
|
30
31
|
Provides-Extra: lint
|
|
31
|
-
Requires-Dist: black==
|
|
32
|
-
Requires-Dist: codespell==2.
|
|
33
|
-
Requires-Dist: flake8-bugbear==24.
|
|
34
|
-
Requires-Dist:
|
|
32
|
+
Requires-Dist: black==25.9.0; extra == "lint"
|
|
33
|
+
Requires-Dist: codespell==2.4.1; extra == "lint"
|
|
34
|
+
Requires-Dist: flake8-bugbear==24.12.12; extra == "lint"
|
|
35
|
+
Requires-Dist: isort==6.0.1; extra == "lint"
|
|
36
|
+
Requires-Dist: pyupgrade==3.20.0; extra == "lint"
|
|
35
37
|
Provides-Extra: test
|
|
36
|
-
Requires-Dist: pytest==8.
|
|
37
|
-
Requires-Dist: pytest-asyncio==
|
|
38
|
-
Requires-Dist: pytest-cov==
|
|
39
|
-
Requires-Dist: pytest-xdist==3.
|
|
38
|
+
Requires-Dist: pytest==8.4.2; extra == "test"
|
|
39
|
+
Requires-Dist: pytest-asyncio==1.2.0; extra == "test"
|
|
40
|
+
Requires-Dist: pytest-cov==7.0.0; extra == "test"
|
|
41
|
+
Requires-Dist: pytest-xdist==3.8.0; extra == "test"
|
|
42
|
+
Dynamic: license-file
|
|
40
43
|
|
|
41
44
|
# PostgreSQL Plugin for StreamFlow
|
|
42
45
|
|
|
@@ -51,7 +54,7 @@ pip install streamflow-postgresql
|
|
|
51
54
|
If everything worked correctly, whenever a workflow execution start the following message should be printed in the log:
|
|
52
55
|
|
|
53
56
|
```bash
|
|
54
|
-
Successfully registered plugin
|
|
57
|
+
Successfully registered plugin streamflow.plugins.unito.postgresql.plugin.PostgreSQLStreamFlowPlugin
|
|
55
58
|
```
|
|
56
59
|
|
|
57
60
|
## Usage
|
|
@@ -11,7 +11,7 @@ pip install streamflow-postgresql
|
|
|
11
11
|
If everything worked correctly, whenever a workflow execution start the following message should be printed in the log:
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
Successfully registered plugin
|
|
14
|
+
Successfully registered plugin streamflow.plugins.unito.postgresql.plugin.PostgreSQLStreamFlowPlugin
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bandit==1.8.6
|
|
@@ -9,7 +9,7 @@ authors = [
|
|
|
9
9
|
]
|
|
10
10
|
description = "StreamFlow PostgreSQL plugin"
|
|
11
11
|
readme = "README.md"
|
|
12
|
-
requires-python = ">=3.
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
13
|
license = {text = "LGPL-3.0-or-later"}
|
|
14
14
|
classifiers = [
|
|
15
15
|
"Development Status :: 3 - Alpha",
|
|
@@ -20,10 +20,11 @@ classifiers = [
|
|
|
20
20
|
"Operating System :: MacOS",
|
|
21
21
|
"Programming Language :: Python",
|
|
22
22
|
"Programming Language :: Python :: 3 :: Only",
|
|
23
|
-
"Programming Language :: Python :: 3.8",
|
|
24
23
|
"Programming Language :: Python :: 3.9",
|
|
25
24
|
"Programming Language :: Python :: 3.10",
|
|
26
25
|
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
27
28
|
"Topic :: Scientific/Engineering",
|
|
28
29
|
"Topic :: System :: Distributed Computing",
|
|
29
30
|
]
|
|
@@ -34,22 +35,25 @@ Package = "https://pypi.org/project/streamflow-postgresql"
|
|
|
34
35
|
Repository = "https://github.com/alpha-unito/streamflow-postgresql"
|
|
35
36
|
|
|
36
37
|
[project.entry-points]
|
|
37
|
-
"unito.streamflow.plugin" = {"unito.postgresql" = "
|
|
38
|
+
"unito.streamflow.plugin" = {"unito.postgresql" = "streamflow.plugins.unito.postgresql.plugin:PostgreSQLStreamFlowPlugin"}
|
|
38
39
|
|
|
39
40
|
[tool.setuptools]
|
|
40
41
|
packages = [
|
|
41
|
-
"
|
|
42
|
+
"streamflow.plugins.unito.postgresql"
|
|
42
43
|
]
|
|
43
44
|
zip-safe = true
|
|
44
45
|
|
|
45
46
|
[tool.setuptools.package-data]
|
|
46
|
-
"
|
|
47
|
+
"streamflow.plugins.unito.postgresql" = ["schemas/*.json", "schemas/*.sql"]
|
|
47
48
|
|
|
48
49
|
[tool.setuptools.dynamic]
|
|
49
50
|
dependencies = {file = "requirements.txt"}
|
|
50
|
-
version = {attr = "
|
|
51
|
+
version = {attr = "streamflow.plugins.unito.postgresql.version.VERSION"}
|
|
51
52
|
|
|
52
53
|
[tool.setuptools.dynamic.optional-dependencies]
|
|
53
54
|
bandit = {file = "bandit-requirements.txt"}
|
|
54
55
|
lint = {file = "lint-requirements.txt"}
|
|
55
|
-
test = {file = "test-requirements.txt"}
|
|
56
|
+
test = {file = "test-requirements.txt"}
|
|
57
|
+
|
|
58
|
+
[tool.isort]
|
|
59
|
+
profile = "black"
|
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
|
-
import
|
|
5
|
-
from
|
|
4
|
+
from collections.abc import MutableMapping, MutableSequence
|
|
5
|
+
from importlib.resources import files
|
|
6
|
+
from typing import Any
|
|
6
7
|
|
|
7
8
|
import asyncpg
|
|
8
|
-
import pkg_resources
|
|
9
9
|
from streamflow.core import utils
|
|
10
|
+
from streamflow.core.asyncache import cachedmethod
|
|
10
11
|
from streamflow.core.context import StreamFlowContext
|
|
11
12
|
from streamflow.core.deployment import Target
|
|
12
13
|
from streamflow.core.persistence import DependencyType
|
|
13
14
|
from streamflow.core.utils import get_date_from_ns
|
|
14
|
-
from streamflow.core.workflow import Port, Status, Step, Token
|
|
15
|
+
from streamflow.core.workflow import Port, Status, Step, Token, Workflow
|
|
15
16
|
from streamflow.persistence.base import CachedDatabase
|
|
16
17
|
|
|
17
18
|
|
|
19
|
+
def _load_keys(
|
|
20
|
+
row: MutableMapping[str, Any], keys: MutableSequence[str] | None = None
|
|
21
|
+
) -> MutableMapping[str, Any]:
|
|
22
|
+
for key in keys or ["params"]:
|
|
23
|
+
row[key] = json.loads(row[key])
|
|
24
|
+
return row
|
|
25
|
+
|
|
26
|
+
|
|
18
27
|
class PostgreSQLConnectionPool:
|
|
19
28
|
def __init__(
|
|
20
29
|
self,
|
|
@@ -43,13 +52,14 @@ class PostgreSQLConnectionPool:
|
|
|
43
52
|
timeout=self.timeout,
|
|
44
53
|
max_size=self.maxsize,
|
|
45
54
|
)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
async with self._pool.acquire() as conn:
|
|
56
|
+
async with conn.transaction():
|
|
57
|
+
await conn.execute(
|
|
58
|
+
files(__package__)
|
|
59
|
+
.joinpath("schemas")
|
|
60
|
+
.joinpath("postgresql.sql")
|
|
61
|
+
.read_text("utf-8")
|
|
62
|
+
)
|
|
53
63
|
return self._pool
|
|
54
64
|
|
|
55
65
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
@@ -86,9 +96,12 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
86
96
|
await self.pool.close()
|
|
87
97
|
|
|
88
98
|
@classmethod
|
|
89
|
-
def get_schema(cls)
|
|
90
|
-
return
|
|
91
|
-
|
|
99
|
+
def get_schema(cls):
|
|
100
|
+
return (
|
|
101
|
+
files(__package__)
|
|
102
|
+
.joinpath("schemas")
|
|
103
|
+
.joinpath("postgresql.json")
|
|
104
|
+
.read_text("utf-8")
|
|
92
105
|
)
|
|
93
106
|
|
|
94
107
|
async def add_dependency(
|
|
@@ -111,9 +124,10 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
111
124
|
self,
|
|
112
125
|
name: str,
|
|
113
126
|
type: str,
|
|
114
|
-
config: str,
|
|
127
|
+
config: MutableMapping[str, Any],
|
|
115
128
|
external: bool,
|
|
116
129
|
lazy: bool,
|
|
130
|
+
scheduling_policy: MutableMapping[str, Any],
|
|
117
131
|
workdir: str | None,
|
|
118
132
|
wraps: MutableMapping[str, Any] | None,
|
|
119
133
|
) -> int:
|
|
@@ -121,16 +135,17 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
121
135
|
async with pool.acquire() as conn:
|
|
122
136
|
async with conn.transaction():
|
|
123
137
|
return await conn.fetchval(
|
|
124
|
-
"INSERT INTO deployment(name, type, config, external, lazy, workdir, wraps) "
|
|
125
|
-
"VALUES ($1, $2, $3, $4, $5, $6, $7) "
|
|
138
|
+
"INSERT INTO deployment(name, type, config, external, lazy, scheduling_policy, workdir, wraps) "
|
|
139
|
+
"VALUES ($1, $2, $3, $4, $5, $6, $7, $8) "
|
|
126
140
|
"RETURNING id",
|
|
127
141
|
name,
|
|
128
142
|
type,
|
|
129
|
-
config,
|
|
143
|
+
json.dumps(config),
|
|
130
144
|
external,
|
|
131
145
|
lazy,
|
|
146
|
+
json.dumps(scheduling_policy),
|
|
132
147
|
workdir,
|
|
133
|
-
json.dumps(wraps),
|
|
148
|
+
json.dumps(wraps) if wraps else None,
|
|
134
149
|
)
|
|
135
150
|
|
|
136
151
|
async def add_execution(self, step_id: int, tag: str, cmd: str) -> int:
|
|
@@ -146,7 +161,9 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
146
161
|
cmd.encode("utf-8"),
|
|
147
162
|
)
|
|
148
163
|
|
|
149
|
-
async def add_filter(
|
|
164
|
+
async def add_filter(
|
|
165
|
+
self, name: str, type: str, config: MutableMapping[str, Any]
|
|
166
|
+
) -> int:
|
|
150
167
|
async with self.pool as pool:
|
|
151
168
|
async with pool.acquire() as conn:
|
|
152
169
|
async with conn.transaction():
|
|
@@ -156,11 +173,15 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
156
173
|
"RETURNING id",
|
|
157
174
|
name,
|
|
158
175
|
type,
|
|
159
|
-
config,
|
|
176
|
+
json.dumps(config),
|
|
160
177
|
)
|
|
161
178
|
|
|
162
179
|
async def add_port(
|
|
163
|
-
self,
|
|
180
|
+
self,
|
|
181
|
+
name: str,
|
|
182
|
+
workflow_id: int,
|
|
183
|
+
type: type[Port],
|
|
184
|
+
params: MutableMapping[str, Any],
|
|
164
185
|
) -> int:
|
|
165
186
|
async with self.pool as pool:
|
|
166
187
|
async with pool.acquire() as conn:
|
|
@@ -187,7 +208,12 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
187
208
|
)
|
|
188
209
|
|
|
189
210
|
async def add_step(
|
|
190
|
-
self,
|
|
211
|
+
self,
|
|
212
|
+
name: str,
|
|
213
|
+
workflow_id: int,
|
|
214
|
+
status: int,
|
|
215
|
+
type: type[Step],
|
|
216
|
+
params: MutableMapping[str, Any],
|
|
191
217
|
) -> int:
|
|
192
218
|
async with self.pool as pool:
|
|
193
219
|
async with pool.acquire() as conn:
|
|
@@ -207,7 +233,7 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
207
233
|
self,
|
|
208
234
|
deployment: int,
|
|
209
235
|
type: type[Target],
|
|
210
|
-
params: str,
|
|
236
|
+
params: MutableMapping[str, Any],
|
|
211
237
|
locations: int = 1,
|
|
212
238
|
service: str | None = None,
|
|
213
239
|
workdir: str | None = None,
|
|
@@ -228,22 +254,38 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
228
254
|
)
|
|
229
255
|
|
|
230
256
|
async def add_token(
|
|
231
|
-
self,
|
|
257
|
+
self,
|
|
258
|
+
tag: str,
|
|
259
|
+
type: type[Token],
|
|
260
|
+
value: Any,
|
|
261
|
+
port: int | None = None,
|
|
262
|
+
recoverable: bool = False,
|
|
232
263
|
) -> int:
|
|
233
264
|
async with self.pool as pool:
|
|
234
265
|
async with pool.acquire() as conn:
|
|
235
266
|
async with conn.transaction():
|
|
236
|
-
|
|
267
|
+
token_id = await conn.fetchval(
|
|
237
268
|
"INSERT INTO token(port, type, tag, value) "
|
|
238
269
|
"VALUES($1, $2, $3, $4) "
|
|
239
270
|
"RETURNING id",
|
|
240
271
|
port,
|
|
241
272
|
utils.get_class_fullname(type),
|
|
242
273
|
tag,
|
|
243
|
-
bytearray(value, "utf-8"),
|
|
274
|
+
bytearray(json.dumps(value), "utf-8"),
|
|
244
275
|
)
|
|
276
|
+
if recoverable:
|
|
277
|
+
await conn.fetchval(
|
|
278
|
+
"INSERT INTO recoverable(id) VALUES($1)", token_id
|
|
279
|
+
)
|
|
280
|
+
return token_id
|
|
245
281
|
|
|
246
|
-
async def add_workflow(
|
|
282
|
+
async def add_workflow(
|
|
283
|
+
self,
|
|
284
|
+
name: str,
|
|
285
|
+
params: MutableMapping[str, Any],
|
|
286
|
+
status: int,
|
|
287
|
+
type: type[Workflow],
|
|
288
|
+
) -> int:
|
|
247
289
|
async with self.pool as pool:
|
|
248
290
|
async with pool.acquire() as conn:
|
|
249
291
|
async with conn.transaction():
|
|
@@ -254,7 +296,7 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
254
296
|
name,
|
|
255
297
|
json.dumps(params),
|
|
256
298
|
status,
|
|
257
|
-
type,
|
|
299
|
+
utils.get_class_fullname(type),
|
|
258
300
|
)
|
|
259
301
|
|
|
260
302
|
async def get_dependees(
|
|
@@ -277,13 +319,21 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
277
319
|
token_id,
|
|
278
320
|
)
|
|
279
321
|
|
|
280
|
-
|
|
322
|
+
@cachedmethod(lambda self: self.deployment_cache)
|
|
323
|
+
async def get_deployment(self, deployment_id: int) -> MutableMapping[str, Any]:
|
|
281
324
|
async with self.pool as pool:
|
|
282
325
|
async with pool.acquire() as conn:
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
326
|
+
row = _load_keys(
|
|
327
|
+
dict(
|
|
328
|
+
await conn.fetchrow(
|
|
329
|
+
"SELECT * FROM deployment WHERE id = $1",
|
|
330
|
+
deployment_id,
|
|
331
|
+
)
|
|
332
|
+
),
|
|
333
|
+
["config", "scheduling_policy"],
|
|
286
334
|
)
|
|
335
|
+
row["wraps"] = json.loads(row["wraps"]) if row["wraps"] else None
|
|
336
|
+
return row
|
|
287
337
|
|
|
288
338
|
async def get_execution(self, execution_id: int) -> MutableMapping[str, Any]:
|
|
289
339
|
async with self.pool as pool:
|
|
@@ -312,12 +362,18 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
312
362
|
for row in rows
|
|
313
363
|
]
|
|
314
364
|
|
|
365
|
+
@cachedmethod(lambda self: self.filter_cache)
|
|
315
366
|
async def get_filter(self, filter_id: int) -> MutableMapping[str, Any]:
|
|
316
367
|
async with self.pool as pool:
|
|
317
368
|
async with pool.acquire() as conn:
|
|
318
|
-
return
|
|
319
|
-
|
|
320
|
-
|
|
369
|
+
return _load_keys(
|
|
370
|
+
dict(
|
|
371
|
+
await conn.fetchrow(
|
|
372
|
+
"SELECT * FROM filter WHERE id = $1",
|
|
373
|
+
filter_id,
|
|
374
|
+
)
|
|
375
|
+
),
|
|
376
|
+
["config"],
|
|
321
377
|
)
|
|
322
378
|
|
|
323
379
|
async def get_input_ports(
|
|
@@ -364,19 +420,28 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
364
420
|
DependencyType.INPUT.value,
|
|
365
421
|
)
|
|
366
422
|
|
|
423
|
+
@cachedmethod(lambda self: self.port_cache)
|
|
367
424
|
async def get_port(self, port_id: int) -> MutableMapping[str, Any]:
|
|
368
425
|
async with self.pool as pool:
|
|
369
426
|
async with pool.acquire() as conn:
|
|
370
|
-
return
|
|
427
|
+
return _load_keys(
|
|
428
|
+
dict(
|
|
429
|
+
await conn.fetchrow("SELECT * FROM port WHERE id = $1", port_id)
|
|
430
|
+
)
|
|
431
|
+
)
|
|
371
432
|
|
|
372
433
|
async def get_port_from_token(self, token_id: int) -> MutableMapping[str, Any]:
|
|
373
434
|
async with self.pool as pool:
|
|
374
435
|
async with pool.acquire() as conn:
|
|
375
|
-
return
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
436
|
+
return _load_keys(
|
|
437
|
+
dict(
|
|
438
|
+
await conn.fetchrow(
|
|
439
|
+
"SELECT port.* "
|
|
440
|
+
"FROM token JOIN port ON token.port = port.id"
|
|
441
|
+
"WHERE token.id = $1",
|
|
442
|
+
token_id,
|
|
443
|
+
)
|
|
444
|
+
)
|
|
380
445
|
)
|
|
381
446
|
|
|
382
447
|
async def get_port_tokens(self, port_id: int) -> MutableSequence[int]:
|
|
@@ -419,32 +484,54 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
419
484
|
)
|
|
420
485
|
return list(result.values())
|
|
421
486
|
|
|
487
|
+
@cachedmethod(lambda self: self.step_cache)
|
|
422
488
|
async def get_step(self, step_id: int) -> MutableMapping[str, Any]:
|
|
423
489
|
async with self.pool as pool:
|
|
424
490
|
async with pool.acquire() as conn:
|
|
425
|
-
return
|
|
491
|
+
return _load_keys(
|
|
492
|
+
dict(
|
|
493
|
+
await conn.fetchrow("SELECT * FROM step WHERE id = $1", step_id)
|
|
494
|
+
)
|
|
495
|
+
)
|
|
426
496
|
|
|
497
|
+
@cachedmethod(lambda self: self.target_cache)
|
|
427
498
|
async def get_target(self, target_id: int) -> MutableMapping[str, Any]:
|
|
428
499
|
async with self.pool as pool:
|
|
429
500
|
async with pool.acquire() as conn:
|
|
430
|
-
return
|
|
431
|
-
|
|
501
|
+
return _load_keys(
|
|
502
|
+
dict(
|
|
503
|
+
await conn.fetchrow(
|
|
504
|
+
"SELECT * FROM target WHERE id = $1", target_id
|
|
505
|
+
)
|
|
506
|
+
)
|
|
432
507
|
)
|
|
433
508
|
|
|
509
|
+
@cachedmethod(lambda self: self.token_cache)
|
|
434
510
|
async def get_token(self, token_id: int) -> MutableMapping[str, Any]:
|
|
435
511
|
async with self.pool as pool:
|
|
436
512
|
async with pool.acquire() as conn:
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
513
|
+
return _load_keys(
|
|
514
|
+
dict(
|
|
515
|
+
await conn.fetchrow(
|
|
516
|
+
"SELECT *, "
|
|
517
|
+
"EXISTS(SELECT 1 FROM recoverable AS r WHERE r.id =$1) AS recoverable "
|
|
518
|
+
"FROM token "
|
|
519
|
+
"WHERE id =$1",
|
|
520
|
+
token_id,
|
|
521
|
+
)
|
|
522
|
+
),
|
|
523
|
+
["value"],
|
|
524
|
+
)
|
|
442
525
|
|
|
443
526
|
async def get_workflow(self, workflow_id: int) -> MutableMapping[str, Any]:
|
|
444
527
|
async with self.pool as pool:
|
|
445
528
|
async with pool.acquire() as conn:
|
|
446
|
-
return
|
|
447
|
-
|
|
529
|
+
return _load_keys(
|
|
530
|
+
dict(
|
|
531
|
+
await conn.fetchrow(
|
|
532
|
+
"SELECT * FROM workflow WHERE id = $1", workflow_id
|
|
533
|
+
)
|
|
534
|
+
)
|
|
448
535
|
)
|
|
449
536
|
|
|
450
537
|
async def get_workflow_ports(
|
|
@@ -452,20 +539,26 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
452
539
|
) -> MutableSequence[MutableMapping[str, Any]]:
|
|
453
540
|
async with self.pool as pool:
|
|
454
541
|
async with pool.acquire() as conn:
|
|
455
|
-
return
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
542
|
+
return [
|
|
543
|
+
_load_keys(dict(r))
|
|
544
|
+
for r in await conn.fetch(
|
|
545
|
+
"SELECT * FROM port WHERE workflow = $1",
|
|
546
|
+
workflow_id,
|
|
547
|
+
)
|
|
548
|
+
]
|
|
459
549
|
|
|
460
550
|
async def get_workflow_steps(
|
|
461
551
|
self, workflow_id: int
|
|
462
552
|
) -> MutableSequence[MutableMapping[str, Any]]:
|
|
463
553
|
async with self.pool as pool:
|
|
464
554
|
async with pool.acquire() as conn:
|
|
465
|
-
return
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
555
|
+
return [
|
|
556
|
+
_load_keys(dict(r))
|
|
557
|
+
for r in await conn.fetch(
|
|
558
|
+
"SELECT * FROM step WHERE workflow = $1",
|
|
559
|
+
workflow_id,
|
|
560
|
+
)
|
|
561
|
+
]
|
|
469
562
|
|
|
470
563
|
async def get_workflows_by_name(
|
|
471
564
|
self, workflow_name: str, last_only: bool = False
|
|
@@ -474,9 +567,12 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
474
567
|
async with pool.acquire() as conn:
|
|
475
568
|
query = "SELECT * FROM workflow WHERE name = $1 ORDER BY id desc"
|
|
476
569
|
return (
|
|
477
|
-
[conn.fetchrow(query, workflow_name)]
|
|
570
|
+
[_load_keys(dict(await conn.fetchrow(query, workflow_name)))]
|
|
478
571
|
if last_only
|
|
479
|
-
else
|
|
572
|
+
else [
|
|
573
|
+
_load_keys(dict(r))
|
|
574
|
+
for r in await conn.fetch(query, workflow_name)
|
|
575
|
+
]
|
|
480
576
|
)
|
|
481
577
|
|
|
482
578
|
async def get_workflows_list(
|
|
@@ -514,7 +610,7 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
514
610
|
deployment_id,
|
|
515
611
|
*updates.values(),
|
|
516
612
|
)
|
|
517
|
-
self.
|
|
613
|
+
self.deployment_cache.pop(deployment_id, None)
|
|
518
614
|
return deployment_id
|
|
519
615
|
|
|
520
616
|
async def update_execution(
|
|
@@ -530,7 +626,6 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
530
626
|
execution_id,
|
|
531
627
|
*updates.values(),
|
|
532
628
|
)
|
|
533
|
-
self.port_cache.pop(execution_id, None)
|
|
534
629
|
return execution_id
|
|
535
630
|
|
|
536
631
|
async def update_filter(
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
CREATE TABLE IF NOT EXISTS workflow
|
|
2
2
|
(
|
|
3
|
-
id
|
|
4
|
-
name
|
|
5
|
-
params
|
|
6
|
-
status
|
|
7
|
-
type
|
|
3
|
+
id SERIAL PRIMARY KEY,
|
|
4
|
+
name TEXT,
|
|
5
|
+
params TEXT,
|
|
6
|
+
status INTEGER,
|
|
7
|
+
type TEXT,
|
|
8
8
|
start_time BIGINT,
|
|
9
9
|
end_time BIGINT
|
|
10
10
|
);
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
CREATE TABLE IF NOT EXISTS step
|
|
13
14
|
(
|
|
14
15
|
id SERIAL PRIMARY KEY,
|
|
@@ -20,6 +21,7 @@ CREATE TABLE IF NOT EXISTS step
|
|
|
20
21
|
FOREIGN KEY (workflow) REFERENCES workflow (id)
|
|
21
22
|
);
|
|
22
23
|
|
|
24
|
+
|
|
23
25
|
CREATE TABLE IF NOT EXISTS port
|
|
24
26
|
(
|
|
25
27
|
id SERIAL PRIMARY KEY,
|
|
@@ -47,9 +49,8 @@ CREATE TABLE IF NOT EXISTS execution
|
|
|
47
49
|
(
|
|
48
50
|
id SERIAL PRIMARY KEY,
|
|
49
51
|
step INTEGER,
|
|
50
|
-
|
|
52
|
+
job_token INTEGER,
|
|
51
53
|
cmd TEXT,
|
|
52
|
-
output BYTEA,
|
|
53
54
|
status INTEGER,
|
|
54
55
|
start_time BIGINT,
|
|
55
56
|
end_time BIGINT,
|
|
@@ -80,14 +81,15 @@ CREATE TABLE IF NOT EXISTS provenance
|
|
|
80
81
|
|
|
81
82
|
CREATE TABLE IF NOT EXISTS deployment
|
|
82
83
|
(
|
|
83
|
-
id
|
|
84
|
-
name
|
|
85
|
-
type
|
|
86
|
-
config
|
|
87
|
-
external
|
|
88
|
-
lazy
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
id SERIAL PRIMARY KEY,
|
|
85
|
+
name TEXT,
|
|
86
|
+
type TEXT,
|
|
87
|
+
config TEXT,
|
|
88
|
+
external BOOLEAN,
|
|
89
|
+
lazy BOOLEAN,
|
|
90
|
+
scheduling_policy TEXT,
|
|
91
|
+
workdir TEXT,
|
|
92
|
+
wraps TEXT
|
|
91
93
|
);
|
|
92
94
|
|
|
93
95
|
|
|
@@ -103,6 +105,14 @@ CREATE TABLE IF NOT EXISTS target
|
|
|
103
105
|
FOREIGN KEY (deployment) REFERENCES deployment (id)
|
|
104
106
|
);
|
|
105
107
|
|
|
108
|
+
|
|
109
|
+
CREATE TABLE IF NOT EXISTS recoverable
|
|
110
|
+
(
|
|
111
|
+
id SERIAL PRIMARY KEY,
|
|
112
|
+
FOREIGN KEY (id) REFERENCES token (id)
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
|
|
106
116
|
CREATE TABLE IF NOT EXISTS filter
|
|
107
117
|
(
|
|
108
118
|
id SERIAL PRIMARY KEY,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "0.0.9"
|