streamflow-postgresql 0.0.8__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.
Files changed (32) hide show
  1. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/PKG-INFO +11 -10
  2. streamflow_postgresql-0.0.9/bandit-requirements.txt +1 -0
  3. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/lint-requirements.txt +2 -2
  4. streamflow_postgresql-0.0.9/requirements.txt +2 -0
  5. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/streamflow/plugins/unito/postgresql/database.py +112 -42
  6. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/streamflow/plugins/unito/postgresql/schemas/postgresql.sql +20 -9
  7. streamflow_postgresql-0.0.9/streamflow/plugins/unito/postgresql/version.py +1 -0
  8. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/streamflow_postgresql.egg-info/PKG-INFO +11 -10
  9. streamflow_postgresql-0.0.9/streamflow_postgresql.egg-info/requires.txt +18 -0
  10. streamflow_postgresql-0.0.9/test-requirements.txt +4 -0
  11. streamflow_postgresql-0.0.9/tests/test_cwl_persistence.py +1007 -0
  12. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/tests/test_persistence.py +150 -120
  13. streamflow_postgresql-0.0.8/bandit-requirements.txt +0 -1
  14. streamflow_postgresql-0.0.8/requirements.txt +0 -2
  15. streamflow_postgresql-0.0.8/streamflow/plugins/unito/postgresql/version.py +0 -1
  16. streamflow_postgresql-0.0.8/streamflow_postgresql.egg-info/requires.txt +0 -18
  17. streamflow_postgresql-0.0.8/test-requirements.txt +0 -4
  18. streamflow_postgresql-0.0.8/tests/test_cwl_persistence.py +0 -796
  19. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/LICENSE +0 -0
  20. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/MANIFEST.in +0 -0
  21. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/README.md +0 -0
  22. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/pyproject.toml +0 -0
  23. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/setup.cfg +0 -0
  24. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/streamflow/plugins/unito/postgresql/__init__.py +0 -0
  25. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/streamflow/plugins/unito/postgresql/plugin.py +0 -0
  26. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/streamflow/plugins/unito/postgresql/schemas/postgresql.json +0 -0
  27. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/streamflow_postgresql.egg-info/SOURCES.txt +0 -0
  28. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/streamflow_postgresql.egg-info/dependency_links.txt +0 -0
  29. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/streamflow_postgresql.egg-info/entry_points.txt +0 -0
  30. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/streamflow_postgresql.egg-info/top_level.txt +0 -0
  31. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/streamflow_postgresql.egg-info/zip-safe +0 -0
  32. {streamflow_postgresql-0.0.8 → streamflow_postgresql-0.0.9}/tests/test_database.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: streamflow-postgresql
3
- Version: 0.0.8
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
@@ -25,20 +25,21 @@ Requires-Python: >=3.9
25
25
  Description-Content-Type: text/markdown
26
26
  License-File: LICENSE
27
27
  Requires-Dist: asyncpg==0.30.0
28
- Requires-Dist: streamflow==0.2.0.dev12
28
+ Requires-Dist: streamflow==0.2.0.dev13
29
29
  Provides-Extra: bandit
30
- Requires-Dist: bandit==1.8.3; extra == "bandit"
30
+ Requires-Dist: bandit==1.8.6; extra == "bandit"
31
31
  Provides-Extra: lint
32
- Requires-Dist: black==25.1.0; extra == "lint"
32
+ Requires-Dist: black==25.9.0; extra == "lint"
33
33
  Requires-Dist: codespell==2.4.1; extra == "lint"
34
34
  Requires-Dist: flake8-bugbear==24.12.12; extra == "lint"
35
35
  Requires-Dist: isort==6.0.1; extra == "lint"
36
- Requires-Dist: pyupgrade==3.19.1; extra == "lint"
36
+ Requires-Dist: pyupgrade==3.20.0; extra == "lint"
37
37
  Provides-Extra: test
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"
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
42
43
 
43
44
  # PostgreSQL Plugin for StreamFlow
44
45
 
@@ -0,0 +1 @@
1
+ bandit==1.8.6
@@ -1,5 +1,5 @@
1
- black==25.1.0
1
+ black==25.9.0
2
2
  codespell==2.4.1
3
3
  flake8-bugbear==24.12.12
4
4
  isort==6.0.1
5
- pyupgrade==3.19.1
5
+ pyupgrade==3.20.0
@@ -0,0 +1,2 @@
1
+ asyncpg==0.30.0
2
+ streamflow==0.2.0.dev13
@@ -16,6 +16,14 @@ from streamflow.core.workflow import Port, Status, Step, Token, Workflow
16
16
  from streamflow.persistence.base import CachedDatabase
17
17
 
18
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
+
19
27
  class PostgreSQLConnectionPool:
20
28
  def __init__(
21
29
  self,
@@ -116,9 +124,10 @@ class PostgreSQLDatabase(CachedDatabase):
116
124
  self,
117
125
  name: str,
118
126
  type: str,
119
- config: str,
127
+ config: MutableMapping[str, Any],
120
128
  external: bool,
121
129
  lazy: bool,
130
+ scheduling_policy: MutableMapping[str, Any],
122
131
  workdir: str | None,
123
132
  wraps: MutableMapping[str, Any] | None,
124
133
  ) -> int:
@@ -126,16 +135,17 @@ class PostgreSQLDatabase(CachedDatabase):
126
135
  async with pool.acquire() as conn:
127
136
  async with conn.transaction():
128
137
  return await conn.fetchval(
129
- "INSERT INTO deployment(name, type, config, external, lazy, workdir, wraps) "
130
- "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) "
131
140
  "RETURNING id",
132
141
  name,
133
142
  type,
134
- config,
143
+ json.dumps(config),
135
144
  external,
136
145
  lazy,
146
+ json.dumps(scheduling_policy),
137
147
  workdir,
138
- json.dumps(wraps),
148
+ json.dumps(wraps) if wraps else None,
139
149
  )
140
150
 
141
151
  async def add_execution(self, step_id: int, tag: str, cmd: str) -> int:
@@ -151,7 +161,9 @@ class PostgreSQLDatabase(CachedDatabase):
151
161
  cmd.encode("utf-8"),
152
162
  )
153
163
 
154
- async def add_filter(self, name: str, type: str, config: str) -> int:
164
+ async def add_filter(
165
+ self, name: str, type: str, config: MutableMapping[str, Any]
166
+ ) -> int:
155
167
  async with self.pool as pool:
156
168
  async with pool.acquire() as conn:
157
169
  async with conn.transaction():
@@ -161,7 +173,7 @@ class PostgreSQLDatabase(CachedDatabase):
161
173
  "RETURNING id",
162
174
  name,
163
175
  type,
164
- config,
176
+ json.dumps(config),
165
177
  )
166
178
 
167
179
  async def add_port(
@@ -242,20 +254,30 @@ class PostgreSQLDatabase(CachedDatabase):
242
254
  )
243
255
 
244
256
  async def add_token(
245
- self, tag: str, type: type[Token], value: Any, port: int | None = None
257
+ self,
258
+ tag: str,
259
+ type: type[Token],
260
+ value: Any,
261
+ port: int | None = None,
262
+ recoverable: bool = False,
246
263
  ) -> int:
247
264
  async with self.pool as pool:
248
265
  async with pool.acquire() as conn:
249
266
  async with conn.transaction():
250
- return await conn.fetchval(
267
+ token_id = await conn.fetchval(
251
268
  "INSERT INTO token(port, type, tag, value) "
252
269
  "VALUES($1, $2, $3, $4) "
253
270
  "RETURNING id",
254
271
  port,
255
272
  utils.get_class_fullname(type),
256
273
  tag,
257
- bytearray(value, "utf-8"),
274
+ bytearray(json.dumps(value), "utf-8"),
258
275
  )
276
+ if recoverable:
277
+ await conn.fetchval(
278
+ "INSERT INTO recoverable(id) VALUES($1)", token_id
279
+ )
280
+ return token_id
259
281
 
260
282
  async def add_workflow(
261
283
  self,
@@ -301,10 +323,17 @@ class PostgreSQLDatabase(CachedDatabase):
301
323
  async def get_deployment(self, deployment_id: int) -> MutableMapping[str, Any]:
302
324
  async with self.pool as pool:
303
325
  async with pool.acquire() as conn:
304
- return await conn.fetchrow(
305
- "SELECT * FROM deployment WHERE id = $1",
306
- deployment_id,
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"],
307
334
  )
335
+ row["wraps"] = json.loads(row["wraps"]) if row["wraps"] else None
336
+ return row
308
337
 
309
338
  async def get_execution(self, execution_id: int) -> MutableMapping[str, Any]:
310
339
  async with self.pool as pool:
@@ -337,9 +366,14 @@ class PostgreSQLDatabase(CachedDatabase):
337
366
  async def get_filter(self, filter_id: int) -> MutableMapping[str, Any]:
338
367
  async with self.pool as pool:
339
368
  async with pool.acquire() as conn:
340
- return await conn.fetchrow(
341
- "SELECT * FROM filter WHERE id = $1",
342
- filter_id,
369
+ return _load_keys(
370
+ dict(
371
+ await conn.fetchrow(
372
+ "SELECT * FROM filter WHERE id = $1",
373
+ filter_id,
374
+ )
375
+ ),
376
+ ["config"],
343
377
  )
344
378
 
345
379
  async def get_input_ports(
@@ -390,16 +424,24 @@ class PostgreSQLDatabase(CachedDatabase):
390
424
  async def get_port(self, port_id: int) -> MutableMapping[str, Any]:
391
425
  async with self.pool as pool:
392
426
  async with pool.acquire() as conn:
393
- return await conn.fetchrow("SELECT * FROM port WHERE id = $1", port_id)
427
+ return _load_keys(
428
+ dict(
429
+ await conn.fetchrow("SELECT * FROM port WHERE id = $1", port_id)
430
+ )
431
+ )
394
432
 
395
433
  async def get_port_from_token(self, token_id: int) -> MutableMapping[str, Any]:
396
434
  async with self.pool as pool:
397
435
  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,
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
+ )
403
445
  )
404
446
 
405
447
  async def get_port_tokens(self, port_id: int) -> MutableSequence[int]:
@@ -446,31 +488,50 @@ class PostgreSQLDatabase(CachedDatabase):
446
488
  async def get_step(self, step_id: int) -> MutableMapping[str, Any]:
447
489
  async with self.pool as pool:
448
490
  async with pool.acquire() as conn:
449
- return await conn.fetchrow("SELECT * FROM step WHERE id = $1", step_id)
491
+ return _load_keys(
492
+ dict(
493
+ await conn.fetchrow("SELECT * FROM step WHERE id = $1", step_id)
494
+ )
495
+ )
450
496
 
451
497
  @cachedmethod(lambda self: self.target_cache)
452
498
  async def get_target(self, target_id: int) -> MutableMapping[str, Any]:
453
499
  async with self.pool as pool:
454
500
  async with pool.acquire() as conn:
455
- return await conn.fetchrow(
456
- "SELECT * FROM target WHERE id = $1", target_id
501
+ return _load_keys(
502
+ dict(
503
+ await conn.fetchrow(
504
+ "SELECT * FROM target WHERE id = $1", target_id
505
+ )
506
+ )
457
507
  )
458
508
 
459
509
  @cachedmethod(lambda self: self.token_cache)
460
510
  async def get_token(self, token_id: int) -> MutableMapping[str, Any]:
461
511
  async with self.pool as pool:
462
512
  async with pool.acquire() as conn:
463
- row = await conn.fetchrow("SELECT * FROM token WHERE id = $1", token_id)
464
- return {
465
- k: bytearray(v) if isinstance(v, memoryview) else v
466
- for k, v in row.items()
467
- }
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
+ )
468
525
 
469
526
  async def get_workflow(self, workflow_id: int) -> MutableMapping[str, Any]:
470
527
  async with self.pool as pool:
471
528
  async with pool.acquire() as conn:
472
- return await conn.fetchrow(
473
- "SELECT * FROM workflow WHERE id = $1", workflow_id
529
+ return _load_keys(
530
+ dict(
531
+ await conn.fetchrow(
532
+ "SELECT * FROM workflow WHERE id = $1", workflow_id
533
+ )
534
+ )
474
535
  )
475
536
 
476
537
  async def get_workflow_ports(
@@ -478,20 +539,26 @@ class PostgreSQLDatabase(CachedDatabase):
478
539
  ) -> MutableSequence[MutableMapping[str, Any]]:
479
540
  async with self.pool as pool:
480
541
  async with pool.acquire() as conn:
481
- return await conn.fetch(
482
- "SELECT * FROM port WHERE workflow = $1",
483
- workflow_id,
484
- )
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
+ ]
485
549
 
486
550
  async def get_workflow_steps(
487
551
  self, workflow_id: int
488
552
  ) -> MutableSequence[MutableMapping[str, Any]]:
489
553
  async with self.pool as pool:
490
554
  async with pool.acquire() as conn:
491
- return await conn.fetch(
492
- "SELECT * FROM step WHERE workflow = $1",
493
- workflow_id,
494
- )
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
+ ]
495
562
 
496
563
  async def get_workflows_by_name(
497
564
  self, workflow_name: str, last_only: bool = False
@@ -500,9 +567,12 @@ class PostgreSQLDatabase(CachedDatabase):
500
567
  async with pool.acquire() as conn:
501
568
  query = "SELECT * FROM workflow WHERE name = $1 ORDER BY id desc"
502
569
  return (
503
- [conn.fetchrow(query, workflow_name)]
570
+ [_load_keys(dict(await conn.fetchrow(query, workflow_name)))]
504
571
  if last_only
505
- else conn.fetch(query, workflow_name)
572
+ else [
573
+ _load_keys(dict(r))
574
+ for r in await conn.fetch(query, workflow_name)
575
+ ]
506
576
  )
507
577
 
508
578
  async def get_workflows_list(
@@ -9,6 +9,7 @@ CREATE TABLE IF NOT EXISTS workflow
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,7 +49,7 @@ CREATE TABLE IF NOT EXISTS execution
47
49
  (
48
50
  id SERIAL PRIMARY KEY,
49
51
  step INTEGER,
50
- tag TEXT,
52
+ job_token INTEGER,
51
53
  cmd TEXT,
52
54
  status INTEGER,
53
55
  start_time BIGINT,
@@ -79,14 +81,15 @@ CREATE TABLE IF NOT EXISTS provenance
79
81
 
80
82
  CREATE TABLE IF NOT EXISTS deployment
81
83
  (
82
- id SERIAL PRIMARY KEY,
83
- name TEXT,
84
- type TEXT,
85
- config TEXT,
86
- external BOOLEAN,
87
- lazy BOOLEAN,
88
- workdir TEXT,
89
- wraps TEXT
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
90
93
  );
91
94
 
92
95
 
@@ -102,6 +105,14 @@ CREATE TABLE IF NOT EXISTS target
102
105
  FOREIGN KEY (deployment) REFERENCES deployment (id)
103
106
  );
104
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
+
105
116
  CREATE TABLE IF NOT EXISTS filter
106
117
  (
107
118
  id SERIAL PRIMARY KEY,
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: streamflow-postgresql
3
- Version: 0.0.8
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
@@ -25,20 +25,21 @@ Requires-Python: >=3.9
25
25
  Description-Content-Type: text/markdown
26
26
  License-File: LICENSE
27
27
  Requires-Dist: asyncpg==0.30.0
28
- Requires-Dist: streamflow==0.2.0.dev12
28
+ Requires-Dist: streamflow==0.2.0.dev13
29
29
  Provides-Extra: bandit
30
- Requires-Dist: bandit==1.8.3; extra == "bandit"
30
+ Requires-Dist: bandit==1.8.6; extra == "bandit"
31
31
  Provides-Extra: lint
32
- Requires-Dist: black==25.1.0; extra == "lint"
32
+ Requires-Dist: black==25.9.0; extra == "lint"
33
33
  Requires-Dist: codespell==2.4.1; extra == "lint"
34
34
  Requires-Dist: flake8-bugbear==24.12.12; extra == "lint"
35
35
  Requires-Dist: isort==6.0.1; extra == "lint"
36
- Requires-Dist: pyupgrade==3.19.1; extra == "lint"
36
+ Requires-Dist: pyupgrade==3.20.0; extra == "lint"
37
37
  Provides-Extra: test
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"
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
42
43
 
43
44
  # PostgreSQL Plugin for StreamFlow
44
45
 
@@ -0,0 +1,18 @@
1
+ asyncpg==0.30.0
2
+ streamflow==0.2.0.dev13
3
+
4
+ [bandit]
5
+ bandit==1.8.6
6
+
7
+ [lint]
8
+ black==25.9.0
9
+ codespell==2.4.1
10
+ flake8-bugbear==24.12.12
11
+ isort==6.0.1
12
+ pyupgrade==3.20.0
13
+
14
+ [test]
15
+ pytest==8.4.2
16
+ pytest-asyncio==1.2.0
17
+ pytest-cov==7.0.0
18
+ pytest-xdist==3.8.0
@@ -0,0 +1,4 @@
1
+ pytest==8.4.2
2
+ pytest-asyncio==1.2.0
3
+ pytest-cov==7.0.0
4
+ pytest-xdist==3.8.0