streamflow-postgresql 0.0.7__py3-none-any.whl → 0.0.8__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.
@@ -1,17 +1,18 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import json
4
- import os
5
- from typing import Any, MutableMapping, MutableSequence
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
- schema_path = pkg_resources.resource_filename(
47
- __name__, os.path.join("schemas", "postgresql.sql")
48
- )
49
- with open(schema_path) as f:
50
- async with self._pool.acquire() as conn:
51
- async with conn.transaction():
52
- await conn.execute(f.read())
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,9 +88,12 @@ class PostgreSQLDatabase(CachedDatabase):
86
88
  await self.pool.close()
87
89
 
88
90
  @classmethod
89
- def get_schema(cls) -> str:
90
- return pkg_resources.resource_filename(
91
- __name__, os.path.join("schemas", "postgresql.json")
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
99
  async def add_dependency(
@@ -160,7 +165,11 @@ class PostgreSQLDatabase(CachedDatabase):
160
165
  )
161
166
 
162
167
  async def add_port(
163
- self, name: str, workflow_id: int, type: type[Port], params: str
168
+ self,
169
+ name: str,
170
+ workflow_id: int,
171
+ type: type[Port],
172
+ params: MutableMapping[str, Any],
164
173
  ) -> int:
165
174
  async with self.pool as pool:
166
175
  async with pool.acquire() as conn:
@@ -187,7 +196,12 @@ class PostgreSQLDatabase(CachedDatabase):
187
196
  )
188
197
 
189
198
  async def add_step(
190
- self, name: str, workflow_id: int, status: int, type: type[Step], params: str
199
+ self,
200
+ name: str,
201
+ workflow_id: int,
202
+ status: int,
203
+ type: type[Step],
204
+ params: MutableMapping[str, Any],
191
205
  ) -> int:
192
206
  async with self.pool as pool:
193
207
  async with pool.acquire() as conn:
@@ -207,7 +221,7 @@ class PostgreSQLDatabase(CachedDatabase):
207
221
  self,
208
222
  deployment: int,
209
223
  type: type[Target],
210
- params: str,
224
+ params: MutableMapping[str, Any],
211
225
  locations: int = 1,
212
226
  service: str | None = None,
213
227
  workdir: str | None = None,
@@ -243,7 +257,13 @@ class PostgreSQLDatabase(CachedDatabase):
243
257
  bytearray(value, "utf-8"),
244
258
  )
245
259
 
246
- async def add_workflow(self, name: str, params: str, status: int, type: str) -> int:
260
+ async def add_workflow(
261
+ self,
262
+ name: str,
263
+ params: MutableMapping[str, Any],
264
+ status: int,
265
+ type: type[Workflow],
266
+ ) -> int:
247
267
  async with self.pool as pool:
248
268
  async with pool.acquire() as conn:
249
269
  async with conn.transaction():
@@ -254,7 +274,7 @@ class PostgreSQLDatabase(CachedDatabase):
254
274
  name,
255
275
  json.dumps(params),
256
276
  status,
257
- type,
277
+ utils.get_class_fullname(type),
258
278
  )
259
279
 
260
280
  async def get_dependees(
@@ -277,12 +297,13 @@ class PostgreSQLDatabase(CachedDatabase):
277
297
  token_id,
278
298
  )
279
299
 
280
- async def get_deployment(self, deplyoment_id: int) -> MutableMapping[str, Any]:
300
+ @cachedmethod(lambda self: self.deployment_cache)
301
+ async def get_deployment(self, deployment_id: int) -> MutableMapping[str, Any]:
281
302
  async with self.pool as pool:
282
303
  async with pool.acquire() as conn:
283
304
  return await conn.fetchrow(
284
305
  "SELECT * FROM deployment WHERE id = $1",
285
- deplyoment_id,
306
+ deployment_id,
286
307
  )
287
308
 
288
309
  async def get_execution(self, execution_id: int) -> MutableMapping[str, Any]:
@@ -312,6 +333,7 @@ class PostgreSQLDatabase(CachedDatabase):
312
333
  for row in rows
313
334
  ]
314
335
 
336
+ @cachedmethod(lambda self: self.filter_cache)
315
337
  async def get_filter(self, filter_id: int) -> MutableMapping[str, Any]:
316
338
  async with self.pool as pool:
317
339
  async with pool.acquire() as conn:
@@ -364,6 +386,7 @@ class PostgreSQLDatabase(CachedDatabase):
364
386
  DependencyType.INPUT.value,
365
387
  )
366
388
 
389
+ @cachedmethod(lambda self: self.port_cache)
367
390
  async def get_port(self, port_id: int) -> MutableMapping[str, Any]:
368
391
  async with self.pool as pool:
369
392
  async with pool.acquire() as conn:
@@ -419,11 +442,13 @@ class PostgreSQLDatabase(CachedDatabase):
419
442
  )
420
443
  return list(result.values())
421
444
 
445
+ @cachedmethod(lambda self: self.step_cache)
422
446
  async def get_step(self, step_id: int) -> MutableMapping[str, Any]:
423
447
  async with self.pool as pool:
424
448
  async with pool.acquire() as conn:
425
449
  return await conn.fetchrow("SELECT * FROM step WHERE id = $1", step_id)
426
450
 
451
+ @cachedmethod(lambda self: self.target_cache)
427
452
  async def get_target(self, target_id: int) -> MutableMapping[str, Any]:
428
453
  async with self.pool as pool:
429
454
  async with pool.acquire() as conn:
@@ -431,6 +456,7 @@ class PostgreSQLDatabase(CachedDatabase):
431
456
  "SELECT * FROM target WHERE id = $1", target_id
432
457
  )
433
458
 
459
+ @cachedmethod(lambda self: self.token_cache)
434
460
  async def get_token(self, token_id: int) -> MutableMapping[str, Any]:
435
461
  async with self.pool as pool:
436
462
  async with pool.acquire() as conn:
@@ -514,7 +540,7 @@ class PostgreSQLDatabase(CachedDatabase):
514
540
  deployment_id,
515
541
  *updates.values(),
516
542
  )
517
- self.port_cache.pop(deployment_id, None)
543
+ self.deployment_cache.pop(deployment_id, None)
518
544
  return deployment_id
519
545
 
520
546
  async def update_execution(
@@ -530,7 +556,6 @@ class PostgreSQLDatabase(CachedDatabase):
530
556
  execution_id,
531
557
  *updates.values(),
532
558
  )
533
- self.port_cache.pop(execution_id, None)
534
559
  return execution_id
535
560
 
536
561
  async def update_filter(
@@ -1,6 +1,6 @@
1
1
  from streamflow.ext.plugin import StreamFlowPlugin
2
2
 
3
- from streamflow_postgresql.database import PostgreSQLDatabase
3
+ from streamflow.plugins.unito.postgresql.database import PostgreSQLDatabase
4
4
 
5
5
 
6
6
  class PostgreSQLStreamFlowPlugin(StreamFlowPlugin):
@@ -1,10 +1,10 @@
1
1
  CREATE TABLE IF NOT EXISTS workflow
2
2
  (
3
- id SERIAL PRIMARY KEY,
4
- name TEXT,
5
- params TEXT,
6
- status INTEGER,
7
- type TEXT,
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
  );
@@ -49,7 +49,6 @@ CREATE TABLE IF NOT EXISTS execution
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,
@@ -0,0 +1 @@
1
+ VERSION = "0.0.8"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: streamflow-postgresql
3
- Version: 0.0.7
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.8
24
+ Requires-Python: >=3.9
24
25
  Description-Content-Type: text/markdown
25
26
  License-File: LICENSE
26
- Requires-Dist: asyncpg ==0.29.0
27
- Requires-Dist: streamflow ==0.2.0.dev11
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.7.8 ; extra == 'bandit'
30
+ Requires-Dist: bandit==1.8.3; extra == "bandit"
30
31
  Provides-Extra: lint
31
- Requires-Dist: black ==24.4.2 ; extra == 'lint'
32
- Requires-Dist: codespell ==2.2.6 ; extra == 'lint'
33
- Requires-Dist: flake8-bugbear ==24.4.26 ; extra == 'lint'
34
- Requires-Dist: pyupgrade ==3.15.2 ; extra == 'lint'
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 ==8.0.1 ; extra == 'test'
37
- Requires-Dist: pytest-asyncio ==0.21.1 ; extra == 'test'
38
- Requires-Dist: pytest-cov ==5.0.0 ; extra == 'test'
39
- Requires-Dist: pytest-xdist ==3.6.1 ; 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"
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 streamflow_postgresql.plugin.PostgreSQLStreamFlowPlugin
56
+ Successfully registered plugin streamflow.plugins.unito.postgresql.plugin.PostgreSQLStreamFlowPlugin
55
57
  ```
56
58
 
57
59
  ## Usage
@@ -0,0 +1,13 @@
1
+ streamflow/plugins/unito/postgresql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ streamflow/plugins/unito/postgresql/database.py,sha256=WeEwxMAouYHhg1jNe1SOL2ImPfovyep0u_iEnUlGE0U,24536
3
+ streamflow/plugins/unito/postgresql/plugin.py,sha256=jgyxjVNDAqvPC1Uv2rErPEWXvfR9yY4c-cDy6NfliwY,285
4
+ streamflow/plugins/unito/postgresql/version.py,sha256=QjIw4lGF4XrIrKfGwfvDqjh8WMYrSyOSoMK25o3xX2M,18
5
+ streamflow/plugins/unito/postgresql/schemas/postgresql.json,sha256=gkF4CMpaN0pAmxmEVoQ9XngzVBXsmDY1J7jFsuskT3o,1076
6
+ streamflow/plugins/unito/postgresql/schemas/postgresql.sql,sha256=moNV-KN0QNetgnAGECR1ChJxhPwwTZB_o35b-2Rf88U,2184
7
+ streamflow_postgresql-0.0.8.dist-info/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
8
+ streamflow_postgresql-0.0.8.dist-info/METADATA,sha256=F1ltjKuG4sjZXC0OfBdmnaJ-SBD--SDOUFKu4cianm4,2948
9
+ streamflow_postgresql-0.0.8.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
10
+ streamflow_postgresql-0.0.8.dist-info/entry_points.txt,sha256=8VRPwbcVMtaEkeQm_ky5UcT1ktEZFPGZGbWyia2aL9U,115
11
+ streamflow_postgresql-0.0.8.dist-info/top_level.txt,sha256=cJUjJEEaE5W_XIY66FE07tERTxJ4OWRtf9ITuY2ESdY,11
12
+ streamflow_postgresql-0.0.8.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
13
+ streamflow_postgresql-0.0.8.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,2 @@
1
+ [unito.streamflow.plugin]
2
+ unito.postgresql = streamflow.plugins.unito.postgresql.plugin:PostgreSQLStreamFlowPlugin
@@ -0,0 +1 @@
1
+ streamflow
@@ -1 +0,0 @@
1
- VERSION = "0.0.7"
@@ -1,13 +0,0 @@
1
- streamflow_postgresql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- streamflow_postgresql/database.py,sha256=3HWz6hoGKMt3DLJg_IpeVG7UCRLwwJn6DhDAKQ-HGaM,23917
3
- streamflow_postgresql/plugin.py,sha256=DpeLlosiHcAtte7JoVBjGRM3yt7SGi--PQFRLXfAA2M,271
4
- streamflow_postgresql/version.py,sha256=dRP5NXJxQujSKaLfhvI3s12RnwJ51q-kj9Ugl8UbKk8,18
5
- streamflow_postgresql/schemas/postgresql.json,sha256=gkF4CMpaN0pAmxmEVoQ9XngzVBXsmDY1J7jFsuskT3o,1076
6
- streamflow_postgresql/schemas/postgresql.sql,sha256=e3hwwHL-5tFya4Y1WlFXFOQZShgWCUQFLvvam60pJ44,2186
7
- streamflow_postgresql-0.0.7.dist-info/LICENSE,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
8
- streamflow_postgresql-0.0.7.dist-info/METADATA,sha256=CgjHmMtO1Zda5ArPm9NIQ9wF7bN2d1dAUMb27PW1V1M,2856
9
- streamflow_postgresql-0.0.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10
- streamflow_postgresql-0.0.7.dist-info/entry_points.txt,sha256=Ll6OkNAxkaRAPnpVeKp8x4jddz8gRqyrw4fNcJhYv4c,101
11
- streamflow_postgresql-0.0.7.dist-info/top_level.txt,sha256=6EKfFMeJBK1E7ALgDk9RDvBtwGUxWO3SzY8ftLjIQv4,22
12
- streamflow_postgresql-0.0.7.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
13
- streamflow_postgresql-0.0.7.dist-info/RECORD,,
@@ -1,2 +0,0 @@
1
- [unito.streamflow.plugin]
2
- unito.postgresql = streamflow_postgresql.plugin:PostgreSQLStreamFlowPlugin
@@ -1 +0,0 @@
1
- streamflow_postgresql