Skip to content

Commit

Permalink
Add "assets" resolver to GrapheneAssetSelection (#19771)
Browse files Browse the repository at this point in the history
Summary:
Will allow us to break out the list of asset keys in the sensor view by
whether or not they have an AMP policy.

Test Plan: BK

## Summary & Motivation

## How I Tested These Changes
  • Loading branch information
gibsondan authored Feb 13, 2024
1 parent fbf58b9 commit 144a6cc
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.

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

2 changes: 2 additions & 0 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 @@ -3,13 +3,15 @@
from dagster._core.definitions.external_asset_graph import ExternalAssetGraph
from dagster._core.host_representation.external import ExternalRepository

from ..implementation.fetch_assets import get_asset_nodes_by_asset_key
from .asset_key import GrapheneAssetKey
from .util import non_null_list


class GrapheneAssetSelection(graphene.ObjectType):
assetSelectionString = graphene.String()
assetKeys = non_null_list(GrapheneAssetKey)
assets = non_null_list("dagster_graphql.schema.pipelines.pipeline.GrapheneAsset")

def __init__(self, asset_selection: AssetSelection, external_repository: ExternalRepository):
self._asset_selection = asset_selection
Expand All @@ -25,5 +27,16 @@ def resolve_assetKeys(self, _graphene_info):
for asset_key in self._asset_selection.resolve(asset_graph)
]

def resolve_assets(self, graphene_info):
from dagster_graphql.schema.pipelines.pipeline import GrapheneAsset

asset_graph = ExternalAssetGraph.from_external_repository(self._external_repository)
asset_nodes_by_asset_key = get_asset_nodes_by_asset_key(graphene_info)

return [
GrapheneAsset(key=asset_key, definition=asset_nodes_by_asset_key.get(asset_key))
for asset_key in self._asset_selection.resolve(asset_graph)
]

class Meta:
name = "AssetSelection"
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@
assetKeys {
path
}
assets {
key {
path
}
definition {
assetKey {
path
}
}
}
}
}
}
Expand Down Expand Up @@ -1420,3 +1430,9 @@ def test_asset_selection(graphql_context):
assert result.data["sensorOrError"]["assetSelection"]["assetKeys"] == [
{"path": ["fresh_diamond_bottom"]}
]
assert result.data["sensorOrError"]["assetSelection"]["assets"] == [
{
"key": {"path": ["fresh_diamond_bottom"]},
"definition": {"assetKey": {"path": ["fresh_diamond_bottom"]}},
}
]

1 comment on commit 144a6cc

@github-actions
Copy link

Choose a reason for hiding this comment

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

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-21u3rs7jn-elementl.vercel.app

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

Please sign in to comment.