Skip to content
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

fix: Load the dbt api spec from a file instead of Github #412

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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