-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[components] Add entry point mechanism for component registration (#2…
…6337) ## Summary & Motivation Change the `dagster-components` registration system to use Python entry points. All components picked up by the system must be exposed as entry points. This includes: - components exposed by `dagster-components` itself - components exposed by arbitrary third party libraries - components exposed by the code location module An entry point is declared under the group `dagster.components` in `pyproject.toml`/`setup.py`: ``` [project.entry-points] "dagster.components" = { lib = "my_pkg.lib" } ``` A new `ComponentRegistry.from_entry_point_discovery()` method is the preferred way to construct a registry. It will pull all entry points from this group using `importlib.metadata` and crawl the specified modules. ## How I Tested These Changes New unit tests.
- Loading branch information
Showing
28 changed files
with
209 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
..._components_tests/code_locations/python_script_location/components/scripts/component.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
..._tests/stub_code_locations/dbt_project_location/components/jaffle_shop_dbt/component.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
type: dbt_project | ||
type: dagster_components.dbt_project | ||
|
||
params: | ||
dbt: | ||
|
2 changes: 1 addition & 1 deletion
2
...ster_components_tests/stub_code_locations/sling_location/components/ingest/component.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
type: sling_replication | ||
type: dagster_components.sling_replication | ||
|
||
params: | ||
sling: | ||
|
2 changes: 1 addition & 1 deletion
2
...ions/templated_custom_keys_dbt_project_location/components/jaffle_shop_dbt/component.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
type: dbt_project | ||
type: dagster_components.dbt_project | ||
|
||
params: | ||
dbt: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...aries/dagster-components/dagster_components_tests/unit_tests/test_registered_component.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
from dagster_components import Component, component | ||
from dagster_components.core.component import get_component_name, is_component | ||
from dagster_components.core.component import get_component_name, is_registered_component | ||
|
||
|
||
def test_registered_component_with_default_name() -> None: | ||
@component | ||
class RegisteredComponent(Component): ... | ||
|
||
assert is_component(RegisteredComponent) | ||
assert is_registered_component(RegisteredComponent) | ||
assert get_component_name(RegisteredComponent) == "registered_component" | ||
|
||
|
||
def test_registered_component_with_default_name_and_parens() -> None: | ||
@component() | ||
class RegisteredComponent(Component): ... | ||
|
||
assert is_component(RegisteredComponent) | ||
assert is_registered_component(RegisteredComponent) | ||
assert get_component_name(RegisteredComponent) == "registered_component" | ||
|
||
|
||
def test_registered_component_with_explicit_kwarg_name() -> None: | ||
@component(name="explicit_name") | ||
class RegisteredComponent(Component): ... | ||
|
||
assert is_component(RegisteredComponent) | ||
assert is_registered_component(RegisteredComponent) | ||
assert get_component_name(RegisteredComponent) == "explicit_name" | ||
|
||
|
||
def test_unregistered_component() -> None: | ||
class UnregisteredComponent(Component): ... | ||
|
||
assert not is_component(UnregisteredComponent) | ||
assert not is_registered_component(UnregisteredComponent) |
Oops, something went wrong.