dagster-postgres 0.26.1__py3-none-any.whl → 0.27.15__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.

Potentially problematic release.


This version of dagster-postgres might be problematic. Click here for more details.

@@ -1,4 +1,4 @@
1
- from dagster._core.libraries import DagsterLibraryRegistry
1
+ from dagster_shared.libraries import DagsterLibraryRegistry
2
2
 
3
3
  from dagster_postgres.event_log import PostgresEventLogStorage
4
4
  from dagster_postgres.run_storage import PostgresRunStorage
@@ -112,12 +112,15 @@ class PostgresEventLogStorage(SqlEventLogStorage, ConfigurableClass):
112
112
  SqlEventLogStorageMetadata.create_all(conn)
113
113
  stamp_alembic_rev(pg_alembic_config(__file__), conn)
114
114
 
115
- def optimize_for_webserver(self, statement_timeout: int, pool_recycle: int) -> None:
115
+ def optimize_for_webserver(
116
+ self, statement_timeout: int, pool_recycle: int, max_overflow: int
117
+ ) -> None:
116
118
  # When running in dagster-webserver, hold an open connection and set statement_timeout
117
119
  kwargs = {
118
120
  "isolation_level": "AUTOCOMMIT",
119
121
  "pool_size": 1,
120
122
  "pool_recycle": pool_recycle,
123
+ "max_overflow": max_overflow,
121
124
  }
122
125
  existing_options = self._engine.url.query.get("options")
123
126
  if existing_options:
@@ -173,7 +176,6 @@ class PostgresEventLogStorage(SqlEventLogStorage, ConfigurableClass):
173
176
  event (EventLogEntry): The event to store.
174
177
  """
175
178
  check.inst_param(event, "event", EventLogEntry)
176
-
177
179
  insert_event_statement = self.prepare_insert_event(event) # from SqlEventLogStorage.py
178
180
  with self._connect() as conn:
179
181
  result = conn.execute(
@@ -209,25 +211,45 @@ class PostgresEventLogStorage(SqlEventLogStorage, ConfigurableClass):
209
211
  self.store_asset_check_event(event, event_id)
210
212
 
211
213
  def store_event_batch(self, events: Sequence[EventLogEntry]) -> None:
214
+ from dagster import DagsterEventType
215
+
212
216
  check.sequence_param(events, "event", of_type=EventLogEntry)
213
217
 
218
+ event_types = {event.get_dagster_event().event_type for event in events}
219
+
214
220
  check.invariant(
215
- all(event.get_dagster_event().event_type in BATCH_WRITABLE_EVENTS for event in events),
221
+ all(event_type in BATCH_WRITABLE_EVENTS for event_type in event_types),
216
222
  f"{BATCH_WRITABLE_EVENTS} are the only currently supported events for batch writes.",
217
223
  )
224
+ events = [
225
+ event
226
+ for event in events
227
+ if not event.get_dagster_event().is_asset_failed_to_materialize
228
+ ]
229
+ if len(events) == 0:
230
+ return
218
231
 
219
- insert_event_statement = self.prepare_insert_event_batch(events)
220
- with self._connect() as conn:
221
- result = conn.execute(insert_event_statement.returning(SqlEventLogStorageTable.c.id))
222
- event_ids = [cast(int, row[0]) for row in result.fetchall()]
232
+ if event_types == {DagsterEventType.ASSET_MATERIALIZATION} or event_types == {
233
+ DagsterEventType.ASSET_OBSERVATION
234
+ }:
235
+ insert_event_statement = self.prepare_insert_event_batch(events)
236
+ with self._connect() as conn:
237
+ result = conn.execute(
238
+ insert_event_statement.returning(SqlEventLogStorageTable.c.id)
239
+ )
240
+ event_ids = [cast("int", row[0]) for row in result.fetchall()]
223
241
 
224
- # We only update the asset table with the last event
225
- self.store_asset_event(events[-1], event_ids[-1])
242
+ # We only update the asset table with the last event
243
+ self.store_asset_event(events[-1], event_ids[-1])
226
244
 
227
- if any(event_id is None for event_id in event_ids):
228
- raise DagsterInvariantViolationError("Cannot store asset event tags for null event id.")
245
+ if any(event_id is None for event_id in event_ids):
246
+ raise DagsterInvariantViolationError(
247
+ "Cannot store asset event tags for null event id."
248
+ )
229
249
 
230
- self.store_asset_event_tags(events, event_ids)
250
+ self.store_asset_event_tags(events, event_ids)
251
+ else:
252
+ return super().store_event_batch(events)
231
253
 
232
254
  def store_asset_event(self, event: EventLogEntry, event_id: int) -> None:
233
255
  check.inst_param(event, "event", EventLogEntry)
@@ -108,12 +108,15 @@ class PostgresRunStorage(SqlRunStorage, ConfigurableClass):
108
108
  # This revision may be shared by any other dagster storage classes using the same DB
109
109
  stamp_alembic_rev(pg_alembic_config(__file__), conn)
110
110
 
111
- def optimize_for_webserver(self, statement_timeout: int, pool_recycle: int) -> None:
111
+ def optimize_for_webserver(
112
+ self, statement_timeout: int, pool_recycle: int, max_overflow: int
113
+ ) -> None:
112
114
  # When running in dagster-webserver, hold an open connection and set statement_timeout
113
115
  kwargs = {
114
116
  "isolation_level": "AUTOCOMMIT",
115
117
  "pool_size": 1,
116
118
  "pool_recycle": pool_recycle,
119
+ "max_overflow": max_overflow,
117
120
  }
118
121
  existing_options = self._engine.url.query.get("options")
119
122
  if existing_options:
@@ -134,7 +137,7 @@ class PostgresRunStorage(SqlRunStorage, ConfigurableClass):
134
137
  return pg_config()
135
138
 
136
139
  @classmethod
137
- def from_config_value(
140
+ def from_config_value( # pyright: ignore[reportIncompatibleMethodOverride]
138
141
  cls, inst_data: Optional[ConfigurableClassData], config_value: PostgresStorageConfig
139
142
  ):
140
143
  return PostgresRunStorage(
@@ -104,12 +104,15 @@ class PostgresScheduleStorage(SqlScheduleStorage, ConfigurableClass):
104
104
  self.migrate()
105
105
  self.optimize()
106
106
 
107
- def optimize_for_webserver(self, statement_timeout: int, pool_recycle: int) -> None:
107
+ def optimize_for_webserver(
108
+ self, statement_timeout: int, pool_recycle: int, max_overflow: int
109
+ ) -> None:
108
110
  # When running in dagster-webserver, hold an open connection and set statement_timeout
109
111
  kwargs = {
110
112
  "isolation_level": "AUTOCOMMIT",
111
113
  "pool_size": 1,
112
114
  "pool_recycle": pool_recycle,
115
+ "max_overflow": max_overflow,
113
116
  }
114
117
  existing_options = self._engine.url.query.get("options")
115
118
  if existing_options:
@@ -130,7 +133,7 @@ class PostgresScheduleStorage(SqlScheduleStorage, ConfigurableClass):
130
133
  return pg_config()
131
134
 
132
135
  @classmethod
133
- def from_config_value(
136
+ def from_config_value( # pyright: ignore[reportIncompatibleMethodOverride]
134
137
  cls, inst_data: Optional[ConfigurableClassData], config_value: PostgresStorageConfig
135
138
  ) -> "PostgresScheduleStorage":
136
139
  return PostgresScheduleStorage(
@@ -59,7 +59,7 @@ class DagsterPostgresStorage(DagsterStorage, ConfigurableClass):
59
59
  return pg_config()
60
60
 
61
61
  @classmethod
62
- def from_config_value(
62
+ def from_config_value( # pyright: ignore[reportIncompatibleMethodOverride]
63
63
  cls, inst_data: Optional[ConfigurableClassData], config_value: PostgresStorageConfig
64
64
  ) -> "DagsterPostgresStorage":
65
65
  return DagsterPostgresStorage(
@@ -0,0 +1,75 @@
1
+ import tempfile
2
+ from contextlib import contextmanager
3
+ from pathlib import Path
4
+
5
+ import pytest
6
+ from dagster._core.test_utils import instance_for_test
7
+ from dagster._utils.merger import merge_dicts
8
+ from dagster_test.fixtures import docker_compose_cm, network_name_from_yml
9
+
10
+ from dagster_postgres.utils import get_conn_string, wait_for_connection
11
+
12
+ compose_file = Path(__file__).parent / "docker-compose.yml"
13
+
14
+
15
+ @pytest.fixture(scope="session")
16
+ def postgres_network():
17
+ yield network_name_from_yml(compose_file)
18
+
19
+
20
+ @pytest.fixture(scope="session")
21
+ def postgres_hostname():
22
+ with docker_compose_cm(docker_compose_yml=compose_file) as hostnames:
23
+ yield hostnames["postgres"]
24
+
25
+
26
+ @pytest.fixture(scope="session")
27
+ def postgres_conn_str(postgres_hostname):
28
+ conn_str = get_conn_string(
29
+ username="test",
30
+ password="test",
31
+ hostname=postgres_hostname,
32
+ db_name="test",
33
+ params=dict(connect_timeout=5),
34
+ )
35
+ wait_for_connection(
36
+ conn_str,
37
+ retry_limit=10,
38
+ retry_wait=3,
39
+ )
40
+
41
+ yield conn_str
42
+
43
+
44
+ @pytest.fixture
45
+ def postgres_instance(postgres_conn_str):
46
+ @contextmanager
47
+ def _instance(overrides=None):
48
+ with tempfile.TemporaryDirectory() as temp_dir:
49
+ with instance_for_test(
50
+ temp_dir=temp_dir,
51
+ overrides=merge_dicts(
52
+ {
53
+ "run_storage": {
54
+ "module": "dagster_postgres.run_storage.run_storage",
55
+ "class": "PostgresRunStorage",
56
+ "config": {"postgres_url": postgres_conn_str},
57
+ },
58
+ "event_log_storage": {
59
+ "module": "dagster_postgres.event_log.event_log",
60
+ "class": "PostgresEventLogStorage",
61
+ "config": {"postgres_url": postgres_conn_str},
62
+ },
63
+ "schedule_storage": {
64
+ "module": "dagster_postgres.schedule_storage.schedule_storage",
65
+ "class": "PostgresScheduleStorage",
66
+ "config": {"postgres_url": postgres_conn_str},
67
+ },
68
+ },
69
+ overrides if overrides else {},
70
+ ),
71
+ ) as instance:
72
+ instance.wipe()
73
+ yield instance
74
+
75
+ return _instance
@@ -0,0 +1,10 @@
1
+ services:
2
+ postgres:
3
+ image: postgres:16
4
+ container_name: postgres
5
+ ports:
6
+ - "5432:5432"
7
+ environment:
8
+ POSTGRES_PASSWORD: "test"
9
+ POSTGRES_USER: "test"
10
+ POSTGRES_DB: "test"
@@ -1 +1 @@
1
- __version__ = "0.26.1"
1
+ __version__ = "0.27.15"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: dagster-postgres
3
- Version: 0.26.1
3
+ Version: 0.27.15
4
4
  Summary: A Dagster integration for postgres
5
5
  Home-page: https://github.com/dagster-io/dagster/tree/master/python_modules/libraries/dagster-postgres
6
6
  Author: Dagster Labs
@@ -10,10 +10,19 @@ Classifier: Programming Language :: Python :: 3.9
10
10
  Classifier: Programming Language :: Python :: 3.10
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
13
14
  Classifier: License :: OSI Approved :: Apache Software License
14
15
  Classifier: Operating System :: OS Independent
15
- Requires-Python: >=3.9,<3.13
16
+ Requires-Python: >=3.9,<3.14
16
17
  License-File: LICENSE
17
- Requires-Dist: dagster ==1.10.1
18
+ Requires-Dist: dagster==1.11.15
18
19
  Requires-Dist: psycopg2-binary
19
-
20
+ Dynamic: author
21
+ Dynamic: author-email
22
+ Dynamic: classifier
23
+ Dynamic: home-page
24
+ Dynamic: license
25
+ Dynamic: license-file
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
@@ -0,0 +1,19 @@
1
+ dagster_postgres/__init__.py,sha256=rZfjhBDGC_SIGnKuiSCzi7D0xD36mAnchDLRL-n1Tmk,561
2
+ dagster_postgres/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
3
+ dagster_postgres/storage.py,sha256=CiPA773j0BQvPtCEz5vVqKjap9h0ODAxR_R_CvbI-bI,4310
4
+ dagster_postgres/utils.py,sha256=AjuUYZ3y4Q3oaa-6I2zd6SNwl66FE8cJ_e2rIKrI9IQ,5930
5
+ dagster_postgres/version.py,sha256=nh4rkWKwcS4_2NEvEKWozrztgCUEn_1ODIolwNpGd8g,24
6
+ dagster_postgres/alembic/alembic.ini,sha256=GovyDEhu_6HvkWV6txqjdDBOe4BseSM0YDWGxXM5_cA,986
7
+ dagster_postgres/event_log/__init__.py,sha256=wRcUR-StRNrPCqpEzi0MRY8b-r_TEWV17OsEynFqlLs,100
8
+ dagster_postgres/event_log/event_log.py,sha256=w8_ZsvDb0vt7qDVSS912jmNRpLDI6F0KQrwribyAmwM,16145
9
+ dagster_postgres/run_storage/__init__.py,sha256=oW_546mJ5K-e-RF0Ou7r-4fHWxFthHgPPhWxklsVK1g,94
10
+ dagster_postgres/run_storage/run_storage.py,sha256=VMXT5sb5n04ViWOYj2eOoZqOk78hqL38J6CuikM79No,9757
11
+ dagster_postgres/schedule_storage/__init__.py,sha256=-jW-1S4Xf5Ew-cz-DjKjU5sVs9EEly_2ELMLOXTewv0,123
12
+ dagster_postgres/schedule_storage/schedule_storage.py,sha256=iPKcvnj1eEeG5LH73GoFvoS3hmE8MFddiFyf7QoKZ3g,8826
13
+ dagster_postgres/test_fixtures/__init__.py,sha256=ZIcbGYa_CMmVF0YkuiX4uI3wRjBke_2VE8QXKcji0Y4,2447
14
+ dagster_postgres/test_fixtures/docker-compose.yml,sha256=hp2VTnENYK6CL2Yae3IsktssahPFQiHyhpNcG36CivM,208
15
+ dagster_postgres-0.27.15.dist-info/licenses/LICENSE,sha256=4lsMW-RCvfVD4_F57wrmpe3vX1xwUk_OAKKmV_XT7Z0,11348
16
+ dagster_postgres-0.27.15.dist-info/METADATA,sha256=_4kuw4rRwvg4462KMMaJ5KzTNVwInGJQvzfgiZJU7rs,945
17
+ dagster_postgres-0.27.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
+ dagster_postgres-0.27.15.dist-info/top_level.txt,sha256=lScMtAEKDX1yIv2tGa1nzntBa0HEStfWPfCwD8FWlHk,17
19
+ dagster_postgres-0.27.15.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2023 Dagster Labs, Inc".
189
+ Copyright 2025 Dagster Labs, Inc.
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
@@ -1,17 +0,0 @@
1
- dagster_postgres/__init__.py,sha256=h8rM1BA27G8jSAak_WnjfZ_dqyz79x9rfTeroUveu_w,560
2
- dagster_postgres/py.typed,sha256=la67KBlbjXN-_-DfGNcdOcjYumVpKG_Tkw-8n5dnGB4,8
3
- dagster_postgres/storage.py,sha256=whjOJeT4-W41bZ8xDBg77NGSVJPQzc33IsxpmGNdpVM,4257
4
- dagster_postgres/utils.py,sha256=AjuUYZ3y4Q3oaa-6I2zd6SNwl66FE8cJ_e2rIKrI9IQ,5930
5
- dagster_postgres/version.py,sha256=u0eTmljUU0kO8AAW-e1ESQ49mK2SuhpCy7eCliBLlDU,23
6
- dagster_postgres/alembic/alembic.ini,sha256=GovyDEhu_6HvkWV6txqjdDBOe4BseSM0YDWGxXM5_cA,986
7
- dagster_postgres/event_log/__init__.py,sha256=wRcUR-StRNrPCqpEzi0MRY8b-r_TEWV17OsEynFqlLs,100
8
- dagster_postgres/event_log/event_log.py,sha256=Y73l4Vf_Tp3HXeEI7WdIpdjDmFTFbMT8HDL62NFg3qI,15430
9
- dagster_postgres/run_storage/__init__.py,sha256=oW_546mJ5K-e-RF0Ou7r-4fHWxFthHgPPhWxklsVK1g,94
10
- dagster_postgres/run_storage/run_storage.py,sha256=dX_x8xZGcz4byCC-Jette87rAGTQAuNpKgkXKIhxgmc,9629
11
- dagster_postgres/schedule_storage/__init__.py,sha256=-jW-1S4Xf5Ew-cz-DjKjU5sVs9EEly_2ELMLOXTewv0,123
12
- dagster_postgres/schedule_storage/schedule_storage.py,sha256=6DSsUFb4nnEvzw0AtY64oBJU5mHsNlB35skwi_gKIZE,8698
13
- dagster_postgres-0.26.1.dist-info/LICENSE,sha256=TMatHW4_G9ldRdodEAp-l2Xa2WvsdeOh60E3v1R2jis,11349
14
- dagster_postgres-0.26.1.dist-info/METADATA,sha256=Z4hkEG7zpC3gvq3pwrua5DJqgzePHT1tMwPrHbgdOio,713
15
- dagster_postgres-0.26.1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
16
- dagster_postgres-0.26.1.dist-info/top_level.txt,sha256=lScMtAEKDX1yIv2tGa1nzntBa0HEStfWPfCwD8FWlHk,17
17
- dagster_postgres-0.26.1.dist-info/RECORD,,