Skip to content

Commit 5cbde18

Browse files
authored
Feat: Clean up public API and improve docs (#109)
1 parent ce2bcf4 commit 5cbde18

File tree

18 files changed

+129
-25
lines changed

18 files changed

+129
-25
lines changed

airbyte/__init__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,34 @@
22
33
.. include:: ../README.md
44
5+
## API Reference
6+
57
"""
68
from __future__ import annotations
79

8-
from airbyte import caches, datasets, registry, secrets
9-
from airbyte._factories.connector_factories import get_source
10+
from airbyte import caches, datasets, documents, exceptions, results, secrets, sources
1011
from airbyte.caches.bigquery import BigQueryCache
1112
from airbyte.caches.duckdb import DuckDBCache
12-
from airbyte.caches.factories import get_default_cache, new_local_cache
13+
from airbyte.caches.util import get_default_cache, new_local_cache
1314
from airbyte.datasets import CachedDataset
14-
from airbyte.registry import get_available_connectors
1515
from airbyte.results import ReadResult
1616
from airbyte.secrets import SecretSource, get_secret
17-
from airbyte.source import Source
17+
from airbyte.sources import registry
18+
from airbyte.sources.base import Source
19+
from airbyte.sources.registry import get_available_connectors
20+
from airbyte.sources.util import get_source
1821

1922

2023
__all__ = [
2124
# Modules
2225
"caches",
2326
"datasets",
27+
"documents",
28+
"exceptions",
2429
"registry",
30+
"results",
2531
"secrets",
32+
"sources",
2633
# Factories
2734
"get_available_connectors",
2835
"get_default_cache",

airbyte/_executor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from rich import print
1414

1515
from airbyte import exceptions as exc
16-
from airbyte.registry import ConnectorMetadata
16+
from airbyte.sources.registry import ConnectorMetadata
1717

1818

1919
if TYPE_CHECKING:

airbyte/_factories/__init__.py

Whitespace-only changes.

airbyte/_util/telemetry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
if TYPE_CHECKING:
5151
from airbyte.caches.base import CacheBase
52-
from airbyte.source import Source
52+
from airbyte.sources.base import Source
5353

5454

5555
HASH_SEED = "PyAirbyte:"

airbyte/caches/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
"""Base module for all caches."""
33
from __future__ import annotations
44

5+
from airbyte.caches import bigquery, duckdb, motherduck, postgres, snowflake, util
56
from airbyte.caches.base import CacheBase
67
from airbyte.caches.duckdb import DuckDBCache
7-
from airbyte.caches.factories import get_default_cache, new_local_cache
88
from airbyte.caches.motherduck import MotherDuckCache
99
from airbyte.caches.postgres import PostgresCache
1010
from airbyte.caches.snowflake import SnowflakeCache
11+
from airbyte.caches.util import get_default_cache, new_local_cache
1112

1213

1314
# We export these classes for easy access: `airbyte.caches...`
@@ -21,4 +22,12 @@
2122
"MotherDuckCache",
2223
"PostgresCache",
2324
"SnowflakeCache",
25+
# Submodules,
26+
"util",
27+
"base",
28+
"bigquery",
29+
"duckdb",
30+
"motherduck",
31+
"postgres",
32+
"snowflake",
2433
]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
2+
"""Utility functions for working with caches."""
3+
24
from __future__ import annotations
35

46
from pathlib import Path

airbyte/documents.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2-
"""Methods for converting Airbyte records into documents."""
2+
"""This module contains the `Documents` class for converting Airbyte records into documents.
3+
4+
Generally you will not create `Documents` objects directly. Instead, you can use one of the
5+
following methods to generate documents from records:
6+
7+
- `Source.get_documents()`: Get an iterable of documents from a source.
8+
- `Dataset.to_documents()`: Get an iterable of documents from a dataset.
9+
"""
10+
311
from __future__ import annotations
412

513
from typing import TYPE_CHECKING, Any, Optional
@@ -46,3 +54,8 @@ def page_content(self) -> str:
4654
with the LangChain project's `Document` class.
4755
"""
4856
return self.content
57+
58+
59+
__all__ = [
60+
"Document",
61+
]

airbyte/exceptions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
property prints rather than sentence-like string concatenation.
77
88
E.g. Instead of this:
9-
> Subprocess failed with exit code '1'
9+
10+
> `Subprocess failed with exit code '1'`
1011
1112
We do this:
12-
> Subprocess failed. (exit_code=1)
13+
14+
> `Subprocess failed. (exit_code=1)`
1315
1416
The benefit of this approach is that we can easily support structured logging, and we can
1517
easily add new properties to exceptions without having to update all the places where they

airbyte/secrets.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,9 @@ def get_secret(
126126
secret_name=secret_name,
127127
sources=[str(s) for s in sources],
128128
)
129+
130+
131+
__all__ = [
132+
"get_secret",
133+
"SecretSource",
134+
]

airbyte/sources/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""Sources connectors module for PyAirbyte."""
2+
from __future__ import annotations
3+
4+
from airbyte.sources import base, util
5+
from airbyte.sources.registry import (
6+
ConnectorMetadata,
7+
get_available_connectors,
8+
get_connector_metadata,
9+
)
10+
from airbyte.sources.util import get_source
11+
12+
13+
__all__ = [
14+
# Submodules
15+
"base",
16+
"util",
17+
# Factories
18+
"get_source",
19+
# Helper Functions
20+
"get_available_connectors",
21+
"get_connector_metadata",
22+
# Classes
23+
"Source",
24+
"ConnectorMetadata",
25+
]

0 commit comments

Comments
 (0)