Repository navigation
Remove the CLI's hard dbt-core dependency (dbt v2 ships as dbt/dbt-oss) #2360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
860507d
fbf003e
23d7fbb
e0d1439
bb04074
813eda8
e962dd4
5120778
cd334a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,22 +21,26 @@ def get_dbt_core_version() -> Optional[version.Version]: | |
| return _get_package_version("dbt-core") | ||
|
|
||
|
|
||
| def get_dbt_package_version() -> Optional[version.Version]: | ||
| """Version of the installed `dbt` package, or None if not installed. | ||
| def get_dbt2_package_version() -> Optional[version.Version]: | ||
| """Version of the installed dbt v2 package, or None if not installed. | ||
|
|
||
| From 2.0, the `dbt` package on PyPI ships the dbt (Fusion) binary as a | ||
| platform wheel with no importable Python module. | ||
| dbt v2 (the Fusion engine) is distributed on PyPI as the `dbt` package (full | ||
| feature set) and the `dbt-oss` package (Apache 2 subset); both ship the dbt | ||
| binary. dbt-core stays on 1.x. | ||
| """ | ||
| return _get_package_version("dbt") | ||
| for package_name in ("dbt", "dbt-oss"): | ||
| package_version = _get_package_version(package_name) | ||
| if package_version is not None and package_version.major >= 2: | ||
| return package_version | ||
| return None | ||
|
|
||
|
|
||
| def is_dbt2_binary_available() -> bool: | ||
| env_path = os.getenv(DBT_FUSION_PATH_ENV_VAR) | ||
| if env_path and os.path.exists(os.path.expanduser(env_path)): | ||
| return True | ||
|
|
||
| dbt_package_version = get_dbt_package_version() | ||
| if dbt_package_version is not None and dbt_package_version.major >= 2: | ||
| if get_dbt2_package_version() is not None: | ||
| return True | ||
| return os.path.exists(os.path.expanduser(DEFAULT_DBT_FUSION_PATH)) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to make sure - is this check still reliable to verify dbt2 installation?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes for all the supported install paths, with one pre-existing edge case:
The edge case (unchanged from #2333): the Conversely, a Fusion binary at a non-standard PATH location with no pip metadata isn't detected as dbt v2 (falls back to the 1.x subprocess runner) — that's what |
||
|
|
||
|
|
@@ -49,10 +53,9 @@ def get_dbt2_binary_path() -> str: | |
| # When only dbt-core 1.x is installed, the `dbt` executable on PATH is its | ||
| # entrypoint, so it can't be trusted to be the dbt 2.0 binary. | ||
| dbt_core_version = get_dbt_core_version() | ||
| dbt_package_version = get_dbt_package_version() | ||
| dbt2_installed_via_pip = ( | ||
| dbt_package_version is not None and dbt_package_version.major >= 2 | ||
| ) or (dbt_core_version is not None and dbt_core_version.major >= 2) | ||
| dbt2_installed_via_pip = get_dbt2_package_version() is not None or ( | ||
| dbt_core_version is not None and dbt_core_version.major >= 2 | ||
| ) | ||
| if dbt2_installed_via_pip or dbt_core_version is None: | ||
| which_path = shutil.which("dbt") | ||
| if which_path: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.