diff --git a/docs/content/api/modules.json.gz b/docs/content/api/modules.json.gz index 6fe2eb274022e..7ead3e9f0e440 100644 Binary files a/docs/content/api/modules.json.gz and b/docs/content/api/modules.json.gz differ diff --git a/docs/content/api/searchindex.json.gz b/docs/content/api/searchindex.json.gz index fe34fc9c2aec9..cb9e6e5c4b1aa 100644 Binary files a/docs/content/api/searchindex.json.gz and b/docs/content/api/searchindex.json.gz differ diff --git a/docs/content/api/sections.json.gz b/docs/content/api/sections.json.gz index 541fd641f93f8..acd60a9bed3b8 100644 Binary files a/docs/content/api/sections.json.gz and b/docs/content/api/sections.json.gz differ diff --git a/docs/next/public/objects.inv b/docs/next/public/objects.inv index e9149669890dc..84a6dd893875e 100644 Binary files a/docs/next/public/objects.inv and b/docs/next/public/objects.inv differ diff --git a/python_modules/libraries/dagster-components/dagster_components/__init__.py b/python_modules/libraries/dagster-components/dagster_components/__init__.py index d5eaadc8d1248..6b8efd2aafde0 100644 --- a/python_modules/libraries/dagster-components/dagster_components/__init__.py +++ b/python_modules/libraries/dagster-components/dagster_components/__init__.py @@ -3,7 +3,7 @@ ComponentGenerateRequest as ComponentGenerateRequest, ComponentLoadContext as ComponentLoadContext, ComponentRegistry as ComponentRegistry, - component as component, + component_type as component_type, ) from dagster_components.core.component_defs_builder import ( build_component_defs as build_component_defs, diff --git a/python_modules/libraries/dagster-components/dagster_components/core/component.py b/python_modules/libraries/dagster-components/dagster_components/core/component.py index 2c68dbfb00e16..62cb60ba34135 100644 --- a/python_modules/libraries/dagster-components/dagster_components/core/component.py +++ b/python_modules/libraries/dagster-components/dagster_components/core/component.py @@ -263,11 +263,17 @@ def load_params(self, params_schema: Type[T]) -> T: COMPONENT_REGISTRY_KEY_ATTR = "__dagster_component_registry_key" -def component( - cls: Optional[Type[Component]] = None, - *, - name: Optional[str] = None, -) -> Any: +def component_type(cls: Optional[Type[Component]] = None, *, name: Optional[str] = None) -> Any: + """Decorator for registering a component type. You must annotate a component + type with this decorator in order for it to be inspectable and loaded by tools. + + Args: + cls (Optional[Type[Component]]): The target of the decorator: the component class + to register. The class must inherit from Component. + name (Optional[str]): The name to register the component type under. If not + provided, the name will be the snake-cased version of the class name. The + name is used as a key in operations like scaffolding and loading. + """ if cls is None: def wrapper(actual_cls: Type[Component]) -> Type[Component]: diff --git a/python_modules/libraries/dagster-components/dagster_components/lib/dbt_project.py b/python_modules/libraries/dagster-components/dagster_components/lib/dbt_project.py index fea3551ab2c74..de850ed6e9077 100644 --- a/python_modules/libraries/dagster-components/dagster_components/lib/dbt_project.py +++ b/python_modules/libraries/dagster-components/dagster_components/lib/dbt_project.py @@ -15,7 +15,7 @@ from dagster_components.core.component import ( ComponentGenerateRequest, TemplatedValueResolver, - component, + component_type, ) from dagster_components.core.component_rendering import RenderingScope from dagster_components.core.dsl_schema import AssetAttributes, AssetSpecProcessor, OpSpecBaseModel @@ -70,7 +70,7 @@ def get_group_name(self, dbt_resource_props) -> Optional[str]: ) -@component(name="dbt_project") +@component_type(name="dbt_project") class DbtProjectComponent(Component): params_schema = DbtProjectParams generate_params_schema = DbtGenerateParams diff --git a/python_modules/libraries/dagster-components/dagster_components/lib/definitions_component.py b/python_modules/libraries/dagster-components/dagster_components/lib/definitions_component.py index 3fd59b2ad4e53..5b007064a4132 100644 --- a/python_modules/libraries/dagster-components/dagster_components/lib/definitions_component.py +++ b/python_modules/libraries/dagster-components/dagster_components/lib/definitions_component.py @@ -10,7 +10,12 @@ from pydantic import BaseModel from typing_extensions import Self -from dagster_components import Component, ComponentGenerateRequest, ComponentLoadContext, component +from dagster_components import ( + Component, + ComponentGenerateRequest, + ComponentLoadContext, + component_type, +) from dagster_components.generate import generate_component_yaml @@ -22,7 +27,7 @@ class DefinitionsParamSchema(BaseModel): definitions_path: Optional[str] = None -@component(name="definitions") +@component_type(name="definitions") class DefinitionsComponent(Component): def __init__(self, definitions_path: Path): self.definitions_path = definitions_path diff --git a/python_modules/libraries/dagster-components/dagster_components/lib/pipes_subprocess_script_collection.py b/python_modules/libraries/dagster-components/dagster_components/lib/pipes_subprocess_script_collection.py index 75a8a83730505..6849715101dc1 100644 --- a/python_modules/libraries/dagster-components/dagster_components/lib/pipes_subprocess_script_collection.py +++ b/python_modules/libraries/dagster-components/dagster_components/lib/pipes_subprocess_script_collection.py @@ -11,7 +11,7 @@ from dagster._utils.warnings import suppress_dagster_warnings from pydantic import BaseModel -from dagster_components.core.component import Component, ComponentLoadContext, component +from dagster_components.core.component import Component, ComponentLoadContext, component_type from dagster_components.core.dsl_schema import AutomationConditionModel if TYPE_CHECKING: @@ -52,7 +52,7 @@ class PipesSubprocessScriptCollectionParams(BaseModel): scripts: Sequence[PipesSubprocessScriptParams] -@component(name="pipes_subprocess_script_collection") +@component_type(name="pipes_subprocess_script_collection") class PipesSubprocessScriptCollection(Component): """Assets that wrap Python scripts executed with Dagster's PipesSubprocessClient.""" diff --git a/python_modules/libraries/dagster-components/dagster_components/lib/sling_replication.py b/python_modules/libraries/dagster-components/dagster_components/lib/sling_replication.py index 63c466930deb9..67dee607be29b 100644 --- a/python_modules/libraries/dagster-components/dagster_components/lib/sling_replication.py +++ b/python_modules/libraries/dagster-components/dagster_components/lib/sling_replication.py @@ -12,7 +12,7 @@ from typing_extensions import Self from dagster_components import Component, ComponentLoadContext -from dagster_components.core.component import ComponentGenerateRequest, component +from dagster_components.core.component import ComponentGenerateRequest, component_type from dagster_components.core.dsl_schema import AssetAttributes, AssetSpecProcessor, OpSpecBaseModel from dagster_components.generate import generate_component_yaml @@ -23,7 +23,7 @@ class SlingReplicationParams(BaseModel): asset_attributes: Optional[AssetAttributes] = None -@component(name="sling_replication") +@component_type(name="sling_replication") class SlingReplicationComponent(Component): params_schema = SlingReplicationParams diff --git a/python_modules/libraries/dagster-components/dagster_components/lib/test/all_metadata_empty_asset.py b/python_modules/libraries/dagster-components/dagster_components/lib/test/all_metadata_empty_asset.py index ac7d3c34f65c9..323b16bc60fe4 100644 --- a/python_modules/libraries/dagster-components/dagster_components/lib/test/all_metadata_empty_asset.py +++ b/python_modules/libraries/dagster-components/dagster_components/lib/test/all_metadata_empty_asset.py @@ -5,7 +5,7 @@ from dagster._core.execution.context.asset_execution_context import AssetExecutionContext from typing_extensions import Self -from dagster_components import Component, ComponentLoadContext, component +from dagster_components import Component, ComponentLoadContext, component_type from dagster_components.core.component import ComponentGenerateRequest from dagster_components.core.component_decl_builder import YamlComponentDecl from dagster_components.generate import generate_component_yaml @@ -14,7 +14,7 @@ from dagster_components.core.component import ComponentDeclNode -@component(name="all_metadata_empty_asset") +@component_type(name="all_metadata_empty_asset") class AllMetadataEmptyAsset(Component): @classmethod def from_decl_node( diff --git a/python_modules/libraries/dagster-components/dagster_components/lib/test/simple_asset.py b/python_modules/libraries/dagster-components/dagster_components/lib/test/simple_asset.py index e446294aa104e..7d3e0c8739c65 100644 --- a/python_modules/libraries/dagster-components/dagster_components/lib/test/simple_asset.py +++ b/python_modules/libraries/dagster-components/dagster_components/lib/test/simple_asset.py @@ -7,7 +7,7 @@ from pydantic import BaseModel, TypeAdapter from typing_extensions import Self -from dagster_components import Component, ComponentLoadContext, component +from dagster_components import Component, ComponentLoadContext, component_type from dagster_components.core.component import ComponentGenerateRequest from dagster_components.core.component_decl_builder import YamlComponentDecl from dagster_components.generate import generate_component_yaml @@ -21,7 +21,7 @@ class SimpleAssetParams(BaseModel): value: str -@component(name="simple_asset") +@component_type(name="simple_asset") class SimpleAsset(Component): """A simple asset that returns a constant string value.""" diff --git a/python_modules/libraries/dagster-components/dagster_components/lib/test/simple_pipes_script_asset.py b/python_modules/libraries/dagster-components/dagster_components/lib/test/simple_pipes_script_asset.py index a744df67899dd..840b1f7c6d433 100644 --- a/python_modules/libraries/dagster-components/dagster_components/lib/test/simple_pipes_script_asset.py +++ b/python_modules/libraries/dagster-components/dagster_components/lib/test/simple_pipes_script_asset.py @@ -11,7 +11,7 @@ from pydantic import BaseModel, TypeAdapter from typing_extensions import Self -from dagster_components import Component, ComponentLoadContext, component +from dagster_components import Component, ComponentLoadContext, component_type from dagster_components.core.component import ComponentGenerateRequest from dagster_components.core.component_decl_builder import YamlComponentDecl from dagster_components.generate import generate_component_yaml @@ -43,7 +43,7 @@ def cli(asset_key: str, filename: str) -> "SimplePipesScriptAssetParams": """ -@component(name="simple_pipes_script_asset") +@component_type(name="simple_pipes_script_asset") class SimplePipesScriptAsset(Component): """A simple asset that runs a Python script with the Pipes subprocess client. diff --git a/python_modules/libraries/dagster-components/dagster_components_tests/code_locations/custom_sling_location/custom_sling_location/components/debug_sling_component/component.py b/python_modules/libraries/dagster-components/dagster_components_tests/code_locations/custom_sling_location/custom_sling_location/components/debug_sling_component/component.py index 0019f56f18974..122c98adc705e 100644 --- a/python_modules/libraries/dagster-components/dagster_components_tests/code_locations/custom_sling_location/custom_sling_location/components/debug_sling_component/component.py +++ b/python_modules/libraries/dagster-components/dagster_components_tests/code_locations/custom_sling_location/custom_sling_location/components/debug_sling_component/component.py @@ -1,12 +1,12 @@ from typing import Iterator from dagster._core.execution.context.asset_execution_context import AssetExecutionContext -from dagster_components import component +from dagster_components import component_type from dagster_components.lib.sling_replication import SlingReplicationComponent from dagster_embedded_elt.sling import SlingResource -@component(name="debug_sling_replication") +@component_type(name="debug_sling_replication") class DebugSlingReplicationComponent(SlingReplicationComponent): def execute(self, context: AssetExecutionContext, sling: SlingResource) -> Iterator: return sling.replicate(context=context, debug=True) diff --git a/python_modules/libraries/dagster-components/dagster_components_tests/integration_tests/test_sling_integration_test.py b/python_modules/libraries/dagster-components/dagster_components_tests/integration_tests/test_sling_integration_test.py index d6fcf590b64ea..5cf51a4543bf5 100644 --- a/python_modules/libraries/dagster-components/dagster_components_tests/integration_tests/test_sling_integration_test.py +++ b/python_modules/libraries/dagster-components/dagster_components_tests/integration_tests/test_sling_integration_test.py @@ -16,7 +16,7 @@ YamlComponentDecl, build_components_from_component_folder, ) -from dagster_components.lib.sling_replication import SlingReplicationComponent, component +from dagster_components.lib.sling_replication import SlingReplicationComponent, component_type from dagster_embedded_elt.sling import SlingResource from dagster_components_tests.utils import assert_assets, get_asset_keys, script_load_context @@ -137,7 +137,7 @@ def test_load_from_path(sling_path: Path) -> None: def test_sling_subclass() -> None: - @component(name="debug_sling_replication") + @component_type(name="debug_sling_replication") class DebugSlingReplicationComponent(SlingReplicationComponent): def execute( self, context: AssetExecutionContext, sling: SlingResource diff --git a/python_modules/libraries/dagster-components/dagster_components_tests/rendering_tests/custom_scope_component/component.py b/python_modules/libraries/dagster-components/dagster_components_tests/rendering_tests/custom_scope_component/component.py index 55075ba403c82..a0e8be5b68fa5 100644 --- a/python_modules/libraries/dagster-components/dagster_components_tests/rendering_tests/custom_scope_component/component.py +++ b/python_modules/libraries/dagster-components/dagster_components_tests/rendering_tests/custom_scope_component/component.py @@ -1,7 +1,7 @@ from typing import Any, Mapping from dagster import AssetSpec, AutomationCondition, Definitions -from dagster_components import Component, ComponentLoadContext, component +from dagster_components import Component, ComponentLoadContext, component_type from pydantic import BaseModel @@ -17,7 +17,7 @@ class CustomScopeParams(BaseModel): attributes: Mapping[str, Any] -@component(name="custom_scope_component") +@component_type(name="custom_scope_component") class HasCustomScope(Component): params_schema = CustomScopeParams diff --git a/python_modules/libraries/dagster-components/dagster_components_tests/unit_tests/test_registered_component.py b/python_modules/libraries/dagster-components/dagster_components_tests/unit_tests/test_registered_component.py index bf7fddb6423f4..309959d1d57eb 100644 --- a/python_modules/libraries/dagster-components/dagster_components_tests/unit_tests/test_registered_component.py +++ b/python_modules/libraries/dagster-components/dagster_components_tests/unit_tests/test_registered_component.py @@ -1,9 +1,9 @@ -from dagster_components import Component, component +from dagster_components import Component, component_type from dagster_components.core.component import get_component_name, is_registered_component def test_registered_component_with_default_name() -> None: - @component + @component_type class RegisteredComponent(Component): ... assert is_registered_component(RegisteredComponent) @@ -11,7 +11,7 @@ class RegisteredComponent(Component): ... def test_registered_component_with_default_name_and_parens() -> None: - @component() + @component_type() class RegisteredComponent(Component): ... assert is_registered_component(RegisteredComponent) @@ -19,7 +19,7 @@ class RegisteredComponent(Component): ... def test_registered_component_with_explicit_kwarg_name() -> None: - @component(name="explicit_name") + @component_type(name="explicit_name") class RegisteredComponent(Component): ... assert is_registered_component(RegisteredComponent) diff --git a/python_modules/libraries/dagster-components/dagster_components_tests/unit_tests/test_registry.py b/python_modules/libraries/dagster-components/dagster_components_tests/unit_tests/test_registry.py index 07f26ca1ed6f8..dd39dcf743efc 100644 --- a/python_modules/libraries/dagster-components/dagster_components_tests/unit_tests/test_registry.py +++ b/python_modules/libraries/dagster-components/dagster_components_tests/unit_tests/test_registry.py @@ -55,8 +55,8 @@ def _find_repo_root(): def _generate_test_component_source(number: int) -> str: return textwrap.dedent(f""" - from dagster_components import Component, component - @component(name="test_component_{number}") + from dagster_components import Component, component_type + @component_type(name="test_component_{number}") class TestComponent{number}(Component): pass """)