From 31e3de3cb7a59a1882913389adc7cf4d755fcd13 Mon Sep 17 00:00:00 2001 From: Meder Kamalov <38204337+mederka@users.noreply.github.com> Date: Tue, 14 Feb 2023 18:40:50 +0100 Subject: [PATCH] feat(dbt-fal): `cloud` host resolution (#758) * feat: resolve host=cloud to api.alpha.fal.ai * feat: also resolve cloud-eu --- docsite/docs/dbt-fal/cloud/using_fal_cloud.md | 6 +++--- .../src/dbt/adapters/fal_experimental/connections.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docsite/docs/dbt-fal/cloud/using_fal_cloud.md b/docsite/docs/dbt-fal/cloud/using_fal_cloud.md index 43d840789..19df4de58 100644 --- a/docsite/docs/dbt-fal/cloud/using_fal_cloud.md +++ b/docsite/docs/dbt-fal/cloud/using_fal_cloud.md @@ -11,7 +11,7 @@ sidebar_position: 1 Skip this step, if you already have the latest version of fal installed, ```bash -pip install --upgrade fal +pip install --upgrade fal[cloud] ``` ## 1. Authenticate to fal cloud @@ -45,7 +45,7 @@ fal_profile: fal_cloud: type: fal db_profile: db - host: api.alpha.fal.ai + host: cloud key_secret: MY_KEY_SECRET_VALUE key_id: MY_KEY_ID_VALUE db: @@ -71,7 +71,7 @@ fal_profile: prod: type: fal db_profile: db - host: rooster.fal.ai:60005 + host: cloud key_secret: MY_KEY_SECRET_VALUE key_id: MY_KEY_ID_VALUE db: diff --git a/projects/adapter/src/dbt/adapters/fal_experimental/connections.py b/projects/adapter/src/dbt/adapters/fal_experimental/connections.py index b8d3ee719..3a4fcfd7e 100644 --- a/projects/adapter/src/dbt/adapters/fal_experimental/connections.py +++ b/projects/adapter/src/dbt/adapters/fal_experimental/connections.py @@ -8,6 +8,12 @@ from dbt.fal.adapters.python import PythonConnectionManager +DEFAULT_HOSTS = { + "cloud": "api.alpha.fal.ai", + "cloud-eu": "api.eu.fal.ai", +} + + class TeleportTypeEnum(StrEnum): LOCAL = "local" REMOTE_S3 = "s3" @@ -45,7 +51,7 @@ def cancel(self, connection): class FalCredentials(Credentials): default_environment: str = "local" teleport: Optional[TeleportCredentials] = None - host: str = "" + host: str = "cloud" key_secret: str = "" key_id: str = "" @@ -54,6 +60,10 @@ class FalCredentials(Credentials): database: str = "" schema: str = "" + def __post_init__(self): + if self.host in list(DEFAULT_HOSTS.keys()): + self.host = DEFAULT_HOSTS[self.host] + @property def type(self): return "fal_experimental"