From 611d0b1648dbb18472c730415287fb4d422de3cc Mon Sep 17 00:00:00 2001 From: JamieDeMaria Date: Tue, 15 Oct 2024 14:40:16 -0400 Subject: [PATCH] update gql --- .../ui-core/src/graphql/schema.graphql | 3 ++ .../packages/ui-core/src/graphql/types.ts | 21 ++++++++++ .../dagster_graphql/schema/backfill.py | 37 ++++++++++++++++ .../schema/pipelines/pipeline.py | 42 ++++++++++++++++++- .../dagster_graphql/schema/runs_feed.py | 1 + 5 files changed, 103 insertions(+), 1 deletion(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql b/js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql index c59ff6f7fc12e..cdfa9bc7aa153 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql +++ b/js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql @@ -1428,6 +1428,7 @@ type Run implements PipelineRun & RunsFeedEntry { endTime: Float assetSelection: [AssetKey!] assetCheckSelection: [AssetCheckhandle!] + launchedBy: PipelineTag! parentPipelineSnapshotId: String resolvedOpSelection: [String!] assetMaterializations: [MaterializationEvent!]! @@ -1452,6 +1453,7 @@ interface RunsFeedEntry { jobName: String assetSelection: [AssetKey!] assetCheckSelection: [AssetCheckhandle!] + launchedBy: PipelineTag! } type AssetCheckhandle { @@ -2842,6 +2844,7 @@ type PartitionBackfill implements RunsFeedEntry { jobName: String assetSelection: [AssetKey!] assetCheckSelection: [AssetCheckhandle!] + launchedBy: PipelineTag! status: BulkActionStatus! partitionNames: [String!] isValidSerialization: Boolean! diff --git a/js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts b/js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts index 2ba2ba6fa8212..4ef68375d56a2 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts +++ b/js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts @@ -3087,6 +3087,7 @@ export type PartitionBackfill = RunsFeedEntry & { isAssetBackfill: Scalars['Boolean']['output']; isValidSerialization: Scalars['Boolean']['output']; jobName: Maybe; + launchedBy: PipelineTag; logEvents: InstigationEventConnection; numCancelable: Scalars['Int']['output']; numPartitions: Maybe; @@ -4446,6 +4447,7 @@ export type Run = PipelineRun & hasUnconstrainedRootNodes: Scalars['Boolean']['output']; id: Scalars['ID']['output']; jobName: Scalars['String']['output']; + launchedBy: PipelineTag; mode: Scalars['String']['output']; parentPipelineSnapshotId: Maybe; parentRunId: Maybe; @@ -4790,6 +4792,7 @@ export type RunsFeedEntry = { endTime: Maybe; id: Scalars['ID']['output']; jobName: Maybe; + launchedBy: PipelineTag; runStatus: Maybe; startTime: Maybe; tags: Array; @@ -10838,6 +10841,12 @@ export const buildPartitionBackfill = ( ? overrides.isValidSerialization! : false, jobName: overrides && overrides.hasOwnProperty('jobName') ? overrides.jobName! : 'est', + launchedBy: + overrides && overrides.hasOwnProperty('launchedBy') + ? overrides.launchedBy! + : relationshipsToOmit.has('PipelineTag') + ? ({} as PipelineTag) + : buildPipelineTag({}, relationshipsToOmit), logEvents: overrides && overrides.hasOwnProperty('logEvents') ? overrides.logEvents! @@ -13018,6 +13027,12 @@ export const buildRun = ( ? overrides.id! : '1e257d13-8f67-444f-aeb2-b39ede89fbf5', jobName: overrides && overrides.hasOwnProperty('jobName') ? overrides.jobName! : 'ut', + launchedBy: + overrides && overrides.hasOwnProperty('launchedBy') + ? overrides.launchedBy! + : relationshipsToOmit.has('PipelineTag') + ? ({} as PipelineTag) + : buildPipelineTag({}, relationshipsToOmit), mode: overrides && overrides.hasOwnProperty('mode') ? overrides.mode! : 'laboriosam', parentPipelineSnapshotId: overrides && overrides.hasOwnProperty('parentPipelineSnapshotId') @@ -13653,6 +13668,12 @@ export const buildRunsFeedEntry = ( ? overrides.id! : '6d9ebb9a-e183-4642-b24f-468c247b375f', jobName: overrides && overrides.hasOwnProperty('jobName') ? overrides.jobName! : 'sed', + launchedBy: + overrides && overrides.hasOwnProperty('launchedBy') + ? overrides.launchedBy! + : relationshipsToOmit.has('PipelineTag') + ? ({} as PipelineTag) + : buildPipelineTag({}, relationshipsToOmit), runStatus: overrides && overrides.hasOwnProperty('runStatus') ? overrides.runStatus! diff --git a/python_modules/dagster-graphql/dagster_graphql/schema/backfill.py b/python_modules/dagster-graphql/dagster_graphql/schema/backfill.py index 61f736d4f8383..4c3674cf2ad0a 100644 --- a/python_modules/dagster-graphql/dagster_graphql/schema/backfill.py +++ b/python_modules/dagster-graphql/dagster_graphql/schema/backfill.py @@ -23,6 +23,11 @@ from dagster._core.storage.tags import ( ASSET_PARTITION_RANGE_END_TAG, ASSET_PARTITION_RANGE_START_TAG, + AUTO_MATERIALIZE_TAG, + AUTO_OBSERVE_TAG, + SCHEDULE_NAME_TAG, + SENSOR_NAME_TAG, + USER_TAG, TagType, get_tag_type, ) @@ -385,6 +390,7 @@ class Meta: assetCheckSelection = graphene.List( graphene.NonNull("dagster_graphql.schema.asset_checks.GrapheneAssetCheckHandle") ) + launchedBy = graphene.NonNull("dagster_graphql.schema.tags.GraphenePipelineTag") def __init__(self, backfill_job: PartitionBackfill): self._backfill_job = check.inst_param(backfill_job, "backfill_job", PartitionBackfill) @@ -520,6 +526,37 @@ def resolve_tags(self, _graphene_info: ResolveInfo): if get_tag_type(key) != TagType.HIDDEN ] + def resolve_launchedBy(self, _graphene_info: ResolveInfo): + """Determines which value should be shown in the Launched by column in the UI. This value is + deetermined based on the tags of the backfill, not the source of the backfill as stored in the DB. Thus, some + backfills may have different launchedBy values from source columns. + """ + from dagster_graphql.schema.tags import GraphenePipelineTag + + if self._backfill_job.tags.get(USER_TAG): + return GraphenePipelineTag(key=USER_TAG, value=self._backfill_job.tags[USER_TAG]) + if self._backfill_job.tags.get(SCHEDULE_NAME_TAG): + return GraphenePipelineTag( + key=SCHEDULE_NAME_TAG, value=self._backfill_job.tags[SCHEDULE_NAME_TAG] + ) + if self._backfill_job.tags.get(SENSOR_NAME_TAG): + return GraphenePipelineTag( + key=SENSOR_NAME_TAG, value=self._backfill_job.tags[SENSOR_NAME_TAG] + ) + if self._backfill_job.tags.get(AUTO_MATERIALIZE_TAG): + return GraphenePipelineTag( + key=AUTO_MATERIALIZE_TAG, value=self._backfill_job.tags[AUTO_MATERIALIZE_TAG] + ) + if self._backfill_job.tags.get("dagster/created_by") == "auto_materialize": + return GraphenePipelineTag( + key="dagster/created_by", value=self._backfill_job.tags["dagster/created_by"] + ) + if self._backfill_job.tags.get(AUTO_OBSERVE_TAG): + return GraphenePipelineTag( + key=AUTO_OBSERVE_TAG, value=self._backfill_job.tags[AUTO_OBSERVE_TAG] + ) + return GraphenePipelineTag(kind="manual", value="") + def resolve_runStatus(self, _graphene_info: ResolveInfo) -> GrapheneRunStatus: return GrapheneBulkActionStatus(self.status).to_dagster_run_status() diff --git a/python_modules/dagster-graphql/dagster_graphql/schema/pipelines/pipeline.py b/python_modules/dagster-graphql/dagster_graphql/schema/pipelines/pipeline.py index f78b0624fe397..d5515a3fa1d85 100644 --- a/python_modules/dagster-graphql/dagster_graphql/schema/pipelines/pipeline.py +++ b/python_modules/dagster-graphql/dagster_graphql/schema/pipelines/pipeline.py @@ -19,7 +19,17 @@ RunRecord, RunsFilter, ) -from dagster._core.storage.tags import REPOSITORY_LABEL_TAG, RUN_METRIC_TAGS, TagType, get_tag_type +from dagster._core.storage.tags import ( + AUTO_MATERIALIZE_TAG, + AUTO_OBSERVE_TAG, + REPOSITORY_LABEL_TAG, + RUN_METRIC_TAGS, + SCHEDULE_NAME_TAG, + SENSOR_NAME_TAG, + USER_TAG, + TagType, + get_tag_type, +) from dagster._core.workspace.permissions import Permissions from dagster._utils.tags import get_boolean_tag_value from dagster._utils.yaml_utils import dump_run_config_yaml @@ -391,6 +401,7 @@ class GrapheneRun(graphene.ObjectType): rootConcurrencyKeys = graphene.List(graphene.NonNull(graphene.String)) hasUnconstrainedRootNodes = graphene.NonNull(graphene.Boolean) hasRunMetricsEnabled = graphene.NonNull(graphene.Boolean) + launchedBy = graphene.NonNull(GraphenePipelineTag) class Meta: interfaces = (GraphenePipelineRun, GrapheneRunsFeedEntry) @@ -529,6 +540,35 @@ def resolve_tags(self, _graphene_info: ResolveInfo): if get_tag_type(key) != TagType.HIDDEN ] + def resolve_launchedBy(self, _graphene_info: ResolveInfo): + """Determines which value should be shown in the Launched by column in the UI. This value is + deetermined based on the tags of the run, not the source of the run as stored in the DB. Thus, some + runs may have different launchedBy values from source columns. + """ + if self.dagster_run.tags.get(USER_TAG): + return GraphenePipelineTag(key=USER_TAG, value=self.dagster_run.tags[USER_TAG]) + if self.dagster_run.tags.get(SCHEDULE_NAME_TAG): + return GraphenePipelineTag( + key=SCHEDULE_NAME_TAG, value=self.dagster_run.tags[SCHEDULE_NAME_TAG] + ) + if self.dagster_run.tags.get(SENSOR_NAME_TAG): + return GraphenePipelineTag( + key=SENSOR_NAME_TAG, value=self.dagster_run.tags[SENSOR_NAME_TAG] + ) + if self.dagster_run.tags.get(AUTO_MATERIALIZE_TAG): + return GraphenePipelineTag( + key=AUTO_MATERIALIZE_TAG, value=self.dagster_run.tags[AUTO_MATERIALIZE_TAG] + ) + if self.dagster_run.tags.get("dagster/created_by") == "auto_materialize": + return GraphenePipelineTag( + key="dagster/created_by", value=self.dagster_run.tags["dagster/created_by"] + ) + if self.dagster_run.tags.get(AUTO_OBSERVE_TAG): + return GraphenePipelineTag( + key=AUTO_OBSERVE_TAG, value=self.dagster_run.tags[AUTO_OBSERVE_TAG] + ) + return GraphenePipelineTag(key="manual", value="") + def resolve_rootRunId(self, _graphene_info: ResolveInfo): return self.dagster_run.root_run_id diff --git a/python_modules/dagster-graphql/dagster_graphql/schema/runs_feed.py b/python_modules/dagster-graphql/dagster_graphql/schema/runs_feed.py index 112ee46f89a03..b05b10eb6d9cb 100644 --- a/python_modules/dagster-graphql/dagster_graphql/schema/runs_feed.py +++ b/python_modules/dagster-graphql/dagster_graphql/schema/runs_feed.py @@ -17,6 +17,7 @@ class GrapheneRunsFeedEntry(graphene.Interface): assetCheckSelection = graphene.List( graphene.NonNull("dagster_graphql.schema.asset_checks.GrapheneAssetCheckHandle") ) + launchedBy = graphene.NonNull("dagster_graphql.schema.tags.GraphenePipelineTag") class Meta: name = "RunsFeedEntry"