-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
airbyte-lib: Hidden documentation (#34702)
Co-authored-by: Aaron ("AJ") Steers <aj@airbyte.io>
- Loading branch information
1 parent
3710b5d
commit 2aa7327
Showing
16 changed files
with
312 additions
and
61 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import AirbyteLibConnectors from '@site/src/components/AirbyteLibConnectors'; | ||
|
||
# Getting Started with AirbyteLib (Beta) | ||
|
||
AirbyteLib is a library that provides a set of utilities to use Airbyte connectors in Python. It is meant to be used in situations where setting up an Airbyte server or cloud account is not possible or desirable, for example in a Jupyter notebook or when iterating on early prototypes on a developer's workstation. | ||
|
||
## Installation | ||
|
||
```bash | ||
pip install airbyte-lib | ||
``` | ||
|
||
Or during the beta, you may want to install the latest from from source with: | ||
|
||
```bash | ||
pip install 'git+airbytehq/airbyte.git@master#egg=airbyte-lib&subdirectory=airbyte-lib' | ||
``` | ||
|
||
## Usage | ||
|
||
Data can be extracted from sources and loaded into caches: | ||
|
||
```python | ||
import airbyte_lib as ab | ||
|
||
source = ab.get_connector( | ||
"source-spacex-api", | ||
config={"id": "605b4b6aaa5433645e37d03f"}, | ||
install_if_missing=True, | ||
) | ||
source.check() | ||
|
||
source.set_streams(["launches", "rockets", "capsules"]) | ||
|
||
cache = ab.new_local_cache() | ||
result = source.read_all(cache) | ||
|
||
for name, records in result.cache.streams.items(): | ||
print(f"Stream {name}: {len(records)} records") | ||
``` | ||
|
||
## API Reference | ||
|
||
For details on specific classes and methods, please refer to our [AirbyteLib API Reference](./reference). | ||
|
||
## Architecture | ||
|
||
[comment]: <> (Edit under https://docs.google.com/drawings/d/1M7ti2D4ha6cEtPnk04RLp1SSh3au4dRJsLupnGPigHQ/edit?usp=sharing) | ||
|
||
![Architecture](../../assets/docs/airbyte-lib-high-level-architecture.svg) | ||
|
||
airbyte-lib is a python library that can be run in any context that supports Python >=3.9. It contains the following main components: | ||
* **Source**: A source object is using a Python connector and includes a configuration object. The configuration object is a dictionary that contains the configuration of the connector, like authentication or connection modalities. The source object is used to read data from the connector. | ||
* **Cache**: Data can be read directly from the source object. However, it is recommended to use a cache object to store the data. The cache object allows to temporarily store records from the source in a SQL database like a local DuckDB file or a Postgres or Snowflake instance. | ||
* **Result**: An object holding the records from a read operation on a source. It allows quick access to the records of each synced stream via the used cache object. Data can be accessed as a list of records, a Pandas DataFrame or via SQLAlchemy queries. | ||
|
||
## Available connectors | ||
|
||
The following connectors are available: | ||
|
||
<AirbyteLibConnectors /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import AirbyteLibDefinitions from '@site/src/components/AirbyteLibDefinitions'; | ||
|
||
# airbyte-lib reference | ||
|
||
This page contains the reference documentation for the airbyte-lib library. | ||
|
||
## Main `airbyte_lib` module | ||
|
||
<AirbyteLibDefinitions module="airbyte_lib" /> | ||
|
||
## Caches `airbyte_lib.caches` | ||
|
||
The following cache implementations are available | ||
|
||
<AirbyteLibDefinitions module="airbyte_lib.caches" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export default function AirbyteLibConnectors({ | ||
connectorsJSON, | ||
}) { | ||
const connectors = JSON.parse(connectorsJSON); | ||
return <ul> | ||
{connectors.map((connector) => <li key={connector.name_oss}> | ||
<a href={`${getRelativeDocumentationUrl(connector)}#reference`}>{connector.name_oss}</a> | ||
</li>)} | ||
</ul> | ||
} | ||
|
||
function getRelativeDocumentationUrl(connector) { | ||
// get the relative path from the the dockerRepository_oss (e.g airbyte/source-amazon-sqs -> /integrations/sources/amazon-sqs) | ||
|
||
const fullDockerImage = connector.dockerRepository_oss; | ||
console.log(fullDockerImage); | ||
const dockerImage = fullDockerImage.split("airbyte/")[1]; | ||
|
||
const [integrationType, ...integrationName] = dockerImage.split("-"); | ||
|
||
return `/integrations/${integrationType}s/${integrationName.join("-")}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
|
||
// Add additional modules here | ||
import main_docs from "../../../airbyte-lib/docs/generated/airbyte_lib.html"; | ||
import caches_docs from "../../../airbyte-lib/docs/generated/airbyte_lib/caches.html"; | ||
|
||
const docs = { | ||
"airbyte_lib": main_docs, | ||
"airbyte_lib.caches": caches_docs, | ||
} | ||
|
||
|
||
export default function AirbyteLibDefinitions({ module }) { | ||
return <> | ||
<div dangerouslySetInnerHTML={{ __html: docs[module] }} /> | ||
</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const visit = require("unist-util-visit").visit; | ||
const { catalog, isPypiConnector } = require("../connector_registry"); | ||
|
||
const plugin = () => { | ||
const transformer = async (ast, vfile) => { | ||
|
||
const registry = await catalog; | ||
|
||
visit(ast, "mdxJsxFlowElement", (node) => { | ||
if (node.name !== "AirbyteLibConnectors") return; | ||
|
||
const connectors = registry.filter(isPypiConnector); | ||
|
||
node.attributes.push({ | ||
type: "mdxJsxAttribute", | ||
name: "connectorsJSON", | ||
value: JSON.stringify(connectors) | ||
}); | ||
}); | ||
}; | ||
return transformer; | ||
}; | ||
|
||
module.exports = plugin; |
Oops, something went wrong.