Skip to content

Commit

Permalink
[dagit] Add opNames field to AssetNode (#7565)
Browse files Browse the repository at this point in the history
  • Loading branch information
hellendag committed Apr 25, 2022
1 parent 5480b04 commit 2f7ccad
Show file tree
Hide file tree
Showing 23 changed files with 46 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ const AssetGraphExplorerWithData: React.FC<
e.stopPropagation();

const token = tokenForAssetKey(assetKey);
let clicked: {opName: string | null; jobName: string | null} = {opName: null, jobName: null};
let clicked: {opNames: string[]; jobName: string | null} = {opNames: [], jobName: null};

if (node?.definition) {
// The asset's defintion was provided in our job.assetNodes query. Show it in the current graph.
clicked = {opName: node.definition.opName, jobName: explorerPath.pipelineName};
clicked = {opNames: node.definition.opNames, jobName: explorerPath.pipelineName};
} else {
// The asset's definition was not provided in our query for job.assetNodes. This means
// it's in another job or is a source asset not defined in the repository at all.
Expand All @@ -185,7 +185,7 @@ const AssetGraphExplorerWithData: React.FC<
let nextOpsNameSelection = token;

// If no opName, this is a source asset.
if (clicked.jobName !== explorerPath.pipelineName || !clicked.opName) {
if (clicked.jobName !== explorerPath.pipelineName || !clicked.opNames.length) {
nextOpsQuery = '';
} else if (e.shiftKey || e.metaKey) {
const existing = explorerPath.opNames[0].split(',');
Expand Down Expand Up @@ -296,7 +296,7 @@ const AssetGraphExplorerWithData: React.FC<
}}
style={{overflow: 'visible'}}
>
{!graphNode || !graphNode.definition.opName ? (
{!graphNode || !graphNode.definition.opNames.length ? (
<ForeignNode assetKey={{path}} />
) : (
<AssetNode
Expand All @@ -323,8 +323,8 @@ const AssetGraphExplorerWithData: React.FC<
{
...explorerPath,
opNames:
selectedGraphNodes.length && selectedGraphNodes[0].definition.opName
? [selectedGraphNodes[0].definition.opName]
selectedGraphNodes.length && selectedGraphNodes[0].definition.opNames.length
? selectedGraphNodes[0].definition.opNames
: [],
},
'replace',
Expand Down
2 changes: 2 additions & 0 deletions js_modules/dagit/packages/core/src/asset-graph/AssetNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export const ASSET_NODE_LIVE_FRAGMENT = gql`
fragment AssetNodeLiveFragment on AssetNode {
id
opName
opNames
repository {
id
}
Expand All @@ -191,6 +192,7 @@ export const ASSET_NODE_FRAGMENT = gql`
fragment AssetNodeFragment on AssetNode {
id
opName
opNames
description
partitionDefinition
computeKind
Expand Down

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

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

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

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

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 @@ -12,16 +12,16 @@ export function useFindAssetInWorkspace() {
const apollo = useApolloClient();

return React.useCallback(
async (key: AssetKeyInput): Promise<{opName: string | null; jobName: string | null}> => {
async (key: AssetKeyInput): Promise<{opNames: string[]; jobName: string | null}> => {
const {data} = await apollo.query<AssetForNavigationQuery, AssetForNavigationQueryVariables>({
query: ASSET_FOR_NAVIGATION_QUERY,
variables: {key},
});
if (data?.assetOrError.__typename === 'Asset' && data?.assetOrError.definition) {
const def = data.assetOrError.definition;
return {opName: def.opName, jobName: def.jobNames[0] || null};
return {opNames: def.opNames, jobName: def.jobNames[0] || null};
}
return {opName: null, jobName: null};
return {opNames: [], jobName: null};
},
[apollo],
);
Expand All @@ -36,6 +36,7 @@ const ASSET_FOR_NAVIGATION_QUERY = gql`
definition {
id
opName
opNames
jobNames
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const ASSET_ID_SCAN_QUERY = gql`
assetNodes {
id
opName
opNames
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export const ASSET_NODE_DEFINITION_FRAGMENT = gql`
id
description
opName
opNames
jobNames
repository {
id
Expand All @@ -219,6 +220,7 @@ export const ASSET_NODE_DEFINITION_FRAGMENT = gql`
asset {
id
opName
opNames
jobNames
...AssetNodeFragment
...AssetNodeLiveFragment
Expand All @@ -228,6 +230,7 @@ export const ASSET_NODE_DEFINITION_FRAGMENT = gql`
asset {
id
opName
opNames
jobNames
...AssetNodeFragment
...AssetNodeLiveFragment
Expand Down
1 change: 1 addition & 0 deletions js_modules/dagit/packages/core/src/assets/AssetTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export const ASSET_TABLE_FRAGMENT = gql`
definition {
id
opName
opNames
description
repository {
id
Expand Down

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

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

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

3 changes: 3 additions & 0 deletions js_modules/dagit/packages/core/src/assets/types/AssetQuery.ts

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

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

1 change: 1 addition & 0 deletions js_modules/dagit/packages/core/src/graphql/schema.graphql

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 @@ -319,6 +319,7 @@ export const GRAPH_EXPLORER_ASSET_NODE_FRAGMENT = gql`
fragment GraphExplorerAssetNodeFragment on AssetNode {
id
opName
opNames
assetKey {
path
}
Expand Down

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

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 @@ -27,6 +27,7 @@ const REPOSITORY_ASSETS_LIST_QUERY = gql`
path
}
opName
opNames
description
repository {
id
Expand Down

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 @@ -101,6 +101,7 @@ class GrapheneAssetNode(graphene.ObjectType):
metadata_entries = non_null_list(GrapheneMetadataEntry)
op = graphene.Field(GrapheneSolidDefinition)
opName = graphene.String()
opNames = non_null_list(graphene.String)
partitionKeys = non_null_list(graphene.String)
partitionDefinition = graphene.String()
repository = graphene.NonNull(lambda: external.GrapheneRepository)
Expand Down Expand Up @@ -368,6 +369,13 @@ def resolve_op(
else:
return None

def resolve_opNames(self, _graphene_info) -> List[str]:
# todo OwenKephart: Return the correct list of op names.
if self._external_asset_node.op_name:
return [self._external_asset_node.op_name]
else:
return []

def resolve_partitionDefinition(self, _graphene_info) -> Optional[str]:
partitions_def_data = self._external_asset_node.partitions_def_data
if partitions_def_data:
Expand Down

0 comments on commit 2f7ccad

Please sign in to comment.