Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
fix: get fal distribution when dbt-fal is not present (#886)
Browse files Browse the repository at this point in the history
* fix: get fal distribution when dbt-fal is not present

* ci: easier deployment
  • Loading branch information
chamini2 authored Jul 17, 2023
1 parent 568c382 commit 5d6bd36
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ jobs:
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
if: inputs.package == dbt-fal
with:
branch: bump-${{ inputs.package }}-${{ env.publishing_version }}
delete-branch: true
Expand Down
4 changes: 3 additions & 1 deletion projects/adapter/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[tool.poetry]
name = "dbt-fal"
version = "1.5.6a0"
# name = "fal"
# version = "0.9.4a0"
description = "Run python scripts from any dbt project."
readme = "README.md"
homepage = "https://github.com/fal-ai/fal"
Expand Down Expand Up @@ -95,5 +97,5 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
dbt-fal = "fal.dbt.cli:cli"
# NOTE: deprecated use
# TODO: remove once `fal` is no longer a supported package
fal = "fal.dbt.cli:fal_cli"
2 changes: 2 additions & 0 deletions projects/adapter/src/fal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# TODO: remove once `fal` is no longer a supported package
# The whole file
DBT_FAL_IMPORT_NOTICE = \
"""The dbt tool `fal` and `dbt-fal` adapter have been merged into a single tool.
Please import from the `fal.dbt` module instead.
Expand Down
7 changes: 6 additions & 1 deletion projects/adapter/src/fal/dbt/cli/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ def _build_cli_parser():
description="Run Python scripts on dbt models",
)

version = pkg_resources.get_distribution("dbt-fal").version
try:
version = pkg_resources.get_distribution("dbt-fal").version
except pkg_resources.DistributionNotFound:
# TODO: remove once `fal` is no longer a supported package
version = pkg_resources.get_distribution("fal").version

parser.add_argument(
"-v",
"--version",
Expand Down
2 changes: 2 additions & 0 deletions projects/adapter/src/fal/dbt/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from fal.dbt.integration.logger import log_manager


# TODO: remove once `fal` is no longer a supported package
DBT_FAL_COMMAND_NOTICE = \
"""The dbt tool `fal` and `dbt-fal` adapter have been merged into a single tool.
Please use the new `dbt-fal` command line tool instead.
Expand All @@ -20,6 +21,7 @@
dbt-fal <command>
"""

# TODO: remove once `fal` is no longer a supported package
def fal_cli(argv: List[str] = sys.argv):
print(DBT_FAL_COMMAND_NOTICE)
cli(argv)
Expand Down
19 changes: 16 additions & 3 deletions projects/adapter/src/fal/dbt/packages/dependency_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,25 @@ def _get_dbt_fal_package() -> Tuple[str, Optional[str]]:
else:
# We are going to install it from PyPI.
dbt_fal_dep = "dbt-fal"
dbt_fal_version = importlib_metadata.version("dbt-fal")
try:
dbt_fal_version = importlib_metadata.version("dbt-fal")
except importlib_metadata.PackageNotFoundError:
# TODO: remove once `fal` is no longer a supported package
dbt_fal_version = importlib_metadata.version("fal")
else:
dbt_fal_dep = "dbt-fal"
dbt_fal_version = importlib_metadata.version("dbt-fal")
try:
dbt_fal_version = importlib_metadata.version("dbt-fal")
except importlib_metadata.PackageNotFoundError:
# TODO: remove once `fal` is no longer a supported package
dbt_fal_version = importlib_metadata.version("fal")

try:
dbt_fal_extras = _find_fal_extras("dbt-fal")
except importlib_metadata.PackageNotFoundError:
# TODO: remove once `fal` is no longer a supported package
dbt_fal_extras = _find_fal_extras("fal")

dbt_fal_extras = _find_fal_extras("dbt-fal")
if dbt_fal_extras:
dbt_fal_dep += f"[{','.join(dbt_fal_extras)}]"

Expand Down

0 comments on commit 5d6bd36

Please sign in to comment.