From ecb72d43c319cb17cfd9c1053c0cf4c5b5701907 Mon Sep 17 00:00:00 2001 From: JamieDeMaria Date: Wed, 14 Aug 2024 11:55:56 -0400 Subject: [PATCH] actually pass the correct cursor --- .../implementation/fetch_runs.py | 4 +++- .../graphql/test_runs_feed.py | 19 +------------------ .../_core/storage/runs/sql_run_storage.py | 4 ++-- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/python_modules/dagster-graphql/dagster_graphql/implementation/fetch_runs.py b/python_modules/dagster-graphql/dagster_graphql/implementation/fetch_runs.py index e7b82a9127aa0..cdbb3ddf481e8 100644 --- a/python_modules/dagster-graphql/dagster_graphql/implementation/fetch_runs.py +++ b/python_modules/dagster-graphql/dagster_graphql/implementation/fetch_runs.py @@ -488,7 +488,9 @@ def get_runs_feed_entries( backfills = [ GraphenePartitionBackfill(backfill) for backfill in instance.get_backfills( - cursor=cursor, limit=limit, created_before=created_before_cursor + cursor=runs_feed_cursor.backfill_cursor, + limit=limit, + created_before=created_before_cursor, ) ] runs = [ diff --git a/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_runs_feed.py b/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_runs_feed.py index 1e8560b2f2bf3..a8e518a9ffcaf 100644 --- a/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_runs_feed.py +++ b/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_runs_feed.py @@ -108,15 +108,11 @@ def test_get_runs_feed(self, gql_context_with_runs_and_backfills): }, ) prev_run_time = None - id_to_timestamp_mapping = {} for res in result.data["runsFeedOrError"]["results"]: - id_to_timestamp_mapping[res["id"]] = res["creationTime"] if prev_run_time: assert res["creationTime"] <= prev_run_time prev_run_time = res["creationTime"] - print(id_to_timestamp_mapping) - result = execute_dagster_graphql( gql_context_with_runs_and_backfills.create_request_context(), GET_RUNS_FEED_QUERY, @@ -131,15 +127,11 @@ def test_get_runs_feed(self, gql_context_with_runs_and_backfills): assert len(result.data["runsFeedOrError"]["results"]) == 10 prev_run_time = None - id_to_timestamp_mapping = {} for res in result.data["runsFeedOrError"]["results"]: - id_to_timestamp_mapping[res["id"]] = res["creationTime"] if prev_run_time: assert res["creationTime"] <= prev_run_time prev_run_time = res["creationTime"] - print(id_to_timestamp_mapping) - assert result.data["runsFeedOrError"]["hasMore"] old_cursor = result.data["runsFeedOrError"]["cursor"] assert old_cursor is not None @@ -153,21 +145,12 @@ def test_get_runs_feed(self, gql_context_with_runs_and_backfills): }, ) - id_to_timestamp_mapping = {} - for res in result.data["runsFeedOrError"]["results"]: - id_to_timestamp_mapping[res["id"]] = res["creationTime"] - + assert len(result.data["runsFeedOrError"]["results"]) == 10 for res in result.data["runsFeedOrError"]["results"]: if prev_run_time: assert res["creationTime"] <= prev_run_time prev_run_time = res["creationTime"] - print(id_to_timestamp_mapping) - - assert len(result.data["runsFeedOrError"]["results"]) == 10 - - # assert False - assert not result.data["runsFeedOrError"]["hasMore"] def test_get_runs_feed_inexact_limit(self, gql_context_with_runs_and_backfills): diff --git a/python_modules/dagster/dagster/_core/storage/runs/sql_run_storage.py b/python_modules/dagster/dagster/_core/storage/runs/sql_run_storage.py index 5d4bc5d7d94f8..2e0a996028a22 100644 --- a/python_modules/dagster/dagster/_core/storage/runs/sql_run_storage.py +++ b/python_modules/dagster/dagster/_core/storage/runs/sql_run_storage.py @@ -841,7 +841,7 @@ def get_backfills( created_after: Optional[datetime] = None, ) -> Sequence[PartitionBackfill]: check.opt_inst_param(status, "status", BulkActionStatus) - query = db_select([BulkActionsTable.c.body]) + query = db_select([BulkActionsTable.c.body, BulkActionsTable.c.timestamp]) if status: query = query.where(BulkActionsTable.c.status == status.value) if cursor: @@ -852,7 +852,7 @@ def get_backfills( if created_after: query = query.where(BulkActionsTable.c.timestamp > created_after) if created_before: - query = query.where(BulkActionsTable.c.timestamp < created_before) + query = query.where(BulkActionsTable.c.timestamp < created_before.replace(tzinfo=None)) if limit: query = query.limit(limit) query = query.order_by(BulkActionsTable.c.id.desc())