Skip to content

Commit

Permalink
back to createTime, other small ergonomic improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiedemaria committed Aug 9, 2024
1 parent 831dfa0 commit e9bda94
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 45 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 1 addition & 15 deletions js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,7 @@ def get_runs_feed_entries(
# they are different tables
all_entries = sorted(
all_entries,
key=lambda x: x.resolve_creationTimestamp(
graphene_info
), # ideally could just do .creationTime
key=lambda x: x.creation_timestamp,
reverse=True,
)

Expand All @@ -573,7 +571,7 @@ def get_runs_feed_entries(
if new_run_cursor is None and isinstance(run, GrapheneRun):
new_run_cursor = run.runId

new_timestamp = to_return[-1].resolve_creationTimestamp(graphene_info) if to_return else None
new_timestamp = to_return[-1].creation_timestamp if to_return else None

# if either of the new cursors are None, replace with the cursor passed in so the next call doesn't
# restart at the top the table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class Meta:
assetSelection = graphene.List(graphene.NonNull(GrapheneAssetKey))
partitionSetName = graphene.Field(graphene.String)
timestamp = graphene.NonNull(graphene.Float)
creationTimestamp = graphene.NonNull(
creationTime = graphene.NonNull(
graphene.Float
) # for RunsFeedEntry interface - dupe of timestamp
startTime = graphene.Float() # for RunsFeedEntry interface - dupe of timestamp
Expand Down Expand Up @@ -374,6 +374,7 @@ def __init__(self, backfill_job: PartitionBackfill):
reexecutionSteps=backfill_job.reexecution_steps,
timestamp=backfill_job.backfill_timestamp,
startTime=backfill_job.backfill_timestamp,
creationTime=backfill_job.backfill_timestamp,
assetSelection=backfill_job.asset_selection,
assetCheckSelection=[],
)
Expand Down Expand Up @@ -461,10 +462,8 @@ def _get_partition_run_data_for_ranged_job_backfill(
)
]

def resolve_creationTimestamp(self, graphene_info: ResolveInfo):
# Needed to have this as a resolver, rather than pass on __init__ because creationTimestamp is
# fulfilled via a resolver for GrapheneRun and we need to use the same method of getting
# creationTimestamp in get_runs_feed_entries
@property
def creation_timestamp(self) -> float:
return self.timestamp

def resolve_unfinishedRuns(self, graphene_info: ResolveInfo) -> Sequence["GrapheneRun"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,6 @@ class GrapheneRun(graphene.ObjectType):
limit=graphene.Argument(graphene.Int),
)
creationTime = graphene.NonNull(graphene.Float)
creationTimestamp = graphene.NonNull(
graphene.Float
) # for RunsFeedEntry interface - dupe of creationTime
startTime = graphene.Float()
endTime = graphene.Float()
updateTime = graphene.Float()
Expand Down Expand Up @@ -398,6 +395,10 @@ def _get_permission_value(self, permission: Permissions, graphene_info: ResolveI
else graphene_info.context.has_permission(permission)
)

@property
def creation_timestamp(self) -> float:
return self._run_record.create_timestamp.timestamp()

def resolve_hasReExecutePermission(self, graphene_info: ResolveInfo):
return self._get_permission_value(Permissions.LAUNCH_PIPELINE_REEXECUTION, graphene_info)

Expand Down Expand Up @@ -572,10 +573,7 @@ def resolve_updateTime(self, graphene_info: ResolveInfo):
return self._run_record.update_timestamp.timestamp()

def resolve_creationTime(self, graphene_info: ResolveInfo):
return self._run_record.create_timestamp.timestamp()

def resolve_creationTimestamp(self, graphene_info: ResolveInfo):
return self.resolve_creationTime(graphene_info)
return self.creation_timestamp

def resolve_hasConcurrencyKeySlots(self, graphene_info: ResolveInfo):
instance = graphene_info.context.instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class GrapheneRunsFeedEntry(graphene.Interface):
runId = graphene.NonNull(graphene.String)
runStatus = graphene.Field("dagster_graphql.schema.pipelines.pipeline.GrapheneRunStatus")
creationTimestamp = graphene.NonNull(graphene.Float)
creationTime = graphene.NonNull(graphene.Float)
startTime = graphene.Float()
endTime = graphene.Float()
tags = non_null_list("dagster_graphql.schema.tags.GraphenePipelineTag")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_get_runs_feed_ignores_backfill_runs(self, graphql_context):
if prev_run_time:
assert res["creationTime"] <= prev_run_time
prev_run_time = res["creationTime"]
assert res["__typename"] == "GraphenePartitionBackfill"
assert res["__typename"] == "PartitionBackfill"

assert not result.data["runsFeedOrError"]["hasMore"]

Expand Down Expand Up @@ -299,7 +299,7 @@ def test_get_runs_feed_one_backfill_long_ago(self, graphql_context):
prev_run_time = res["creationTime"]

# first 10 results should all be runs
assert res["__typename"] == "GrapheneRun"
assert res["__typename"] == "Run"

assert result.data["runsFeedOrError"]["hasMore"]
assert result.data["runsFeedOrError"]["cursor"] is not None
Expand Down Expand Up @@ -380,7 +380,7 @@ def test_get_runs_feed_one_new_backfill(self, graphql_context):
prev_run_time = res["creationTime"]

# all remaining results should be runs
assert res["__typename"] == "GrapheneRun"
assert res["__typename"] == "Run"

assert not result.data["runsFeedOrError"]["hasMore"]
assert result.data["runsFeedOrError"]["cursor"] is not None
Expand Down Expand Up @@ -441,7 +441,7 @@ def test_get_runs_feed_backfill_created_between_calls(self, graphql_context):
assert res["creationTime"] <= prev_run_time
prev_run_time = res["creationTime"]

assert res["__typename"] == "GrapheneRun"
assert res["__typename"] == "Run"

assert not result.data["runsFeedOrError"]["hasMore"]
assert result.data["runsFeedOrError"]["cursor"] is not None
Expand Down

0 comments on commit e9bda94

Please sign in to comment.