diff --git a/docs/content/guides/dagster/code-references.mdx b/docs/content/guides/dagster/code-references.mdx index 066e73902db7e..5f9e15fcdb6c6 100644 --- a/docs/content/guides/dagster/code-references.mdx +++ b/docs/content/guides/dagster/code-references.mdx @@ -9,10 +9,10 @@ title: Linking to assets' code with code references | Dagster Docs development. This guide will be updated as we roll out new features. -Attaching code reference metadata to your Dagster assets allows you to easily view those assets' source code from the Dagster UI: +Attaching code reference metadata to your Dagster asset definitions allows you to easily view those assets' source code from the Dagster UI: - **In local development**, navigate directly to the code backing an asset in your editor -- **In Dagster+**, link to source code in your source control repository to see the full change history for an asset +- **In your production environment**, link to source code in your source control repository to see the full change history for an asset In this guide, we'll show you how to automatically and manually attach code references to your Dagster assets. @@ -22,7 +22,7 @@ In this guide, we'll show you how to automatically and manually attach code refe To complete the steps in this guide, you'll need: -- A Dagster repository with assets that you want to link to code +- A set of Dagster asset definitions that you want to link to code - Dagster version `1.7.6` or newer --- @@ -44,14 +44,7 @@ def my_asset(): ... def another_asset(): ... -defs = Definitions( - assets=with_source_code_references( - [ - my_asset, - another_asset, - ] - ) -) +defs = Definitions(assets=with_source_code_references([my_asset, another_asset])) ``` A link to the asset's source in `with_source_code_references.py` will then be visible in the **Asset Catalog** view in the Dagster UI: @@ -71,14 +64,13 @@ A link to the asset's source in `with_source_code_references.py` will then be vi In some cases, you may want to manually attach code references to your asset definitions. Some assets may have a more complex source structure, such as an asset whose definition is spread across multiple Python source files or an asset which is partially defined with a `.sql` model file. -To manually attach code references to an asset definition, use an instance of `dagster._core.definitions.metadata.CodeReferencesMetadataSet`. You can then choose to augment these manual references with `with_source_code_references`: +To manually attach code references to an asset definition, use `CodeReferencesMetadataValue`. You can then choose to augment these manual references with `with_source_code_references`: ```python file=/guides/dagster/code_references/manual_references.py import os from dagster import Definitions, asset from dagster._core.definitions.metadata import ( - CodeReferencesMetadataSet, CodeReferencesMetadataValue, LocalFileCodeReference, with_source_code_references, @@ -87,18 +79,14 @@ from dagster._core.definitions.metadata import ( @asset( metadata={ - **CodeReferencesMetadataSet( - code_references=CodeReferencesMetadataValue( - code_references=[ - LocalFileCodeReference( - file_path=os.path.join( - os.path.dirname(__file__), "source.yaml" - ), - line_number=1, - label="Model YAML", - ) - ] - ) + "dagster/code_references": CodeReferencesMetadataValue( + code_references=[ + LocalFileCodeReference( + file_path=os.path.join(os.path.dirname(__file__), "source.yaml"), + line_number=1, + label="Model YAML", + ) + ] ) } ) diff --git a/examples/docs_snippets/docs_snippets/guides/dagster/code_references/manual_references.py b/examples/docs_snippets/docs_snippets/guides/dagster/code_references/manual_references.py index ed17d60752214..bb7071ae0125f 100644 --- a/examples/docs_snippets/docs_snippets/guides/dagster/code_references/manual_references.py +++ b/examples/docs_snippets/docs_snippets/guides/dagster/code_references/manual_references.py @@ -2,7 +2,6 @@ from dagster import Definitions, asset from dagster._core.definitions.metadata import ( - CodeReferencesMetadataSet, CodeReferencesMetadataValue, LocalFileCodeReference, with_source_code_references, @@ -11,18 +10,14 @@ @asset( metadata={ - **CodeReferencesMetadataSet( - code_references=CodeReferencesMetadataValue( - code_references=[ - LocalFileCodeReference( - file_path=os.path.join( - os.path.dirname(__file__), "source.yaml" - ), - line_number=1, - label="Model YAML", - ) - ] - ) + "dagster/code_references": CodeReferencesMetadataValue( + code_references=[ + LocalFileCodeReference( + file_path=os.path.join(os.path.dirname(__file__), "source.yaml"), + line_number=1, + label="Model YAML", + ) + ] ) } ) diff --git a/examples/docs_snippets/docs_snippets/guides/dagster/code_references/with_source_code_references.py b/examples/docs_snippets/docs_snippets/guides/dagster/code_references/with_source_code_references.py index f9296814e6f19..0588ad850e02d 100644 --- a/examples/docs_snippets/docs_snippets/guides/dagster/code_references/with_source_code_references.py +++ b/examples/docs_snippets/docs_snippets/guides/dagster/code_references/with_source_code_references.py @@ -10,11 +10,4 @@ def my_asset(): ... def another_asset(): ... -defs = Definitions( - assets=with_source_code_references( - [ - my_asset, - another_asset, - ] - ) -) +defs = Definitions(assets=with_source_code_references([my_asset, another_asset]))