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

New asset catalog page #20210

Merged
merged 5 commits into from
Mar 7, 2024
Merged

New asset catalog page #20210

merged 5 commits into from
Mar 7, 2024

Conversation

clairelin135
Copy link
Contributor

@clairelin135 clairelin135 commented Mar 2, 2024

First stab at displaying the new asset catalog page.

Relies on the existing assetsOrError query to fetch asset definition info, and adds logic to group assets by code location / owner / etc. This will enable changes to this view, i.e. displaying a tooltip of the asset keys per group, if desired.

Tagging others on this PR to get thoughts so far on the existing implementation.

Next steps:

  • Add tests for this component
  • Unify styling for UserDisplay component across core and cloud. Currently they display differently.
  • Supporting asset search
  • Displaying a background for the search section

Outstanding questions:

  • How do we handle large numbers of assets on this page? Do we need to implement some way to minimize each section, or paginate?
image

Copy link

github-actions bot commented Mar 2, 2024

Deploy preview for dagit-storybook ready!

✅ Preview
https://dagit-storybook-2qb86yz26-elementl.vercel.app
https://claire-asset-overview-page.components-storybook.dagster-docs.io

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

Copy link

github-actions bot commented Mar 2, 2024

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-99f7930l1-elementl.vercel.app
https://claire-asset-overview-page.core-storybook.dagster-docs.io

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

@clairelin135 clairelin135 force-pushed the claire/asset-overview-page branch from 88f4ede to 9989084 Compare March 4, 2024 18:06
@clairelin135
Copy link
Contributor Author

clairelin135 commented Mar 4, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @clairelin135 and the rest of your teammates on Graphite Graphite

Copy link
Member

@hellendag hellendag left a comment

Choose a reason for hiding this comment

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

Nice! I've got some comments and requests in line. :)

@@ -37,9 +38,15 @@ export const BaseTag = (props: Props) => {
rightIcon,
label,
tooltipText,
fontSize = '12px',
Copy link
Member

Choose a reason for hiding this comment

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

Can you share a screenshot of where this change is needed? It's surprising to me that we would need to modify core components for this UI.

If it does need to be changed, can you separate the ui-components change into its own PR, with an added Storybook example to demonstrate the new value?

Copy link
Contributor Author

@clairelin135 clairelin135 Mar 5, 2024

Choose a reason for hiding this comment

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

Without it, owners that don't exist as users display in a smaller font size:

Screenshot 2024-03-05 at 1 00 28 PM

Though perhaps we should not use a BaseTag for the OSS user display component and instead make the component match the internal implementation: https://github.com/dagster-io/internal/blob/87c74af6b49beef51c95b398cc0c1713b7795d42/dagster-cloud/js_modules/app-cloud/src/settings/audit-log/AuditLogUserDisplay.tsx#L29-L34

Regardless, will break this out into a separate diff.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think probably Tag (or BaseTag) aren't quite right for it, if all you really need is the subway dot and the team/user name. UserDisplayForPermissions might be close.

const assetCountByCodeLocation: Record<string, number> = {};

assets.forEach((asset) => {
if (asset.definition) {
Copy link
Member

Choose a reason for hiding this comment

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

Since it looks like you don't really need to run this forEach function if there's no asset.definition, perhaps use an assets.filter first?

Comment on lines +36 to +37
repositoryLocationName: string;
repositoryName: string;
Copy link
Member

Choose a reason for hiding this comment

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

RepoAddress is nice for combining these values.

Copy link
Contributor Author

@clairelin135 clairelin135 Mar 5, 2024

Choose a reason for hiding this comment

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

I did want to use RepoAddress here too, but we build a URL linking to the asset graph filtered view from this object that relies on these specific key names.

If desired, I can use RepoAddress here and then change the key names when we build the link

Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah, I just mean that RepoAddress is nice for representing the combined strings in a single value to be passed around. Then when it needs to be stringified, we have the utilities to do that. Mostly I'd just want consistency, to having places where we are manually concatting or interpolating these values in a way that differs from how we represent RepoAddress strings elsewhere.

<SectionBody>
{Object.entries(assetCountBySection.countsByComputeKind).map(
([label, count], idx) => (
<CountForAssetType key={idx} assetsCount={count}>
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

@@ -616,6 +616,25 @@ export const OpTags = React.memo(({tags, style, reduceColor, reduceText}: OpTags
);
});

export const TagIcon = React.memo(({tag_label}: {tag_label: string}) => {
Copy link
Member

Choose a reason for hiding this comment

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

Always use camelCase for JS variable names.

([label, count], idx) => (
<CountForAssetType key={idx} assetsCount={count}>
<Box flex={{direction: 'row', gap: 4, alignItems: 'center'}}>
<TagIcon tag_label={label} />
Copy link
Member

Choose a reason for hiding this comment

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

See comment below re: JS var naming conventions.

<SectionHeader sectionName="Asset groups" />
<SectionBody>
{assetCountBySection.countPerAssetGroup.map(
(assetGroupCount: CountPerGroupName, idx) => (
Copy link
Member

Choose a reason for hiding this comment

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

You probably shouldn't have to annotate this type, TS should be able to infer it.

@bengotow
Copy link
Collaborator

bengotow commented Mar 6, 2024

Looks like Dish and Marco beat me to the PR reviews - this is looking awesome! 🙌

@clairelin135
Copy link
Contributor Author

Thanks @hellendag and @salazarm for all the feedback, super helpful to get a better understanding of best practices here.

I updated the PR per the feedback, I think it's ready for another look!

@clairelin135 clairelin135 force-pushed the claire/asset-overview-page branch from ebfc8fc to 176d325 Compare March 6, 2024 00:50
@clairelin135 clairelin135 force-pushed the claire/asset-overview-page branch from 176d325 to b29093f Compare March 6, 2024 18:23
Copy link
Contributor

@salazarm salazarm left a comment

Choose a reason for hiding this comment

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

This looks great!

Copy link
Contributor

@salazarm salazarm left a comment

Choose a reason for hiding this comment

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

How will we get to this page? I didn't see any links to it in the other PR

Copy link
Member

@hellendag hellendag left a comment

Choose a reason for hiding this comment

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

Sweet. Let's ship and iterate. Nice work!

<AssetPageHeader
assetKey={{path: currentPath}}
right={
<Box flex={{gap: 12, alignItems: 'center'}}>
Copy link
Member

Choose a reason for hiding this comment

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

With only one item in the flex container, the gap shouldn't be necessary here.

timeZone: timezone === 'Automatic' ? browserTimezone() : timezone,
}),
);
if (hour < 12) {
Copy link
Member

Choose a reason for hiding this comment

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

Should it be Good morning when it's like midnight or 2am? 🤔

Comment on lines +111 to +115
new Date().toLocaleTimeString('en-US', {
hour: '2-digit',
hourCycle: 'h23',
timeZone: timezone === 'Automatic' ? browserTimezone() : timezone,
}),
Copy link
Member

Choose a reason for hiding this comment

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

No need to change anything here, but a couple notes:

  • For future reference, these formatters can be expensive to set up. It's often a good idea to create a (memoized or static) single formatter object for reuse and call format on it.
  • The approach of parsing out the number from the string looks good to me. Alternatively, if we chose not to care about the user's timezone setting, you could use the getHours() method on the Date object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the heads up here.

Which item exactly is the formatter? Is it the date object?

@@ -8,6 +8,7 @@ const WorkspaceRoot = lazy(() => import('../workspace/WorkspaceRoot'));
const OverviewRoot = lazy(() => import('../overview/OverviewRoot'));
const FallthroughRoot = lazy(() => import('./FallthroughRoot'));
const AssetsCatalogRoot = lazy(() => import('../assets/AssetsCatalogRoot'));
const AssetsOverview = lazy(() => import('../assets/AssetsOverview'));
Copy link
Member

Choose a reason for hiding this comment

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

Not used? Does this need a route added to the Switch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good catch, this will only be displayed on cloud so this line isn't needed

@clairelin135
Copy link
Contributor Author

@salazarm no links pointing to this page yet. I was thinking that we'd only swap it with the current assets table view once the search UI is out.

@clairelin135 clairelin135 force-pushed the claire/asset-overview-page branch from 8cb67cf to 67a2a67 Compare March 7, 2024 18:45
@clairelin135 clairelin135 merged commit 258bc71 into master Mar 7, 2024
2 checks passed
@clairelin135 clairelin135 deleted the claire/asset-overview-page branch March 7, 2024 18:56
PedramNavid pushed a commit that referenced this pull request Mar 28, 2024
First stab at displaying the new asset catalog page.

Relies on the existing `assetsOrError` query to fetch asset definition
info, and adds logic to group assets by code location / owner / etc.
This will enable changes to this view, i.e. displaying a tooltip of the
asset keys per group, if desired.

Tagging others on this PR to get thoughts so far on the existing
implementation.

Next steps:
- Add tests for this component
- Unify styling for `UserDisplay` component across core and cloud.
Currently they display differently.
- Supporting asset search
- Displaying a background for the search section

Outstanding questions:
- How do we handle large numbers of assets on this page? Do we need to
implement some way to minimize each section, or paginate?

<img width="1457" alt="image"
src="https://github.com/dagster-io/dagster/assets/29110579/de586d6b-8ee9-4f62-9891-b491e937f562">
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.

4 participants