Skip to content

Commit

Permalink
[dagit] Replace opName with opNames everywhere (#7977)
Browse files Browse the repository at this point in the history
  • Loading branch information
hellendag committed May 20, 2022
1 parent 8f375c4 commit 605d274
Show file tree
Hide file tree
Showing 25 changed files with 22 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ const opsInRange = (
return [];
}
if (from.id === to.id) {
return [to.definition.opName!];
return [...to.definition.opNames];
}

if (seen.length === 0 && graphDirectionOf({graph, from, to}) === 'upstream') {
Expand All @@ -684,7 +684,7 @@ const opsInRange = (
}
const result: string[] = opsInRange({graph, from: node, to}, [...seen, from.id]);
if (result.length) {
ledToTarget.push(from.definition.opName!, ...result);
ledToTarget.push(...from.definition.opNames, ...result);
}
}
return uniq(ledToTarget);
Expand Down
12 changes: 7 additions & 5 deletions js_modules/dagit/packages/core/src/asset-graph/AssetNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export const AssetNode: React.FC<{
padded?: boolean;
inAssetCatalog?: boolean;
}> = React.memo(({definition, selected, liveData, inAssetCatalog, padded = true}) => {
const stepKey = definition.opName || '';
const firstOp = definition.opNames.length ? definition.opNames[0] : null;

// Used for linking to the run with this step highlighted. We only support highlighting
// a single step, so just use the first one.
const stepKey = firstOp || '';

const displayName = withMiddleTruncation(displayNameForAssetKey(definition.assetKey), {
maxLength: ASSET_NODE_NAME_MAX_LENGTH,
Expand Down Expand Up @@ -64,15 +68,15 @@ export const AssetNode: React.FC<{
{definition.description && !inAssetCatalog && (
<Description>{markdownToPlaintext(definition.description).split('\n')[0]}</Description>
)}
{definition.opName && displayName !== definition.opName && (
{firstOp && displayName !== firstOp && (
<Description>
<Box
flex={{gap: 4, alignItems: 'flex-end'}}
style={{marginLeft: -2, overflow: 'hidden'}}
>
<Icon name="op" size={16} />
<div style={{minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis'}}>
{definition.opName}
{firstOp}
</div>
</Box>
</Description>
Expand Down Expand Up @@ -201,7 +205,6 @@ export const AssetRunLink: React.FC<{
export const ASSET_NODE_LIVE_FRAGMENT = gql`
fragment AssetNodeLiveFragment on AssetNode {
id
opName
opNames
repository {
id
Expand All @@ -220,7 +223,6 @@ export const ASSET_NODE_FRAGMENT = gql`
fragment AssetNodeFragment on AssetNode {
id
graphName
opName
opNames
description
partitionDefinition
Expand Down
8 changes: 4 additions & 4 deletions js_modules/dagit/packages/core/src/asset-graph/Utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export interface GraphData {
downstream: {[assetId: GraphId]: {[childAssetId: GraphId]: boolean}};
upstream: {[assetId: GraphId]: {[parentAssetId: GraphId]: boolean}};
}
export const isSourceAsset = (node: {jobNames: string[]; opName: string | null}) => {
return node.jobNames.length === 0 && !node.opName;
export const isSourceAsset = (node: {jobNames: string[]; opNames: string[]}) => {
return node.jobNames.length === 0 && !node.opNames.length;
};

export function identifyBundles(assetIds: string[]) {
Expand Down Expand Up @@ -244,8 +244,8 @@ export const buildLiveData = (
const isPartitioned = graphNode.definition.partitionDefinition;
const repo = repos.find((r) => r.id === liveNode.repository.id);

const runs = repo?.inProgressRunsByStep.find((r) => r.stepKey === liveNode.opName);
const info = repo?.latestRunByStep.find((r) => r.stepKey === liveNode.opName);
const runs = repo?.inProgressRunsByStep.find((r) => liveNode.opNames.includes(r.stepKey));
const info = repo?.latestRunByStep.find((r) => liveNode.opNames.includes(r.stepKey));

const latestRunForStepKey = info?.__typename === 'LatestRun' ? info.run : null;

Expand Down
7 changes: 4 additions & 3 deletions js_modules/dagit/packages/core/src/asset-graph/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const layoutAssetGraph = (graphData: GraphData): AssetGraphLayout => {
});
g.setDefaultEdgeLabel(() => ({}));

const shouldRender = (node?: GraphNode) => node && node.definition.opName;
const shouldRender = (node?: GraphNode) => node && node.definition.opNames.length > 0;

// Add all the nodes to the graph
Object.values(graphData.nodes)
Expand Down Expand Up @@ -199,15 +199,16 @@ const DISPLAY_NAME_PX_PER_CHAR = 8.0;

export const getAssetNodeDimensions = (def: {
assetKey: {path: string[]};
opName: string | null;
opNames: string[];
description?: string | null;
}) => {
let height = 75;
if (def.description) {
height += 25;
}
const displayName = displayNameForAssetKey(def.assetKey);
if (def.opName && displayName !== def.opName) {
const firstOp = def.opNames[0];
if (firstOp && displayName !== firstOp) {
height += 25;
}
return {
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 @@ -39,7 +39,6 @@ const ASSET_FOR_NAVIGATION_QUERY = gql`
id
definition {
id
opName
opNames
jobNames
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const AssetDefinedInMultipleReposNotice: React.FC<{
: [];

const otherReposWithAsset = otherRepos.filter((r) =>
r.assetNodes.some((a) => a.id === assetId && a.opName),
r.assetNodes.some((a) => a.id === assetId && a.opNames.length),
);

if (otherReposWithAsset.length === 0) {
Expand Down Expand Up @@ -59,7 +59,6 @@ const ASSET_ID_SCAN_QUERY = gql`
}
assetNodes {
id
opName
opNames
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ export const ASSET_NODE_DEFINITION_FRAGMENT = gql`
id
description
graphName
opName
opNames
jobNames
repository {
Expand All @@ -259,7 +258,6 @@ export const ASSET_NODE_DEFINITION_FRAGMENT = gql`
dependencies {
asset {
id
opName
opNames
jobNames
...AssetNodeFragment
Expand All @@ -269,7 +267,6 @@ export const ASSET_NODE_DEFINITION_FRAGMENT = gql`
dependedBy {
asset {
id
opName
opNames
jobNames
...AssetNodeFragment
Expand Down
3 changes: 1 addition & 2 deletions js_modules/dagit/packages/core/src/assets/AssetTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const AssetEntryRow: React.FC<{
<td>
{asset ? (
<Box flex={{gap: 8, alignItems: 'center'}}>
{asset.definition?.opName ? (
{asset.definition?.opNames.length ? (
<Link
to={instanceAssetsExplorerPathToURL({
opsQuery: `++"${tokenForAssetKey({path})}"++`,
Expand Down Expand Up @@ -292,7 +292,6 @@ export const ASSET_TABLE_FRAGMENT = gql`
}
definition {
id
opName
opNames
description
repository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ interface Props {
setOpen: (open: boolean) => void;
repoAddress: RepoAddress;
assetJobName: string;
assets: {assetKey: AssetKey; opName: string | null; partitionDefinition: string | null}[];
assets: {assetKey: AssetKey; opNames: string[]; partitionDefinition: string | null}[];
upstreamAssetKeys: AssetKey[]; // single layer of upstream dependencies
}

Expand Down Expand Up @@ -199,7 +199,7 @@ const LaunchAssetChoosePartitionsDialogBody: React.FC<Props> = ({

const tags = [...partition.tagsOrError.results];
const runConfigData = yaml.parse(partition.runConfigOrError.yaml || '') || {};
const stepKeys = assets.map((a) => a.opName!);
const stepKeys = assets.map((a) => a.opNames).flat();

const launchResult = await client.mutate<
LaunchPipelineExecution,
Expand Down Expand Up @@ -248,7 +248,7 @@ const LaunchAssetChoosePartitionsDialogBody: React.FC<Props> = ({
},
},
partitionNames: selected,
reexecutionSteps: assets.map((a) => a.opName!),
reexecutionSteps: assets.map((a) => a.opNames).flat(),
fromFailure: false,
tags: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {AssetKey} from './types';

type AssetMinimal = {
assetKey: {path: string[]};
opName: string | null;
opNames: string[];
jobNames: string[];
partitionDefinition: string | null;
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: 0 additions & 3 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.

Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ export const GRAPH_EXPLORER_FRAGMENT = gql`
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 @@ -26,7 +26,6 @@ const REPOSITORY_ASSETS_LIST_QUERY = gql`
assetKey {
path
}
opName
opNames
description
repository {
Expand Down

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

0 comments on commit 605d274

Please sign in to comment.