airbyte-cdk 6.45.4.post52.dev14501809740__py3-none-any.whl → 6.45.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airbyte_cdk/models/__init__.py +0 -1
- airbyte_cdk/models/airbyte_protocol.py +3 -1
- airbyte_cdk/models/file_transfer_record_message.py +13 -0
- airbyte_cdk/sources/concurrent_source/concurrent_read_processor.py +1 -1
- airbyte_cdk/sources/declarative/auth/oauth.py +2 -2
- airbyte_cdk/sources/declarative/concurrent_declarative_source.py +6 -10
- airbyte_cdk/sources/declarative/declarative_component_schema.yaml +0 -36
- airbyte_cdk/sources/declarative/extractors/record_selector.py +1 -6
- airbyte_cdk/sources/declarative/models/declarative_component_schema.py +0 -31
- airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py +4 -40
- airbyte_cdk/sources/declarative/stream_slicers/declarative_partition_generator.py +4 -9
- airbyte_cdk/sources/file_based/file_based_stream_reader.py +16 -38
- airbyte_cdk/sources/file_based/file_types/file_transfer.py +15 -8
- airbyte_cdk/sources/file_based/schema_helpers.py +1 -11
- airbyte_cdk/sources/file_based/stream/concurrent/adapters.py +12 -3
- airbyte_cdk/sources/file_based/stream/default_file_based_stream.py +38 -15
- airbyte_cdk/sources/file_based/stream/permissions_file_based_stream.py +3 -1
- airbyte_cdk/sources/streams/concurrent/default_stream.py +0 -3
- airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py +28 -11
- airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py +4 -27
- airbyte_cdk/sources/types.py +2 -11
- airbyte_cdk/sources/utils/record_helper.py +8 -8
- airbyte_cdk/test/mock_http/response_builder.py +0 -8
- {airbyte_cdk-6.45.4.post52.dev14501809740.dist-info → airbyte_cdk-6.45.5.dist-info}/METADATA +2 -2
- {airbyte_cdk-6.45.4.post52.dev14501809740.dist-info → airbyte_cdk-6.45.5.dist-info}/RECORD +29 -31
- airbyte_cdk/sources/declarative/retrievers/file_uploader.py +0 -89
- airbyte_cdk/sources/file_based/file_record_data.py +0 -23
- airbyte_cdk/sources/utils/files_directory.py +0 -15
- {airbyte_cdk-6.45.4.post52.dev14501809740.dist-info → airbyte_cdk-6.45.5.dist-info}/LICENSE.txt +0 -0
- {airbyte_cdk-6.45.4.post52.dev14501809740.dist-info → airbyte_cdk-6.45.5.dist-info}/LICENSE_SHORT +0 -0
- {airbyte_cdk-6.45.4.post52.dev14501809740.dist-info → airbyte_cdk-6.45.5.dist-info}/WHEEL +0 -0
- {airbyte_cdk-6.45.4.post52.dev14501809740.dist-info → airbyte_cdk-6.45.5.dist-info}/entry_points.txt +0 -0
@@ -1,89 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
import json
|
6
|
-
import logging
|
7
|
-
import uuid
|
8
|
-
from dataclasses import InitVar, dataclass, field
|
9
|
-
from pathlib import Path
|
10
|
-
from typing import Any, Mapping, Optional, Union
|
11
|
-
|
12
|
-
from airbyte_cdk.models import AirbyteRecordMessageFileReference
|
13
|
-
from airbyte_cdk.sources.declarative.extractors.record_extractor import RecordExtractor
|
14
|
-
from airbyte_cdk.sources.declarative.interpolation.interpolated_string import (
|
15
|
-
InterpolatedString,
|
16
|
-
)
|
17
|
-
from airbyte_cdk.sources.declarative.partition_routers.substream_partition_router import (
|
18
|
-
SafeResponse,
|
19
|
-
)
|
20
|
-
from airbyte_cdk.sources.declarative.requesters import Requester
|
21
|
-
from airbyte_cdk.sources.declarative.types import Record, StreamSlice
|
22
|
-
from airbyte_cdk.sources.types import Config
|
23
|
-
from airbyte_cdk.sources.utils.files_directory import get_files_directory
|
24
|
-
|
25
|
-
logger = logging.getLogger("airbyte")
|
26
|
-
|
27
|
-
|
28
|
-
@dataclass
|
29
|
-
class FileUploader:
|
30
|
-
requester: Requester
|
31
|
-
download_target_extractor: RecordExtractor
|
32
|
-
config: Config
|
33
|
-
parameters: InitVar[Mapping[str, Any]]
|
34
|
-
|
35
|
-
filename_extractor: Optional[Union[InterpolatedString, str]] = None
|
36
|
-
content_extractor: Optional[RecordExtractor] = None
|
37
|
-
|
38
|
-
def __post_init__(self, parameters: Mapping[str, Any]) -> None:
|
39
|
-
if self.filename_extractor:
|
40
|
-
self.filename_extractor = InterpolatedString.create(
|
41
|
-
self.filename_extractor,
|
42
|
-
parameters=parameters,
|
43
|
-
)
|
44
|
-
|
45
|
-
def upload(self, record: Record) -> None:
|
46
|
-
mocked_response = SafeResponse()
|
47
|
-
mocked_response.content = json.dumps(record.data).encode()
|
48
|
-
download_target = list(self.download_target_extractor.extract_records(mocked_response))[0]
|
49
|
-
if not isinstance(download_target, str):
|
50
|
-
raise ValueError(
|
51
|
-
f"download_target is expected to be a str but was {type(download_target)}: {download_target}"
|
52
|
-
)
|
53
|
-
|
54
|
-
response = self.requester.send_request(
|
55
|
-
stream_slice=StreamSlice(
|
56
|
-
partition={}, cursor_slice={}, extra_fields={"download_target": download_target}
|
57
|
-
),
|
58
|
-
)
|
59
|
-
|
60
|
-
if self.content_extractor:
|
61
|
-
raise NotImplementedError("TODO")
|
62
|
-
else:
|
63
|
-
files_directory = Path(get_files_directory())
|
64
|
-
|
65
|
-
file_name = (
|
66
|
-
self.filename_extractor.eval(self.config, record=record)
|
67
|
-
if self.filename_extractor
|
68
|
-
else str(uuid.uuid4())
|
69
|
-
)
|
70
|
-
file_name = file_name.lstrip("/")
|
71
|
-
file_relative_path = Path(record.stream_name) / Path(file_name)
|
72
|
-
|
73
|
-
full_path = files_directory / file_relative_path
|
74
|
-
full_path.parent.mkdir(parents=True, exist_ok=True)
|
75
|
-
|
76
|
-
with open(str(full_path), "wb") as f:
|
77
|
-
f.write(response.content)
|
78
|
-
file_size_bytes = full_path.stat().st_size
|
79
|
-
|
80
|
-
logger.info("File uploaded successfully")
|
81
|
-
logger.info(f"File url: {str(full_path)}")
|
82
|
-
logger.info(f"File size: {file_size_bytes / 1024} KB")
|
83
|
-
logger.info(f"File relative path: {str(file_relative_path)}")
|
84
|
-
|
85
|
-
record.file_reference = AirbyteRecordMessageFileReference(
|
86
|
-
staging_file_url=str(full_path),
|
87
|
-
source_file_relative_path=str(file_relative_path),
|
88
|
-
file_size_bytes=file_size_bytes,
|
89
|
-
)
|
@@ -1,23 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
|
5
|
-
from datetime import datetime
|
6
|
-
from typing import Optional
|
7
|
-
|
8
|
-
from pydantic.v1 import BaseModel
|
9
|
-
|
10
|
-
|
11
|
-
class FileRecordData(BaseModel):
|
12
|
-
"""
|
13
|
-
A record in a file-based stream.
|
14
|
-
"""
|
15
|
-
|
16
|
-
folder: str
|
17
|
-
filename: str
|
18
|
-
bytes: int
|
19
|
-
source_uri: str
|
20
|
-
id: Optional[str] = None
|
21
|
-
created_at: Optional[str] = None
|
22
|
-
updated_at: Optional[str] = None
|
23
|
-
mime_type: Optional[str] = None
|
@@ -1,15 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
|
3
|
-
#
|
4
|
-
import os
|
5
|
-
|
6
|
-
AIRBYTE_STAGING_DIRECTORY = os.getenv("AIRBYTE_STAGING_DIRECTORY", "/staging/files")
|
7
|
-
DEFAULT_LOCAL_DIRECTORY = "/tmp/airbyte-file-transfer"
|
8
|
-
|
9
|
-
|
10
|
-
def get_files_directory() -> str:
|
11
|
-
return (
|
12
|
-
AIRBYTE_STAGING_DIRECTORY
|
13
|
-
if os.path.exists(AIRBYTE_STAGING_DIRECTORY)
|
14
|
-
else DEFAULT_LOCAL_DIRECTORY
|
15
|
-
)
|
{airbyte_cdk-6.45.4.post52.dev14501809740.dist-info → airbyte_cdk-6.45.5.dist-info}/LICENSE.txt
RENAMED
File without changes
|
{airbyte_cdk-6.45.4.post52.dev14501809740.dist-info → airbyte_cdk-6.45.5.dist-info}/LICENSE_SHORT
RENAMED
File without changes
|
File without changes
|
{airbyte_cdk-6.45.4.post52.dev14501809740.dist-info → airbyte_cdk-6.45.5.dist-info}/entry_points.txt
RENAMED
File without changes
|