streamflow-postgresql 0.0.6__tar.gz → 0.0.8__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.6/streamflow_postgresql.egg-info → streamflow_postgresql-0.0.8}/PKG-INFO +18 -16
- {streamflow-postgresql-0.0.6 → streamflow_postgresql-0.0.8}/README.md +1 -1
- streamflow_postgresql-0.0.8/bandit-requirements.txt +1 -0
- streamflow_postgresql-0.0.8/lint-requirements.txt +5 -0
- {streamflow-postgresql-0.0.6 → streamflow_postgresql-0.0.8}/pyproject.toml +11 -7
- streamflow_postgresql-0.0.8/requirements.txt +2 -0
- {streamflow-postgresql-0.0.6/streamflow_postgresql → streamflow_postgresql-0.0.8/streamflow/plugins/unito/postgresql}/database.py +171 -73
- {streamflow-postgresql-0.0.6/streamflow_postgresql → streamflow_postgresql-0.0.8/streamflow/plugins/unito/postgresql}/plugin.py +1 -1
- {streamflow-postgresql-0.0.6/streamflow_postgresql → streamflow_postgresql-0.0.8/streamflow/plugins/unito/postgresql}/schemas/postgresql.sql +16 -8
- streamflow_postgresql-0.0.8/streamflow/plugins/unito/postgresql/version.py +1 -0
- {streamflow-postgresql-0.0.6 → streamflow_postgresql-0.0.8/streamflow_postgresql.egg-info}/PKG-INFO +18 -16
- {streamflow-postgresql-0.0.6 → streamflow_postgresql-0.0.8}/streamflow_postgresql.egg-info/SOURCES.txt +8 -6
- streamflow_postgresql-0.0.8/streamflow_postgresql.egg-info/entry_points.txt +2 -0
- streamflow_postgresql-0.0.8/streamflow_postgresql.egg-info/requires.txt +18 -0
- streamflow_postgresql-0.0.8/streamflow_postgresql.egg-info/top_level.txt +1 -0
- streamflow_postgresql-0.0.8/test-requirements.txt +4 -0
- streamflow_postgresql-0.0.8/tests/test_cwl_persistence.py +796 -0
- streamflow_postgresql-0.0.8/tests/test_database.py +44 -0
- {streamflow-postgresql-0.0.6 → streamflow_postgresql-0.0.8}/tests/test_persistence.py +66 -83
- streamflow-postgresql-0.0.6/bandit-requirements.txt +0 -1
- streamflow-postgresql-0.0.6/lint-requirements.txt +0 -4
- streamflow-postgresql-0.0.6/requirements.txt +0 -2
- streamflow-postgresql-0.0.6/streamflow_postgresql/version.py +0 -1
- streamflow-postgresql-0.0.6/streamflow_postgresql.egg-info/entry_points.txt +0 -2
- streamflow-postgresql-0.0.6/streamflow_postgresql.egg-info/requires.txt +0 -17
- streamflow-postgresql-0.0.6/streamflow_postgresql.egg-info/top_level.txt +0 -1
- streamflow-postgresql-0.0.6/test-requirements.txt +0 -4
- {streamflow-postgresql-0.0.6 → streamflow_postgresql-0.0.8}/LICENSE +0 -0
- {streamflow-postgresql-0.0.6 → streamflow_postgresql-0.0.8}/MANIFEST.in +0 -0
- {streamflow-postgresql-0.0.6 → streamflow_postgresql-0.0.8}/setup.cfg +0 -0
- {streamflow-postgresql-0.0.6/streamflow_postgresql → streamflow_postgresql-0.0.8/streamflow/plugins/unito/postgresql}/__init__.py +0 -0
- {streamflow-postgresql-0.0.6/streamflow_postgresql → streamflow_postgresql-0.0.8/streamflow/plugins/unito/postgresql}/schemas/postgresql.json +0 -0
- {streamflow-postgresql-0.0.6 → streamflow_postgresql-0.0.8}/streamflow_postgresql.egg-info/dependency_links.txt +0 -0
- {streamflow-postgresql-0.0.6 → streamflow_postgresql-0.0.8}/streamflow_postgresql.egg-info/zip-safe +0 -0
{streamflow-postgresql-0.0.6/streamflow_postgresql.egg-info → streamflow_postgresql-0.0.8}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: streamflow-postgresql
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.8
|
|
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,31 @@ 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.dev12
|
|
28
29
|
Provides-Extra: bandit
|
|
29
|
-
Requires-Dist: bandit==1.
|
|
30
|
+
Requires-Dist: bandit==1.8.3; extra == "bandit"
|
|
30
31
|
Provides-Extra: lint
|
|
31
|
-
Requires-Dist: black==
|
|
32
|
-
Requires-Dist: codespell==2.
|
|
33
|
-
Requires-Dist: flake8-bugbear==
|
|
34
|
-
Requires-Dist:
|
|
32
|
+
Requires-Dist: black==25.1.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.19.1; extra == "lint"
|
|
35
37
|
Provides-Extra: test
|
|
36
|
-
Requires-Dist: pytest==
|
|
37
|
-
Requires-Dist: pytest-asyncio==0.
|
|
38
|
-
Requires-Dist: pytest-cov==
|
|
39
|
-
Requires-Dist: pytest-xdist==3.
|
|
38
|
+
Requires-Dist: pytest==8.3.4; extra == "test"
|
|
39
|
+
Requires-Dist: pytest-asyncio==0.25.3; extra == "test"
|
|
40
|
+
Requires-Dist: pytest-cov==6.0.0; extra == "test"
|
|
41
|
+
Requires-Dist: pytest-xdist==3.6.1; extra == "test"
|
|
40
42
|
|
|
41
43
|
# PostgreSQL Plugin for StreamFlow
|
|
42
44
|
|
|
@@ -51,7 +53,7 @@ pip install streamflow-postgresql
|
|
|
51
53
|
If everything worked correctly, whenever a workflow execution start the following message should be printed in the log:
|
|
52
54
|
|
|
53
55
|
```bash
|
|
54
|
-
Successfully registered plugin
|
|
56
|
+
Successfully registered plugin streamflow.plugins.unito.postgresql.plugin.PostgreSQLStreamFlowPlugin
|
|
55
57
|
```
|
|
56
58
|
|
|
57
59
|
## 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.3
|
|
@@ -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,17 +1,18 @@
|
|
|
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
|
|
|
@@ -43,13 +44,14 @@ class PostgreSQLConnectionPool:
|
|
|
43
44
|
timeout=self.timeout,
|
|
44
45
|
max_size=self.maxsize,
|
|
45
46
|
)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
async with self._pool.acquire() as conn:
|
|
48
|
+
async with conn.transaction():
|
|
49
|
+
await conn.execute(
|
|
50
|
+
files(__package__)
|
|
51
|
+
.joinpath("schemas")
|
|
52
|
+
.joinpath("postgresql.sql")
|
|
53
|
+
.read_text("utf-8")
|
|
54
|
+
)
|
|
53
55
|
return self._pool
|
|
54
56
|
|
|
55
57
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
@@ -86,24 +88,14 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
86
88
|
await self.pool.close()
|
|
87
89
|
|
|
88
90
|
@classmethod
|
|
89
|
-
def get_schema(cls)
|
|
90
|
-
return
|
|
91
|
-
|
|
91
|
+
def get_schema(cls):
|
|
92
|
+
return (
|
|
93
|
+
files(__package__)
|
|
94
|
+
.joinpath("schemas")
|
|
95
|
+
.joinpath("postgresql.json")
|
|
96
|
+
.read_text("utf-8")
|
|
92
97
|
)
|
|
93
98
|
|
|
94
|
-
async def add_command(self, step_id: int, tag: str, cmd: str) -> int:
|
|
95
|
-
async with self.pool as pool:
|
|
96
|
-
async with pool.acquire() as conn:
|
|
97
|
-
async with conn.transaction():
|
|
98
|
-
return await conn.fetchval(
|
|
99
|
-
"INSERT INTO command(step, tag, cmd) "
|
|
100
|
-
"VALUES($1, $2, $3) "
|
|
101
|
-
"RETURNING id",
|
|
102
|
-
step_id,
|
|
103
|
-
tag,
|
|
104
|
-
cmd.encode("utf-8"),
|
|
105
|
-
)
|
|
106
|
-
|
|
107
99
|
async def add_dependency(
|
|
108
100
|
self, step: int, port: int, type: DependencyType, name: str
|
|
109
101
|
) -> None:
|
|
@@ -128,13 +120,14 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
128
120
|
external: bool,
|
|
129
121
|
lazy: bool,
|
|
130
122
|
workdir: str | None,
|
|
123
|
+
wraps: MutableMapping[str, Any] | None,
|
|
131
124
|
) -> int:
|
|
132
125
|
async with self.pool as pool:
|
|
133
126
|
async with pool.acquire() as conn:
|
|
134
127
|
async with conn.transaction():
|
|
135
128
|
return await conn.fetchval(
|
|
136
|
-
"INSERT INTO deployment(name, type, config, external, lazy, workdir) "
|
|
137
|
-
"VALUES ($1, $2, $3, $4, $5, $6) "
|
|
129
|
+
"INSERT INTO deployment(name, type, config, external, lazy, workdir, wraps) "
|
|
130
|
+
"VALUES ($1, $2, $3, $4, $5, $6, $7) "
|
|
138
131
|
"RETURNING id",
|
|
139
132
|
name,
|
|
140
133
|
type,
|
|
@@ -142,10 +135,41 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
142
135
|
external,
|
|
143
136
|
lazy,
|
|
144
137
|
workdir,
|
|
138
|
+
json.dumps(wraps),
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
async def add_execution(self, step_id: int, tag: str, cmd: str) -> int:
|
|
142
|
+
async with self.pool as pool:
|
|
143
|
+
async with pool.acquire() as conn:
|
|
144
|
+
async with conn.transaction():
|
|
145
|
+
return await conn.fetchval(
|
|
146
|
+
"INSERT INTO execution(step, tag, cmd) "
|
|
147
|
+
"VALUES($1, $2, $3) "
|
|
148
|
+
"RETURNING id",
|
|
149
|
+
step_id,
|
|
150
|
+
tag,
|
|
151
|
+
cmd.encode("utf-8"),
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
async def add_filter(self, name: str, type: str, config: str) -> int:
|
|
155
|
+
async with self.pool as pool:
|
|
156
|
+
async with pool.acquire() as conn:
|
|
157
|
+
async with conn.transaction():
|
|
158
|
+
return await conn.fetchval(
|
|
159
|
+
"INSERT INTO filter(name, type, config) "
|
|
160
|
+
"VALUES($1, $2, $3) "
|
|
161
|
+
"RETURNING id",
|
|
162
|
+
name,
|
|
163
|
+
type,
|
|
164
|
+
config,
|
|
145
165
|
)
|
|
146
166
|
|
|
147
167
|
async def add_port(
|
|
148
|
-
self,
|
|
168
|
+
self,
|
|
169
|
+
name: str,
|
|
170
|
+
workflow_id: int,
|
|
171
|
+
type: type[Port],
|
|
172
|
+
params: MutableMapping[str, Any],
|
|
149
173
|
) -> int:
|
|
150
174
|
async with self.pool as pool:
|
|
151
175
|
async with pool.acquire() as conn:
|
|
@@ -172,7 +196,12 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
172
196
|
)
|
|
173
197
|
|
|
174
198
|
async def add_step(
|
|
175
|
-
self,
|
|
199
|
+
self,
|
|
200
|
+
name: str,
|
|
201
|
+
workflow_id: int,
|
|
202
|
+
status: int,
|
|
203
|
+
type: type[Step],
|
|
204
|
+
params: MutableMapping[str, Any],
|
|
176
205
|
) -> int:
|
|
177
206
|
async with self.pool as pool:
|
|
178
207
|
async with pool.acquire() as conn:
|
|
@@ -192,7 +221,7 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
192
221
|
self,
|
|
193
222
|
deployment: int,
|
|
194
223
|
type: type[Target],
|
|
195
|
-
params: str,
|
|
224
|
+
params: MutableMapping[str, Any],
|
|
196
225
|
locations: int = 1,
|
|
197
226
|
service: str | None = None,
|
|
198
227
|
workdir: str | None = None,
|
|
@@ -228,7 +257,13 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
228
257
|
bytearray(value, "utf-8"),
|
|
229
258
|
)
|
|
230
259
|
|
|
231
|
-
async def add_workflow(
|
|
260
|
+
async def add_workflow(
|
|
261
|
+
self,
|
|
262
|
+
name: str,
|
|
263
|
+
params: MutableMapping[str, Any],
|
|
264
|
+
status: int,
|
|
265
|
+
type: type[Workflow],
|
|
266
|
+
) -> int:
|
|
232
267
|
async with self.pool as pool:
|
|
233
268
|
async with pool.acquire() as conn:
|
|
234
269
|
async with conn.transaction():
|
|
@@ -239,27 +274,56 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
239
274
|
name,
|
|
240
275
|
json.dumps(params),
|
|
241
276
|
status,
|
|
242
|
-
type,
|
|
277
|
+
utils.get_class_fullname(type),
|
|
243
278
|
)
|
|
244
279
|
|
|
245
|
-
async def
|
|
280
|
+
async def get_dependees(
|
|
281
|
+
self, token_id: int
|
|
282
|
+
) -> MutableSequence[MutableMapping[str, Any]]:
|
|
283
|
+
async with self.pool as pool:
|
|
284
|
+
async with pool.acquire() as conn:
|
|
285
|
+
return await conn.fetch(
|
|
286
|
+
"SELECT * FROM provenance WHERE depender = $1",
|
|
287
|
+
token_id,
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
async def get_dependers(
|
|
291
|
+
self, token_id: int
|
|
292
|
+
) -> MutableSequence[MutableMapping[str, Any]]:
|
|
293
|
+
async with self.pool as pool:
|
|
294
|
+
async with pool.acquire() as conn:
|
|
295
|
+
return await conn.fetch(
|
|
296
|
+
"SELECT * FROM provenance WHERE dependee = $1",
|
|
297
|
+
token_id,
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
@cachedmethod(lambda self: self.deployment_cache)
|
|
301
|
+
async def get_deployment(self, deployment_id: int) -> MutableMapping[str, Any]:
|
|
302
|
+
async with self.pool as pool:
|
|
303
|
+
async with pool.acquire() as conn:
|
|
304
|
+
return await conn.fetchrow(
|
|
305
|
+
"SELECT * FROM deployment WHERE id = $1",
|
|
306
|
+
deployment_id,
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
async def get_execution(self, execution_id: int) -> MutableMapping[str, Any]:
|
|
246
310
|
async with self.pool as pool:
|
|
247
311
|
async with pool.acquire() as conn:
|
|
248
312
|
row = await conn.fetchrow(
|
|
249
|
-
"SELECT * FROM
|
|
313
|
+
"SELECT * FROM execution WHERE id = $1", execution_id
|
|
250
314
|
)
|
|
251
315
|
return {
|
|
252
316
|
k: bytearray(v) if isinstance(v, memoryview) else v
|
|
253
317
|
for k, v in row.items()
|
|
254
318
|
}
|
|
255
319
|
|
|
256
|
-
async def
|
|
320
|
+
async def get_executions_by_step(
|
|
257
321
|
self, step_id: int
|
|
258
322
|
) -> MutableSequence[MutableMapping[str, Any]]:
|
|
259
323
|
async with self.pool as pool:
|
|
260
324
|
async with pool.acquire() as conn:
|
|
261
325
|
rows = await conn.fetch(
|
|
262
|
-
"SELECT * FROM
|
|
326
|
+
"SELECT * FROM execution WHERE step = $1", step_id
|
|
263
327
|
)
|
|
264
328
|
return [
|
|
265
329
|
{
|
|
@@ -269,35 +333,38 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
269
333
|
for row in rows
|
|
270
334
|
]
|
|
271
335
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
) -> MutableSequence[MutableMapping[str, Any]]:
|
|
336
|
+
@cachedmethod(lambda self: self.filter_cache)
|
|
337
|
+
async def get_filter(self, filter_id: int) -> MutableMapping[str, Any]:
|
|
275
338
|
async with self.pool as pool:
|
|
276
339
|
async with pool.acquire() as conn:
|
|
277
|
-
return await conn.
|
|
278
|
-
"SELECT * FROM
|
|
279
|
-
|
|
340
|
+
return await conn.fetchrow(
|
|
341
|
+
"SELECT * FROM filter WHERE id = $1",
|
|
342
|
+
filter_id,
|
|
280
343
|
)
|
|
281
344
|
|
|
282
|
-
async def
|
|
283
|
-
self,
|
|
345
|
+
async def get_input_ports(
|
|
346
|
+
self, step_id: int
|
|
284
347
|
) -> MutableSequence[MutableMapping[str, Any]]:
|
|
285
348
|
async with self.pool as pool:
|
|
286
349
|
async with pool.acquire() as conn:
|
|
287
350
|
return await conn.fetch(
|
|
288
|
-
"SELECT * FROM
|
|
289
|
-
|
|
351
|
+
"SELECT * FROM dependency WHERE step = $1 AND type = $2",
|
|
352
|
+
step_id,
|
|
353
|
+
DependencyType.INPUT.value,
|
|
290
354
|
)
|
|
291
355
|
|
|
292
|
-
async def
|
|
356
|
+
async def get_input_steps(
|
|
357
|
+
self, port_id: int
|
|
358
|
+
) -> MutableSequence[MutableMapping[str, Any]]:
|
|
293
359
|
async with self.pool as pool:
|
|
294
360
|
async with pool.acquire() as conn:
|
|
295
|
-
return await conn.
|
|
296
|
-
"SELECT * FROM
|
|
297
|
-
|
|
361
|
+
return await conn.fetch(
|
|
362
|
+
"SELECT * FROM dependency WHERE port = $1 AND type = $2",
|
|
363
|
+
port_id,
|
|
364
|
+
DependencyType.OUTPUT.value,
|
|
298
365
|
)
|
|
299
366
|
|
|
300
|
-
async def
|
|
367
|
+
async def get_output_ports(
|
|
301
368
|
self, step_id: int
|
|
302
369
|
) -> MutableSequence[MutableMapping[str, Any]]:
|
|
303
370
|
async with self.pool as pool:
|
|
@@ -305,25 +372,36 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
305
372
|
return await conn.fetch(
|
|
306
373
|
"SELECT * FROM dependency WHERE step = $1 AND type = $2",
|
|
307
374
|
step_id,
|
|
308
|
-
DependencyType.
|
|
375
|
+
DependencyType.OUTPUT.value,
|
|
309
376
|
)
|
|
310
377
|
|
|
311
|
-
async def
|
|
312
|
-
self,
|
|
378
|
+
async def get_output_steps(
|
|
379
|
+
self, port_id: int
|
|
313
380
|
) -> MutableSequence[MutableMapping[str, Any]]:
|
|
314
381
|
async with self.pool as pool:
|
|
315
382
|
async with pool.acquire() as conn:
|
|
316
383
|
return await conn.fetch(
|
|
317
|
-
"SELECT * FROM dependency WHERE
|
|
318
|
-
|
|
319
|
-
DependencyType.
|
|
384
|
+
"SELECT * FROM dependency WHERE port = $1 AND type = $2",
|
|
385
|
+
port_id,
|
|
386
|
+
DependencyType.INPUT.value,
|
|
320
387
|
)
|
|
321
388
|
|
|
389
|
+
@cachedmethod(lambda self: self.port_cache)
|
|
322
390
|
async def get_port(self, port_id: int) -> MutableMapping[str, Any]:
|
|
323
391
|
async with self.pool as pool:
|
|
324
392
|
async with pool.acquire() as conn:
|
|
325
393
|
return await conn.fetchrow("SELECT * FROM port WHERE id = $1", port_id)
|
|
326
394
|
|
|
395
|
+
async def get_port_from_token(self, token_id: int) -> MutableMapping[str, Any]:
|
|
396
|
+
async with self.pool as pool:
|
|
397
|
+
async with pool.acquire() as conn:
|
|
398
|
+
return await conn.fetchrow(
|
|
399
|
+
"SELECT port.* "
|
|
400
|
+
"FROM token JOIN port ON token.port = port.id"
|
|
401
|
+
"WHERE token.id = $1",
|
|
402
|
+
token_id,
|
|
403
|
+
)
|
|
404
|
+
|
|
327
405
|
async def get_port_tokens(self, port_id: int) -> MutableSequence[int]:
|
|
328
406
|
async with self.pool as pool:
|
|
329
407
|
async with pool.acquire() as conn:
|
|
@@ -338,7 +416,7 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
338
416
|
if last_only:
|
|
339
417
|
rows = await conn.fetch(
|
|
340
418
|
"SELECT c.id, s.name, c.start_time, c.end_time "
|
|
341
|
-
"FROM step AS s,
|
|
419
|
+
"FROM step AS s, execution AS c "
|
|
342
420
|
"WHERE s.id = c.step "
|
|
343
421
|
"AND s.workflow = ("
|
|
344
422
|
"SELECT id FROM workflow "
|
|
@@ -351,7 +429,7 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
351
429
|
async with conn.transaction():
|
|
352
430
|
cursor = conn.cursor(
|
|
353
431
|
"SELECT s.workflow, c.id, s.name, c.start_time, c.end_time "
|
|
354
|
-
"FROM step AS s,
|
|
432
|
+
"FROM step AS s, execution AS c "
|
|
355
433
|
"WHERE s.id = c.step "
|
|
356
434
|
"AND s.workflow IN (SELECT id FROM workflow WHERE name = $1) "
|
|
357
435
|
"ORDER BY s.workflow DESC",
|
|
@@ -364,11 +442,13 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
364
442
|
)
|
|
365
443
|
return list(result.values())
|
|
366
444
|
|
|
445
|
+
@cachedmethod(lambda self: self.step_cache)
|
|
367
446
|
async def get_step(self, step_id: int) -> MutableMapping[str, Any]:
|
|
368
447
|
async with self.pool as pool:
|
|
369
448
|
async with pool.acquire() as conn:
|
|
370
449
|
return await conn.fetchrow("SELECT * FROM step WHERE id = $1", step_id)
|
|
371
450
|
|
|
451
|
+
@cachedmethod(lambda self: self.target_cache)
|
|
372
452
|
async def get_target(self, target_id: int) -> MutableMapping[str, Any]:
|
|
373
453
|
async with self.pool as pool:
|
|
374
454
|
async with pool.acquire() as conn:
|
|
@@ -376,6 +456,7 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
376
456
|
"SELECT * FROM target WHERE id = $1", target_id
|
|
377
457
|
)
|
|
378
458
|
|
|
459
|
+
@cachedmethod(lambda self: self.token_cache)
|
|
379
460
|
async def get_token(self, token_id: int) -> MutableMapping[str, Any]:
|
|
380
461
|
async with self.pool as pool:
|
|
381
462
|
async with pool.acquire() as conn:
|
|
@@ -446,37 +527,54 @@ class PostgreSQLDatabase(CachedDatabase):
|
|
|
446
527
|
"ORDER BY name DESC"
|
|
447
528
|
)
|
|
448
529
|
|
|
449
|
-
async def
|
|
450
|
-
self,
|
|
530
|
+
async def update_deployment(
|
|
531
|
+
self, deployment_id: int, updates: MutableMapping[str, Any]
|
|
451
532
|
) -> int:
|
|
452
533
|
async with self.pool as pool:
|
|
453
534
|
async with pool.acquire() as conn:
|
|
454
535
|
async with conn.transaction():
|
|
455
536
|
await conn.execute(
|
|
456
|
-
"UPDATE
|
|
537
|
+
"UPDATE deployment SET {} WHERE id = $1".format( # nosec
|
|
457
538
|
", ".join([f"{k} = ${i+2}" for i, k in enumerate(updates)])
|
|
458
539
|
),
|
|
459
|
-
|
|
540
|
+
deployment_id,
|
|
460
541
|
*updates.values(),
|
|
461
542
|
)
|
|
462
|
-
self.
|
|
463
|
-
return
|
|
543
|
+
self.deployment_cache.pop(deployment_id, None)
|
|
544
|
+
return deployment_id
|
|
464
545
|
|
|
465
|
-
async def
|
|
466
|
-
self,
|
|
546
|
+
async def update_execution(
|
|
547
|
+
self, execution_id: int, updates: MutableMapping[str, Any]
|
|
467
548
|
) -> int:
|
|
468
549
|
async with self.pool as pool:
|
|
469
550
|
async with pool.acquire() as conn:
|
|
470
551
|
async with conn.transaction():
|
|
471
552
|
await conn.execute(
|
|
472
|
-
"UPDATE
|
|
553
|
+
"UPDATE execution SET {} WHERE id = $1".format( # nosec
|
|
473
554
|
", ".join([f"{k} = ${i+2}" for i, k in enumerate(updates)])
|
|
474
555
|
),
|
|
475
|
-
|
|
556
|
+
execution_id,
|
|
476
557
|
*updates.values(),
|
|
477
558
|
)
|
|
478
|
-
|
|
479
|
-
|
|
559
|
+
return execution_id
|
|
560
|
+
|
|
561
|
+
async def update_filter(
|
|
562
|
+
self, filter_id: int, updates: MutableMapping[str, Any]
|
|
563
|
+
) -> int:
|
|
564
|
+
async with self.pool as pool:
|
|
565
|
+
async with pool.acquire() as conn:
|
|
566
|
+
async with conn.transaction():
|
|
567
|
+
await conn.execute(
|
|
568
|
+
"UPDATE filter SET {} WHERE id = $1".format( # nosec
|
|
569
|
+
", ".join(
|
|
570
|
+
[f"{k} = ${i + 2}" for i, k in enumerate(updates)]
|
|
571
|
+
)
|
|
572
|
+
),
|
|
573
|
+
filter_id,
|
|
574
|
+
*updates.values(),
|
|
575
|
+
)
|
|
576
|
+
self.filter_cache.pop(filter_id, None)
|
|
577
|
+
return filter_id
|
|
480
578
|
|
|
481
579
|
async def update_port(self, port_id: int, updates: MutableMapping[str, Any]) -> int:
|
|
482
580
|
async with self.pool as pool:
|
|
@@ -1,10 +1,10 @@
|
|
|
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
|
);
|
|
@@ -43,13 +43,12 @@ CREATE TABLE IF NOT EXISTS dependency
|
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
CREATE TABLE IF NOT EXISTS
|
|
46
|
+
CREATE TABLE IF NOT EXISTS execution
|
|
47
47
|
(
|
|
48
48
|
id SERIAL PRIMARY KEY,
|
|
49
49
|
step INTEGER,
|
|
50
50
|
tag TEXT,
|
|
51
51
|
cmd TEXT,
|
|
52
|
-
output BYTEA,
|
|
53
52
|
status INTEGER,
|
|
54
53
|
start_time BIGINT,
|
|
55
54
|
end_time BIGINT,
|
|
@@ -86,7 +85,8 @@ CREATE TABLE IF NOT EXISTS deployment
|
|
|
86
85
|
config TEXT,
|
|
87
86
|
external BOOLEAN,
|
|
88
87
|
lazy BOOLEAN,
|
|
89
|
-
workdir TEXT
|
|
88
|
+
workdir TEXT,
|
|
89
|
+
wraps TEXT
|
|
90
90
|
);
|
|
91
91
|
|
|
92
92
|
|
|
@@ -101,3 +101,11 @@ CREATE TABLE IF NOT EXISTS target
|
|
|
101
101
|
params TEXT,
|
|
102
102
|
FOREIGN KEY (deployment) REFERENCES deployment (id)
|
|
103
103
|
);
|
|
104
|
+
|
|
105
|
+
CREATE TABLE IF NOT EXISTS filter
|
|
106
|
+
(
|
|
107
|
+
id SERIAL PRIMARY KEY,
|
|
108
|
+
name TEXT,
|
|
109
|
+
type TEXT,
|
|
110
|
+
config TEXT
|
|
111
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "0.0.8"
|