Skip to content

Commit

Permalink
fix: Load the dbt api spec from a file instead of Github (#412)
Browse files Browse the repository at this point in the history
Fixes #410

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Edgar Ramírez Mondragón <[email protected]>
  • Loading branch information
3 people authored Nov 14, 2024
1 parent 0e3fc2e commit ff0253d
Show file tree
Hide file tree
Showing 4 changed files with 1,942 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ responses = "responses"

[tool.deptry.per_rule_ignores]
DEP001 = [ "backports" ]
DEP002 = [ "backports-datetime-fromisoformat" ]
DEP002 = [ "backports-datetime-fromisoformat", "requests" ]
12 changes: 5 additions & 7 deletions tap_dbt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

from __future__ import annotations

import importlib.resources
import typing as t
from abc import abstractmethod
from functools import cache

import requests
import yaml
from singer_sdk import RESTStream
from singer_sdk._singerlib import resolve_schema_references
from singer_sdk.authenticators import APIAuthenticatorBase, SimpleAuthenticator

OPENAPI_URL = (
"https://raw.githubusercontent.com/fishtown-analytics/dbt-cloud-openapi-spec"
"/ee64f573d79585f12d30eaafc223dc8a84052c9a/openapi-v2-old.yaml"
)
from tap_dbt import schemas


@cache
Expand All @@ -25,8 +22,9 @@ def load_openapi() -> dict[str, t.Any]:
Returns:
The OpenAPI specification as a dict.
"""
response = requests.get(OPENAPI_URL, timeout=10)
return yaml.safe_load(response.text)
schema_path = importlib.resources.files(schemas) / "openapi_v2.yaml"
with schema_path.open() as schema:
return yaml.safe_load(schema)


class DBTStream(RESTStream):
Expand Down
1 change: 1 addition & 0 deletions tap_dbt/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""OpenAPI schema for dbt Cloud."""
Loading

0 comments on commit ff0253d

Please sign in to comment.