-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[1/n] Add with_source_code_references
fn to add source location metadata to assets
#21465
Conversation
ebafe76
to
e032f1d
Compare
e032f1d
to
d0ff45e
Compare
04406c7
to
859f329
Compare
@@ -257,6 +257,8 @@ export const MetadataEntry = ({ | |||
</IconButton> | |||
</Group> | |||
); | |||
case 'SourceMetadataEntry': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minimal change to placate bk, actual tsx changes are stacked
Deploy preview for dagit-core-storybook ready! ✅ Preview Built with commit 8d6aefa. |
0b354bc
to
d46bc1d
Compare
python_modules/dagster/dagster/_core/definitions/metadata/__init__.py
Outdated
Show resolved
Hide resolved
python_modules/dagster/dagster/_core/definitions/metadata/__init__.py
Outdated
Show resolved
Hide resolved
python_modules/dagster/dagster/_core/definitions/metadata/__init__.py
Outdated
Show resolved
Hide resolved
python_modules/dagster/dagster/_core/definitions/metadata/__init__.py
Outdated
Show resolved
Hide resolved
python_modules/dagster/dagster/_core/definitions/metadata/__init__.py
Outdated
Show resolved
Hide resolved
python_modules/dagster/dagster/_core/definitions/metadata/__init__.py
Outdated
Show resolved
Hide resolved
python_modules/dagster/dagster/_core/definitions/metadata/__init__.py
Outdated
Show resolved
Hide resolved
python_modules/dagster/dagster_tests/asset_defs_tests/test_asset_defs_source_metadata.py
Outdated
Show resolved
Hide resolved
d46bc1d
to
bda13a9
Compare
bda13a9
to
9fb26a5
Compare
0a18e77
to
f7932d1
Compare
python_modules/dagster/dagster/_core/definitions/metadata/source_code.py
Outdated
Show resolved
Hide resolved
python_modules/dagster/dagster/_core/definitions/metadata/source_code.py
Outdated
Show resolved
Hide resolved
## Summary Some restructuring/cleanup to make #21465 a bit easier
f7932d1
to
4afa85d
Compare
0a9304d
to
c9a6c28
Compare
PR is updated to move the label to the
This is a good idea, will incorporate in downstream UI PRs.
Agreed - right now the feature is explicitly opt-in because of the potential cost of |
8e20595
to
fceb4be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely. Thanks for working through this.
fceb4be
to
33d4e57
Compare
Deploy preview for dagster-university ready! ✅ Preview Built with commit 33d4e57. |
33d4e57
to
180d3e7
Compare
Merge activity
|
180d3e7
to
8d6aefa
Compare
## Summary & Motivation Displays a button link to view an asset in the user's editor, for code link metadata specified in #21465. Also hides this metadata from the table. ```python @asset def my_asset() -> pd.DataFrame: ... with_code_source([my_asset]) ``` <img width="955" alt="Screenshot 2024-04-26 at 3 41 53 PM" src="https://github.com/dagster-io/dagster/assets/10215173/8d846b4d-377b-4a4e-a9bd-69c30eb9bee4"> If the user specifies multiple files, they are displayed with a dropdown: ```python @asset( metadata={ **SourceDataMetadataSet( source_paths={ DEFAULT_SOURCE_FILE_KEY: SourcePathMetadataSet( path_to_module=..., path_from_module=..., line_number=... ), "SQL model": SourcePathMetadataSet( path_to_module=..., path_from_module=..., line_number=... ), } ) } ) def my_two_source_asset() -> pd.DataFrame: ... ``` <img width="248" alt="Screenshot 2024-04-26 at 4 23 55 PM" src="https://github.com/dagster-io/dagster/assets/10215173/16ec33ef-8ade-4b52-97ad-6b0a491b426e">
## Summary Some restructuring/cleanup to make dagster-io#21465 a bit easier
…adata to assets (dagster-io#21465) ## Summary Rework of dagster-io#12096. Adds a `with_source_code_references` wrapper which attaches source code location metadata to the assets which it wraps. Stacked PRs handle displaying it in the UI. Right now, the code source metadata is structured as a list of file references, each includes a path to the source file and and line number, along with an optional label to be shown in the UI. Users can choose to manually add these to their asset definitions, either via decorator or as part of an asset factory. ```python @asset( metadata={ **CodeReferencesMetadataSet( source_data=CodeReferencesMetadataValue( code_references=[ LocalFileSource( file_path=..., line_number=... ), LocalFileSource( label="SQL file", file_path=..., line_number=... ) ] ) ) } ) def my_multiple_source_asset() -> pd.DataFrame: ... ``` The `with_source_code_references` wrapper can be used to automatically attach local file paths and line numbers to assets using `inspect`. This behavior may later become default-on, but for now is explicitly opt-in. ```python @asset def my_asset() -> pd.DataFrame: ... @asset def my_other_asset() -> pd.DataFrame: ... defs = Definitions( assets=with_source_code_references([my_asset, my_other_asset]) ) ``` ## Test Plan New unit tests.
## Summary & Motivation Displays a button link to view an asset in the user's editor, for code link metadata specified in dagster-io#21465. Also hides this metadata from the table. ```python @asset def my_asset() -> pd.DataFrame: ... with_code_source([my_asset]) ``` <img width="955" alt="Screenshot 2024-04-26 at 3 41 53 PM" src="https://github.com/dagster-io/dagster/assets/10215173/8d846b4d-377b-4a4e-a9bd-69c30eb9bee4"> If the user specifies multiple files, they are displayed with a dropdown: ```python @asset( metadata={ **SourceDataMetadataSet( source_paths={ DEFAULT_SOURCE_FILE_KEY: SourcePathMetadataSet( path_to_module=..., path_from_module=..., line_number=... ), "SQL model": SourcePathMetadataSet( path_to_module=..., path_from_module=..., line_number=... ), } ) } ) def my_two_source_asset() -> pd.DataFrame: ... ``` <img width="248" alt="Screenshot 2024-04-26 at 4 23 55 PM" src="https://github.com/dagster-io/dagster/assets/10215173/16ec33ef-8ade-4b52-97ad-6b0a491b426e">
Summary
Rework of #12096. Adds a
with_source_code_references
wrapper which attaches source code location metadata to the assets which it wraps.Stacked PRs handle displaying it in the UI.
Right now, the code source metadata is structured as a list of file references, each includes a path to the source file and and line number, along with an optional label to be shown in the UI. Users can choose to manually add these to their asset definitions, either via decorator or as part of an asset factory.
The
with_source_code_references
wrapper can be used to automatically attach local file paths and line numbers to assets usinginspect
. This behavior may later become default-on, but for now is explicitly opt-in.Test Plan
New unit tests.