Skip to content

Commit

Permalink
chore: register dbt-core version in DagsterLibraryRegistry (#23329)
Browse files Browse the repository at this point in the history
## Summary & Motivation
As the title. Since `dbt-core` isn't a Dagster library, we'll skip the
version check and write it directly into the library mapping.

## How I Tested These Changes
N/A
  • Loading branch information
rexledesma authored Sep 12, 2024
1 parent 8ddba34 commit 428fde1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions python_modules/dagster/dagster/_core/libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions python_modules/dagster/dagster_tests/core_tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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__}

Expand Down
2 changes: 2 additions & 0 deletions python_modules/libraries/dagster-dbt/dagster_dbt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]] = {
Expand Down

0 comments on commit 428fde1

Please sign in to comment.