diff --git a/python_modules/dagster/dagster/_core/libraries.py b/python_modules/dagster/dagster/_core/libraries.py index 412387786dd09..c438fc78046c6 100644 --- a/python_modules/dagster/dagster/_core/libraries.py +++ b/python_modules/dagster/dagster/_core/libraries.py @@ -8,8 +8,10 @@ class DagsterLibraryRegistry: _libraries: Dict[str, str] = {"dagster": __version__} @classmethod - def register(cls, name: str, version: str): - check_dagster_package_version(name, version) + def register(cls, name: str, version: str, *, is_dagster_package: bool = True): + if is_dagster_package: + check_dagster_package_version(name, version) + cls._libraries[name] = version @classmethod diff --git a/python_modules/dagster/dagster_tests/core_tests/test_utils.py b/python_modules/dagster/dagster_tests/core_tests/test_utils.py index ab7d92b878a17..1a0a180c45441 100644 --- a/python_modules/dagster/dagster_tests/core_tests/test_utils.py +++ b/python_modules/dagster/dagster_tests/core_tests/test_utils.py @@ -16,6 +16,15 @@ from dagster._utils import hash_collection, library_version_from_core_version +@pytest.fixture +def library_registry_fixture(): + previous_libraries = DagsterLibraryRegistry.get() + + yield + + DagsterLibraryRegistry._libraries = previous_libraries # noqa: SLF001 + + def test_parse_env_var_no_equals(): env_var = "FOO_ENV_VAR" @@ -73,6 +82,15 @@ def test_library_version_from_core_version(): assert library_version_from_core_version("1.1.16post0") == "0.17.16post0" +def test_non_dagster_library_registry(library_registry_fixture): + DagsterLibraryRegistry.register("not-dagster", "0.0.1", is_dagster_package=False) + + assert DagsterLibraryRegistry.get() == { + "dagster": dagster.version.__version__, + "not-dagster": "0.0.1", + } + + def test_library_registry(): assert DagsterLibraryRegistry.get() == {"dagster": dagster.version.__version__} diff --git a/python_modules/libraries/dagster-dbt/dagster_dbt/__init__.py b/python_modules/libraries/dagster-dbt/dagster_dbt/__init__.py index db694884c5c6a..19e30238ce8a0 100644 --- a/python_modules/libraries/dagster-dbt/dagster_dbt/__init__.py +++ b/python_modules/libraries/dagster-dbt/dagster_dbt/__init__.py @@ -54,9 +54,11 @@ from dagster._annotations import deprecated from dagster._core.libraries import DagsterLibraryRegistry from dagster._utils.warnings import deprecation_warning +from dbt.version import __version__ as __dbt_version__ from typing_extensions import Final DagsterLibraryRegistry.register("dagster-dbt", __version__) +DagsterLibraryRegistry.register("dbt-core", __dbt_version__) _DEPRECATED: Final[Mapping[str, Tuple[str, str, str]]] = {