Skip to content

Commit 310b518

Browse files
btkcodedevmarcosmarxmoctavia-squidington-iii
authored
🎉New Source: TMDb [low-code cdk] (#18561)
* Init: New Source: TMDb * chore: Added documentation * Chore: All Comments Resolved * Added language config for filtering, All comomments resolved * Update Doc URL * add tmdb to source def and format files * Removed unwanted authenticator, Added request params and configs * cleansed lint * feat: Added pagination, refactor: moved example to spec.yaml and minor corrections * fix: change required in spec.yaml, corrections to docs * removed unwanted file change * remove movies_changes * auto-bump connector version Co-authored-by: btkcodedev <[email protected]> Co-authored-by: marcosmarxm <[email protected]> Co-authored-by: Marcos Marx <[email protected]> Co-authored-by: Octavia Squidington III <[email protected]>
1 parent 0d4a2bb commit 310b518

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+12096
-0
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,13 @@
15541554
icon: timely.svg
15551555
sourceType: api
15561556
releaseStage: alpha
1557+
- name: TMDb
1558+
sourceDefinitionId: 6240848f-f795-45eb-8f5e-c7542822fc03
1559+
dockerRepository: airbyte/source-tmdb
1560+
dockerImageTag: 0.1.0
1561+
documentationUrl: https://docs.airbyte.com/integrations/sources/tmdb
1562+
sourceType: api
1563+
releaseStage: alpha
15571564
- name: Toggl
15581565
sourceDefinitionId: 7e7c844f-2300-4342-b7d3-6dd7992593cd
15591566
dockerRepository: airbyte/source-toggl

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14225,6 +14225,50 @@
1422514225
supportsNormalization: false
1422614226
supportsDBT: false
1422714227
supported_destination_sync_modes: []
14228+
- dockerImage: "airbyte/source-tmdb:0.1.0"
14229+
spec:
14230+
documentationUrl: "https://docs.airbyte.com/integrations/sources/tmdb"
14231+
connectionSpecification:
14232+
$schema: "http://json-schema.org/draft-07/schema#"
14233+
title: "Tmdb Spec"
14234+
type: "object"
14235+
required:
14236+
- "api_key"
14237+
- "movie_id"
14238+
- "query"
14239+
- "language"
14240+
additionalProperties: true
14241+
properties:
14242+
api_key:
14243+
title: "Unique key for establishing connection"
14244+
type: "string"
14245+
description: "API Key from tmdb account"
14246+
airbyte_secret: true
14247+
movie_id:
14248+
title: "Movie ID for targeting movies"
14249+
type: "string"
14250+
description: "Target movie ID, Mandate for movie streams (Example is 550)"
14251+
examples:
14252+
- 550
14253+
- 560
14254+
query:
14255+
title: "Query for search streams"
14256+
type: "string"
14257+
description: "Target movie ID, Mandate for search streams"
14258+
examples:
14259+
- "Marvel"
14260+
- "DC"
14261+
language:
14262+
title: "Language for filtering"
14263+
type: "string"
14264+
description: "Language expressed in ISO 639-1 scheme, Mandate for required\
14265+
\ streams (Example en-US)"
14266+
examples:
14267+
- "en-US"
14268+
- "en-UK"
14269+
supportsNormalization: false
14270+
supportsDBT: false
14271+
supported_destination_sync_modes: []
1422814272
- dockerImage: "airbyte/source-toggl:0.1.0"
1422914273
spec:
1423014274
documentationUrl: "https://docs.airbyte.com/integrations/sources/toggl"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
!Dockerfile
3+
!main.py
4+
!source_tmdb
5+
!setup.py
6+
!secrets
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM python:3.9.11-alpine3.15 as base
2+
3+
# build and load all requirements
4+
FROM base as builder
5+
WORKDIR /airbyte/integration_code
6+
7+
# upgrade pip to the latest version
8+
RUN apk --no-cache upgrade \
9+
&& pip install --upgrade pip \
10+
&& apk --no-cache add tzdata build-base
11+
12+
13+
COPY setup.py ./
14+
# install necessary packages to a temporary folder
15+
RUN pip install --prefix=/install .
16+
17+
# build a clean environment
18+
FROM base
19+
WORKDIR /airbyte/integration_code
20+
21+
# copy all loaded and built libraries to a pure basic image
22+
COPY --from=builder /install /usr/local
23+
# add default timezone settings
24+
COPY --from=builder /usr/share/zoneinfo/Etc/UTC /etc/localtime
25+
RUN echo "Etc/UTC" > /etc/timezone
26+
27+
# bash is installed for more convenient debugging.
28+
RUN apk --no-cache add bash
29+
30+
# copy payload code only
31+
COPY main.py ./
32+
COPY source_tmdb ./source_tmdb
33+
34+
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
35+
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
36+
37+
LABEL io.airbyte.version=0.1.0
38+
LABEL io.airbyte.name=airbyte/source-tmdb
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Tmdb Source
2+
3+
This is the repository for the Tmdb configuration based source connector.
4+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/tmdb).
5+
6+
## Local development
7+
8+
### Prerequisites
9+
**To iterate on this connector, make sure to complete this prerequisites section.**
10+
11+
#### Minimum Python version required `= 3.9.0`
12+
13+
#### Build & Activate Virtual Environment and install dependencies
14+
From this connector directory, create a virtual environment:
15+
```
16+
python -m venv .venv
17+
```
18+
19+
This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
20+
development environment of choice. To activate it from the terminal, run:
21+
```
22+
source .venv/bin/activate
23+
pip install -r requirements.txt
24+
25+
```
26+
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
27+
28+
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
29+
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
30+
If this is mumbo jumbo to you, don't worry about it, just put your deps in `setup.py` but install using `pip install -r requirements.txt` and everything
31+
should work as you expect.
32+
33+
#### Building via Gradle
34+
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.
35+
36+
To build using Gradle, from the Airbyte repository root, run:
37+
```
38+
./gradlew :airbyte-integrations:connectors:source-tmdb:build
39+
```
40+
41+
#### Create credentials
42+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/tmdb)
43+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_tmdb/spec.yaml` file.
44+
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
45+
See `integration_tests/sample_config.json` for a sample config file.
46+
47+
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source tmdb test creds`
48+
and place them into `secrets/config.json`.
49+
50+
### Locally running the connector docker image
51+
52+
#### Build
53+
First, make sure you build the latest Docker image:
54+
```
55+
docker build . -t airbyte/source-tmdb:dev
56+
```
57+
58+
You can also build the connector image via Gradle:
59+
```
60+
./gradlew :airbyte-integrations:connectors:source-tmdb:airbyteDocker
61+
```
62+
When building via Gradle, the docker image name and tag, respectively, are the values of the `io.airbyte.name` and `io.airbyte.version` `LABEL`s in
63+
the Dockerfile.
64+
65+
#### Run
66+
Then run any of the connector commands as follows:
67+
```
68+
docker run --rm airbyte/source-tmdb:dev spec
69+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-tmdb:dev check --config /secrets/config.json
70+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-tmdb:dev discover --config /secrets/config.json
71+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-tmdb:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
72+
```
73+
## Testing
74+
75+
#### Acceptance Tests
76+
Customize `acceptance-test-config.yml` file to configure tests. See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference) for more information.
77+
If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.
78+
79+
To run your integration tests with docker
80+
81+
### Using gradle to run tests
82+
All commands should be run from airbyte project root.
83+
To run unit tests:
84+
```
85+
./gradlew :airbyte-integrations:connectors:source-tmdb:unitTest
86+
```
87+
To run acceptance and custom integration tests:
88+
```
89+
./gradlew :airbyte-integrations:connectors:source-tmdb:integrationTest
90+
```
91+
92+
## Dependency Management
93+
All of your dependencies should go in `setup.py`, NOT `requirements.txt`. The requirements file is only used to connect internal Airbyte dependencies in the monorepo for local development.
94+
We split dependencies between two groups, dependencies that are:
95+
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
96+
* required for the testing need to go to `TEST_REQUIREMENTS` list
97+
98+
### Publishing a new version of the connector
99+
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
100+
1. Make sure your changes are passing unit and integration tests.
101+
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)).
102+
1. Create a Pull Request.
103+
1. Pat yourself on the back for being an awesome contributor.
104+
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
3+
#
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# See [Source Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/source-acceptance-tests-reference)
2+
# for more information about how to configure these tests
3+
connector_image: airbyte/source-tmdb:dev
4+
acceptance_tests:
5+
spec:
6+
tests:
7+
- spec_path: "source_tmdb/spec.yaml"
8+
connection:
9+
tests:
10+
- config_path: "secrets/config.json"
11+
status: "succeed"
12+
- config_path: "integration_tests/invalid_config.json"
13+
status: "failed"
14+
discovery:
15+
tests:
16+
- config_path: "secrets/config.json"
17+
basic_read:
18+
tests:
19+
- config_path: "secrets/config.json"
20+
configured_catalog_path: "integration_tests/configured_catalog.json"
21+
empty_streams: []
22+
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
23+
# expect_records:
24+
# path: "integration_tests/expected_records.txt"
25+
# extra_fields: no
26+
# exact_order: no
27+
# extra_records: yes
28+
incremental:
29+
bypass_reason: "This connector does not implement incremental sync"
30+
# TODO uncomment this block this block if your connector implements incremental sync:
31+
# tests:
32+
# - config_path: "secrets/config.json"
33+
# configured_catalog_path: "integration_tests/configured_catalog.json"
34+
# future_state_path: "integration_tests/abnormal_state.json"
35+
full_refresh:
36+
tests:
37+
- config_path: "secrets/config.json"
38+
configured_catalog_path: "integration_tests/configured_catalog.json"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env sh
2+
3+
# Build latest connector image
4+
docker build . -t $(cat acceptance-test-config.yml | grep "connector_image" | head -n 1 | cut -d: -f2-)
5+
6+
# Pull latest acctest image
7+
docker pull airbyte/source-acceptance-test:latest
8+
9+
# Run
10+
docker run --rm -it \
11+
-v /var/run/docker.sock:/var/run/docker.sock \
12+
-v /tmp:/tmp \
13+
-v $(pwd):/test_input \
14+
airbyte/source-acceptance-test \
15+
--acceptance-test-config /test_input
16+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# TMDb
2+
3+
The connector uses the v3 API documented here: https://developers.themoviedb.org/3/getting-started/introduction. It is
4+
straightforward HTTP REST API with API Authentication.
5+
6+
## API key
7+
8+
Api key is mandate for this connector to work. It could be generated using a free account at TMDb. Visit: https://www.themoviedb.org/settings/api
9+
10+
## Implementation details
11+
12+
## Setup guide
13+
14+
### Step 1: Set up TMDb connection
15+
16+
- Have an API key by generating personal API key (Example: 12345)
17+
- A movie ID, or query could be configured in config.json (Not Mandate, Default movie _id would be 550 and query would be marvel)
18+
- See sample_config.json for more details
19+
20+
## Step 2: Generate schema for the endpoint
21+
22+
### Custom schema is generated and tested with different IDs
23+
24+
## Step 3: Spec, Secrets, and connector yaml files are configured with reference to the Airbyte documentation.
25+
26+
## In a nutshell:
27+
28+
1. Navigate to the Airbyte Open Source dashboard.
29+
2. Set the name for your source.
30+
3. Enter your `api_key`.
31+
5. Enter params `movie_id, query, language` (if needed).
32+
6. Click **Set up source**.
33+
34+
* We use only GET methods, all streams are straightforward.
35+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
id 'airbyte-python'
3+
id 'airbyte-docker'
4+
id 'airbyte-source-acceptance-test'
5+
}
6+
7+
airbytePython {
8+
moduleDirectory 'source_tmdb'
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
3+
#
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"todo-stream-name": {
3+
"todo-field-name": "todo-abnormal-value"
4+
}
5+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
3+
#
4+
5+
6+
import pytest
7+
8+
pytest_plugins = ("source_acceptance_test.plugin",)
9+
10+
11+
@pytest.fixture(scope="session", autouse=True)
12+
def connector_setup():
13+
"""This fixture is a placeholder for external resources that acceptance test might require."""
14+
# TODO: setup test dependencies if needed. otherwise remove the TODO comments
15+
yield
16+
# TODO: clean up test dependencies

0 commit comments

Comments
 (0)