Skip to content

Commit e5bb6e1

Browse files
authored
source-todoist: ensure inline schemas, updated cdk, poetry (where possible) (#37272)
1 parent f390062 commit e5bb6e1

File tree

10 files changed

+1327
-254
lines changed

10 files changed

+1327
-254
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,91 @@
1-
# Todoist Source
1+
# Todoist source connector
22

3-
This is the repository for the Todoist configuration based source connector.
3+
4+
This is the repository for the Todoist source connector, written in Python.
45
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.com/integrations/sources/todoist).
56

67
## Local development
78

9+
### Prerequisites
10+
* Python (~=3.9)
11+
* Poetry (~=1.7) - installation instructions [here](https://python-poetry.org/docs/#installation)
812

9-
#### Create credentials
10-
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/todoist)
11-
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_todoist/spec.yaml` file.
12-
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
13-
See `integration_tests/sample_config.json` for a sample config file.
14-
15-
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source todoist test creds`
16-
and place them into `secrets/config.json`.
17-
18-
### Locally running the connector docker image
19-
20-
#### Use `airbyte-ci` to build your connector
21-
The Airbyte way of building this connector is to use our `airbyte-ci` tool.
22-
You can follow install instructions [here](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md#L1).
23-
Then running the following command will build your connector:
2413

14+
### Installing the connector
15+
From this connector directory, run:
2516
```bash
26-
airbyte-ci connectors --name source-todoist build
17+
poetry install --with dev
2718
```
28-
Once the command is done, you will find your connector image in your local docker registry: `airbyte/source-todoist:dev`.
2919

30-
##### Customizing our build process
31-
When contributing on our connector you might need to customize the build process to add a system dependency or set an env var.
32-
You can customize our build process by adding a `build_customization.py` module to your connector.
33-
This module should contain a `pre_connector_install` and `post_connector_install` async function that will mutate the base image and the connector container respectively.
34-
It will be imported at runtime by our build process and the functions will be called if they exist.
35-
36-
Here is an example of a `build_customization.py` module:
37-
```python
38-
from __future__ import annotations
39-
40-
from typing import TYPE_CHECKING
41-
42-
if TYPE_CHECKING:
43-
# Feel free to check the dagger documentation for more information on the Container object and its methods.
44-
# https://dagger-io.readthedocs.io/en/sdk-python-v0.6.4/
45-
from dagger import Container
4620

21+
### Create credentials
22+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/todoist)
23+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_todoist/spec.yaml` file.
24+
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
25+
See `sample_files/sample_config.json` for a sample config file.
4726

48-
async def pre_connector_install(base_image_container: Container) -> Container:
49-
return await base_image_container.with_env_variable("MY_PRE_BUILD_ENV_VAR", "my_pre_build_env_var_value")
5027

51-
async def post_connector_install(connector_container: Container) -> Container:
52-
return await connector_container.with_env_variable("MY_POST_BUILD_ENV_VAR", "my_post_build_env_var_value")
28+
### Locally running the connector
29+
```
30+
poetry run source-todoist spec
31+
poetry run source-todoist check --config secrets/config.json
32+
poetry run source-todoist discover --config secrets/config.json
33+
poetry run source-todoist read --config secrets/config.json --catalog sample_files/configured_catalog.json
5334
```
5435

55-
#### Build your own connector image
56-
This connector is built using our dynamic built process in `airbyte-ci`.
57-
The base image used to build it is defined within the metadata.yaml file under the `connectorBuildOptions`.
58-
The build logic is defined using [Dagger](https://dagger.io/) [here](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/pipelines/builds/python_connectors.py).
59-
It does not rely on a Dockerfile.
60-
61-
If you would like to patch our connector and build your own a simple approach would be to:
62-
63-
1. Create your own Dockerfile based on the latest version of the connector image.
64-
```Dockerfile
65-
FROM airbyte/source-todoist:latest
66-
67-
COPY . ./airbyte/integration_code
68-
RUN pip install ./airbyte/integration_code
69-
70-
# The entrypoint and default env vars are already set in the base image
71-
# ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
72-
# ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
36+
### Running unit tests
37+
To run unit tests locally, from the connector directory run:
38+
```
39+
poetry run pytest unit_tests
7340
```
74-
Please use this as an example. This is not optimized.
7541

76-
2. Build your image:
42+
### Building the docker image
43+
1. Install [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)
44+
2. Run the following command to build the docker image:
7745
```bash
78-
docker build -t airbyte/source-todoist:dev .
79-
# Running the spec command against your patched connector
80-
docker run airbyte/source-todoist:dev spec
46+
airbyte-ci connectors --name=source-todoist build
47+
```
48+
49+
An image will be available on your host with the tag `airbyte/source-todoist:dev`.
8150

82-
#### Run
51+
52+
### Running as a docker container
8353
Then run any of the connector commands as follows:
8454
```
8555
docker run --rm airbyte/source-todoist:dev spec
8656
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-todoist:dev check --config /secrets/config.json
8757
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-todoist:dev discover --config /secrets/config.json
8858
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-todoist:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
8959
```
90-
## Testing
9160

92-
### Acceptance Tests
93-
Customize `acceptance-test-config.yml` file to configure tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
61+
### Running our CI test suite
62+
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
63+
```bash
64+
airbyte-ci connectors --name=source-todoist test
65+
```
66+
67+
### Customizing acceptance Tests
68+
Customize `acceptance-test-config.yml` file to configure acceptance tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
9469
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.
95-
Please run acceptance tests via [airbyte-ci](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md#connectors-test-command):
70+
71+
### Dependency Management
72+
All of your dependencies should be managed via Poetry.
73+
To add a new dependency, run:
9674
```bash
97-
airbyte-ci connectors --name source-todoist test
75+
poetry add <package-name>
9876
```
9977

100-
## Dependency Management
101-
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.
102-
We split dependencies between two groups, dependencies that are:
103-
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
104-
* required for the testing need to go to `TEST_REQUIREMENTS` list
78+
Please commit the changes to `pyproject.toml` and `poetry.lock` files.
10579

106-
### Publishing a new version of the connector
80+
## Publishing a new version of the connector
10781
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
10882
1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-todoist test`
109-
2. Bump the connector version in `metadata.yaml`: increment the `dockerImageTag` value. Please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors).
83+
2. Bump the connector version (please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors)):
84+
- bump the `dockerImageTag` value in in `metadata.yaml`
85+
- bump the `version` value in `pyproject.toml`
11086
3. Make sure the `metadata.yaml` content is up to date.
111-
4. Make the connector documentation and its changelog is up to date (`docs/integrations/sources/todoist.md`).
87+
4. Make sure the connector documentation and its changelog is up to date (`docs/integrations/sources/todoist.md`).
11288
5. Create a Pull Request: use [our PR naming conventions](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#pull-request-title-convention).
11389
6. Pat yourself on the back for being an awesome contributor.
11490
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
115-
91+
8. Once your PR is merged, the new version of the connector will be automatically published to Docker Hub and our connector registry.

airbyte-integrations/connectors/source-todoist/metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ data:
1919
connectorSubtype: api
2020
connectorType: source
2121
definitionId: 1a3d38e4-dc6b-4154-b56b-582f9e978ecd
22-
dockerImageTag: 0.2.0
22+
dockerImageTag: 0.2.2
2323
dockerRepository: airbyte/source-todoist
2424
githubIssueLabel: source-todoist
2525
icon: todoist.svg

0 commit comments

Comments
 (0)