Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 3de6a60

Browse files
authored
Merge pull request #628 from datafold/LAB-72
use a different endpoint for ds metadata
2 parents c26b2b2 + 3a39a88 commit 3de6a60

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

data_diff/cloud/datafold_api.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import pydantic
88
import requests
99

10+
from data_diff.errors import DataDiffDatasourceIdNotFoundError
11+
1012
from ..utils import getLogger
1113

1214
logger = getLogger(__name__)
@@ -207,9 +209,15 @@ def get_data_sources(self) -> List[TCloudApiDataSource]:
207209
return [TCloudApiDataSource(**item) for item in rv.json()]
208210

209211
def get_data_source(self, data_source_id: int) -> TCloudApiDataSource:
210-
rv = self.make_get_request(url=f"api/v1/data_sources/{data_source_id}")
212+
rv = self.make_get_request(url=f"api/v1/data_sources")
211213
rv.raise_for_status()
212-
return TCloudApiDataSource(**rv.json())
214+
response_json = rv.json()
215+
datasource = next((datasource for datasource in response_json if datasource["id"] == data_source_id), None)
216+
if not datasource:
217+
raise DataDiffDatasourceIdNotFoundError(
218+
f"Datasource ID: {data_source_id} was not found in your Datafold account!"
219+
)
220+
return TCloudApiDataSource(**datasource)
213221

214222
def create_data_source(self, config: TDsConfig) -> TCloudApiDataSource:
215223
payload = config.dict()

data_diff/errors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ class DataDiffNoAPIKeyError(Exception):
5656

5757
class DataDiffNoDatasourceIdError(Exception):
5858
"Raised when using --cloud but no datasource_id was found in dbt_project.yml"
59+
60+
61+
class DataDiffDatasourceIdNotFoundError(Exception):
62+
"Raised when using --cloud but the datasource_id is not found for a particular org."

0 commit comments

Comments
 (0)