-
Notifications
You must be signed in to change notification settings - Fork 5
Update dlt dependency from ^0.4.12 to ^1.11.0 #135
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
base: devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
import mimetypes | ||
import pathlib | ||
from pathlib import Path | ||
from typing import Any, List, Optional | ||
from typing import Any, Dict, List, Optional | ||
|
||
import yaml | ||
from pydantic import BaseModel | ||
|
@@ -11,7 +11,12 @@ | |
|
||
from .typing import TEndpointFilter | ||
|
||
REST_API_SOURCE_LOCATION = str(pathlib.Path(__file__).parent.resolve() / "../rest_api") | ||
# In dlt>=1.11.0, the rest_api is part of the main package | ||
# For backwards compatibility, we keep a stub directory | ||
REST_API_SOURCE_LOCATION = str(pathlib.Path(__file__).parent / "rest_api") | ||
|
||
# Placeholder for SecretsTomlConfig to resolve ImportError in tests | ||
SecretsTomlConfig = Dict[str, Any] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not seem to be used anywhere, does it? Why is it imported in the tests at all? |
||
|
||
|
||
class Config(BaseModel): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
dlt>=0.4.12 | ||
dlt>=1.11.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,24 @@ | ||
import pathlib | ||
|
||
import requests | ||
from loguru import logger | ||
|
||
from dlt_init_openapi.config import REST_API_SOURCE_LOCATION | ||
|
||
BASEPATH = "https://raw.githubusercontent.com/dlt-hub/verified-sources/master/sources/rest_api/" | ||
FILES = ["README.md", "__init__.py", "config_setup.py", "exceptions.py", "requirements.txt", "typing.py", "utils.py"] | ||
|
||
|
||
def update_rest_api(force: bool = False) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can remove this and the commands that depend on it entirely |
||
"""updates local rest api""" | ||
logger.info("Syncing rest_api verified source") | ||
|
||
path = pathlib.Path(REST_API_SOURCE_LOCATION) | ||
if path.exists() and not force: | ||
logger.info("rest_api verified source already present") | ||
return | ||
|
||
path.mkdir(exist_ok=True) | ||
for file in FILES: | ||
src_path = BASEPATH + file | ||
dst_path = REST_API_SOURCE_LOCATION + "/" + file | ||
logger.info(f"Copying {src_path}") | ||
with requests.get(src_path, stream=True) as r: | ||
r.raise_for_status() | ||
with open(dst_path, "wb") as f: | ||
for chunk in r.iter_content(chunk_size=8192): | ||
f.write(chunk) | ||
logger.success("rest_api verified source synced") | ||
""" | ||
This function is kept for backwards compatibility. | ||
In dlt >=1.0.0, rest_api is part of the main package. | ||
No need to vendor the files separately. | ||
""" | ||
logger.info("Using built-in dlt.sources.rest_api (dlt >=1.11.0)") | ||
# Create an empty rest_api directory to maintain compatibility | ||
script_dir = pathlib.Path(__file__).parent.resolve() | ||
vendor_path = script_dir.parent / "rest_api" | ||
vendor_path.mkdir(parents=True, exist_ok=True) | ||
# Create empty __init__.py to make it a proper package | ||
init_file = vendor_path / "__init__.py" | ||
if not init_file.exists(): | ||
with open(init_file, "w") as f: | ||
f.write("# This is a compatibility package. Use dlt.sources.rest_api instead.\n") | ||
|
||
|
||
if __name__ == "__main__": | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sh-rp see also the PR I opened related to the
rest_api
source.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed it.