Skip to content

Commit bc27a84

Browse files
btkcodedevgirarda
andauthored
✨Source Rss: Migrate Python CDK to Low-code CDK (#36418)
Co-authored-by: Alexandre Girard <[email protected]>
1 parent 1ce0cc5 commit bc27a84

27 files changed

+1373
-679
lines changed

airbyte-integrations/connectors/source-rss/.dockerignore

-6
This file was deleted.

airbyte-integrations/connectors/source-rss/Dockerfile

-38
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,103 @@
1-
# Rabbitmq Destination
1+
# Rss Source
22

3-
This is the repository for the Rabbitmq destination connector, written in Python.
4-
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/destinations/rabbitmq).
3+
This is the repository for the Rss configuration based source connector.
4+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.com/integrations/sources/rss).
55

66
## Local development
77

88
### Prerequisites
9-
**To iterate on this connector, make sure to complete this prerequisites section.**
109

11-
#### Minimum Python version required `= 3.7.0`
10+
* Python (`^3.9`)
11+
* Poetry (`^1.7`) - installation instructions [here](https://python-poetry.org/docs/#installation)
1212

13-
#### Build & Activate Virtual Environment and install dependencies
14-
From this connector directory, create a virtual environment:
15-
```
16-
python -m venv .venv
17-
```
1813

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
14+
15+
### Installing the connector
16+
17+
From this connector directory, run:
18+
```bash
19+
poetry install --with dev
2420
```
25-
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
2621

27-
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
28-
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
29-
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
30-
should work as you expect.
3122

32-
#### Create credentials
33-
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/destinations/rabbitmq)
34-
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `destination_rabbitmq/spec.json` file.
35-
Note that the `secrets` directory is gitignored by default, so there is no danger of accidentally checking in sensitive information.
36-
See `integration_tests/sample_config.json` for a sample config file.
23+
### Create credentials
24+
25+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/rss)
26+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `src/source_rss/spec.yaml` file.
27+
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
28+
See `sample_files/sample_config.json` for a sample config file.
3729

38-
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `destination rabbitmq test creds`
39-
and place them into `secrets/config.json`.
4030

4131
### Locally running the connector
32+
4233
```
43-
python main.py spec
44-
python main.py check --config secrets/config.json
45-
python main.py discover --config secrets/config.json
46-
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
34+
poetry run source-rss spec
35+
poetry run source-rss check --config secrets/config.json
36+
poetry run source-rss discover --config secrets/config.json
37+
poetry run source-rss read --config secrets/config.json --catalog sample_files/configured_catalog.json
4738
```
4839

49-
### Locally running the connector docker image
40+
### Running tests
5041

42+
To run tests locally, from the connector directory run:
5143

52-
#### Build
53-
**Via [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md) (recommended):**
54-
```bash
55-
airbyte-ci connectors --name destination-rabbitmq build
44+
```
45+
poetry run pytest tests
5646
```
5747

58-
An image will be built with the tag `airbyte/destination-rabbitmq:dev`.
48+
### Building the docker image
5949

60-
**Via `docker build`:**
50+
1. Install [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)
51+
2. Run the following command to build the docker image:
6152
```bash
62-
docker build -t airbyte/destination-rabbitmq:dev .
53+
airbyte-ci connectors --name=source-rss build
6354
```
6455

65-
#### Run
56+
An image will be available on your host with the tag `airbyte/source-rss:dev`.
57+
58+
59+
### Running as a docker container
60+
6661
Then run any of the connector commands as follows:
6762
```
68-
docker run --rm airbyte/destination-rabbitmq:dev spec
69-
docker run --rm -v $(pwd)/secrets:/secrets airbyte/destination-rabbitmq:dev check --config /secrets/config.json
70-
# messages.jsonl is a file containing line-separated JSON representing AirbyteMessages
71-
cat messages.jsonl | docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/destination-rabbitmq:dev write --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
63+
docker run --rm airbyte/source-rss:dev spec
64+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-rss:dev check --config /secrets/config.json
65+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-rss:dev discover --config /secrets/config.json
66+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-rss:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
7267
```
7368

74-
## Testing
69+
### Running our CI test suite
70+
7571
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
7672
```bash
7773
airbyte-ci connectors --name=source-rss test
7874
```
7975

8076
### Customizing acceptance Tests
81-
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.
77+
78+
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.
8279
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.
8380

84-
## Dependency Management
85-
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.
86-
We split dependencies between two groups, dependencies that are:
87-
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
88-
* required for the testing need to go to `TEST_REQUIREMENTS` list
81+
### Dependency Management
82+
83+
All of your dependencies should be managed via Poetry.
84+
To add a new dependency, run:
85+
```bash
86+
poetry add <package-name>
87+
```
88+
89+
Please commit the changes to `pyproject.toml` and `poetry.lock` files.
90+
91+
## Publishing a new version of the connector
8992

90-
### Publishing a new version of the connector
9193
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
9294
1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-rss test`
93-
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).
95+
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)):
96+
- bump the `dockerImageTag` value in in `metadata.yaml`
97+
- bump the `version` value in `pyproject.toml`
9498
3. Make sure the `metadata.yaml` content is up to date.
95-
4. Make the connector documentation and its changelog is up to date (`docs/integrations/sources/rss.md`).
99+
4. Make sure the connector documentation and its changelog is up to date (`docs/integrations/sources/rss.md`).
96100
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).
97101
6. Pat yourself on the back for being an awesome contributor.
98102
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
99-
103+
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-rss/acceptance-test-config.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@ connector_image: airbyte/source-rss:dev
44
acceptance_tests:
55
spec:
66
tests:
7-
- config_path: "integration_tests/sample_config.json"
8-
spec_path: "source_rss/spec.yaml"
7+
- spec_path: "source_rss/spec.yaml"
98
connection:
109
tests:
11-
- config_path: "integration_tests/sample_config.json"
10+
- config_path: "secrets/config.json"
1211
status: "succeed"
1312
- config_path: "integration_tests/invalid_config.json"
1413
status: "failed"
1514
discovery:
1615
tests:
17-
- config_path: "integration_tests/sample_config.json"
16+
- config_path: "secrets/config.json"
1817
basic_read:
1918
tests:
20-
- config_path: "integration_tests/sample_config.json"
19+
- config_path: "secrets/config.json"
2120
configured_catalog_path: "integration_tests/configured_catalog.json"
2221
empty_streams: []
2322
incremental:
24-
tests:
25-
- config_path: "integration_tests/sample_config.json"
26-
configured_catalog_path: "integration_tests/incremental_configured_catalog.json"
27-
future_state:
28-
future_state_path: "integration_tests/abnormal_state.json"
23+
bypass_reason: "This connector does not implement incremental sync"
24+
# tests:
25+
# - config_path: "secrets/config.json"
26+
# configured_catalog_path: "integration_tests/configured_catalog.json"
27+
# future_state:
28+
# future_state_path: "integration_tests/abnormal_state.json"
2929
full_refresh:
3030
tests:
31-
- config_path: "integration_tests/sample_config.json"
31+
- config_path: "secrets/config.json"
3232
configured_catalog_path: "integration_tests/configured_catalog.json"
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"items": {
3-
"published": "3333-10-24T16:16:00+00:00"
2+
"todo-stream-name": {
3+
"todo-field-name": "value"
44
}
55
}

airbyte-integrations/connectors/source-rss/integration_tests/acceptance.py

+2
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@
1111
@pytest.fixture(scope="session", autouse=True)
1212
def connector_setup():
1313
"""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
1415
yield
16+
# TODO: clean up test dependencies

airbyte-integrations/connectors/source-rss/integration_tests/catalog.json

-45
This file was deleted.

airbyte-integrations/connectors/source-rss/integration_tests/configured_catalog.json

+2-36
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,8 @@
33
{
44
"stream": {
55
"name": "items",
6-
"json_schema": {
7-
"$schema": "http://json-schema.org/draft-07/schema#",
8-
"type": "object",
9-
"required": ["published"],
10-
"properties": {
11-
"title": {
12-
"type": ["null", "string"]
13-
},
14-
"link": {
15-
"type": ["null", "string"]
16-
},
17-
"description": {
18-
"type": ["null", "string"]
19-
},
20-
"author": {
21-
"type": ["null", "string"]
22-
},
23-
"category": {
24-
"type": ["null", "string"]
25-
},
26-
"comments": {
27-
"type": ["null", "string"]
28-
},
29-
"enclosure": {
30-
"type": ["null", "string"]
31-
},
32-
"guid": {
33-
"type": ["null", "string"]
34-
},
35-
"published": {
36-
"type": ["string"],
37-
"format": "date-time"
38-
}
39-
}
40-
},
41-
"supported_sync_modes": ["full_refresh", "incremental"]
6+
"json_schema": {},
7+
"supported_sync_modes": ["full_refresh"]
428
},
439
"sync_mode": "full_refresh",
4410
"destination_sync_mode": "overwrite"

0 commit comments

Comments
 (0)