Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gql] Expose partition mapping on AssetDependency #18119

Merged
merged 6 commits into from
Nov 27, 2023

Conversation

clairelin135
Copy link
Contributor

@clairelin135 clairelin135 commented Nov 17, 2023

Adds backend support to resolve #15720

This PR exposes the partition mapping on GrapheneAssetDependency, which represents the "edge" in between an asset and its upstream. The partition mapping is only returned if it is defined on the asset (and not inferred). The reasoning here is to avoid introducing complexity in the UI when the user hasn't provided an explicit definition.

It adds descriptions for partition mappings in case if we'd like to display that.

@clairelin135
Copy link
Contributor Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

Copy link

github-actions bot commented Nov 17, 2023

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-g17yigm3v-elementl.vercel.app
https://11-16-claire-expose-partition-mapping-gql.core-storybook.dagster-docs.io

Built with commit aeb1b72.
This pull request is being automatically deployed with vercel-action

@clairelin135 clairelin135 force-pushed the 11-16-claire/expose-partition-mapping-gql branch from 5ccccdd to 89346f7 Compare November 17, 2023 18:40
@clairelin135 clairelin135 marked this pull request as ready for review November 17, 2023 18:56
Copy link
Contributor

@sryza sryza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These description strings are great.

@@ -159,6 +166,11 @@ def resolve_asset(self, _graphene_info: ResolveInfo):
materialization_loader=self._latest_materialization_loader,
)

def resolve_partitionMapping(self, _graphene_info: ResolveInfo):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we haven't been super rigorous about this in the past, but I think it's worth adding a return type annotation here.



class GraphenePartitionMapping(graphene.ObjectType):
name = graphene.NonNull(graphene.String)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling this class_name would be more clear.

@@ -191,6 +197,9 @@ def get_downstream_partitions_for_partitions(
) -> PartitionsSubset:
raise NotImplementedError()

def __str__(self) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calling this description would be better, because it allows __str__ to show a more Dagster-developer-accessible version of the class's representation (with the class name and attributes).

@@ -292,6 +304,9 @@ def get_downstream_partitions_for_partitions(
)
return downstream_partitions_def.empty_subset()

def __str__(self) -> str:
return f"Each downstream partition depends on the following upstream partitions: {self.partition_keys}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases, this could be a large number of partitions. Should we be concerned?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a little concerning, but for StaticPartitionsDefinitions our description string is all of the keys concatenated with a comma, which is probably worse

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just truncate and add an ellipsis on the front end if the string is too long?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. That sounds fine to me for now.

@@ -728,6 +751,18 @@ def __new__(
),
)

def __str__(self) -> str:
description = "\n ".join(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is complex enough that I think it's worth writing a test for it.

Comment on lines 719 to 721
type PartitionMapping {
name: String!
description: String!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me! I'll have to think about how we show this on a per-dependency basis on the asset details page, but I think this is a great solution.

@clairelin135 clairelin135 force-pushed the 11-16-claire/expose-partition-mapping-gql branch from 89346f7 to a02f8da Compare November 23, 2023 00:32
@clairelin135
Copy link
Contributor Author

@sryza I updated this PR to address your feedback

Copy link

Deploy preview for dagster-university ready!

✅ Preview
https://dagster-university-9yajur0o9-elementl.vercel.app
https://11-16-claire-expose-partition-mapping-gql.dagster-university.dagster-docs.io

Built with commit a02f8da.
This pull request is being automatically deployed with vercel-action

Copy link
Contributor

@sryza sryza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@clairelin135 clairelin135 merged commit c21b2af into master Nov 27, 2023
2 checks passed
@clairelin135 clairelin135 deleted the 11-16-claire/expose-partition-mapping-gql branch November 27, 2023 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show partition mappings in the UI
3 participants