Skip to content

Commit 0d0b03b

Browse files
alafanecherexiaohansong
authored andcommitted
✨ source-instagram: migrate to poetry (#35177)
1 parent f98e6c2 commit 0d0b03b

File tree

6 files changed

+1572
-102
lines changed

6 files changed

+1572
-102
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,55 @@
1-
# Instagram Source
1+
# Instagram source connector
2+
23

34
This is the repository for the Instagram source connector, written in Python.
4-
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/instagram).
5+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.com/integrations/sources/instagram).
56

67
## Local development
78

89
### Prerequisites
9-
**To iterate on this connector, make sure to complete this prerequisites section.**
10-
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+
### Installing the connector
15+
From this connector directory, run:
16+
```bash
17+
poetry install --with dev
2418
```
25-
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
2619

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.
3120

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

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

4128
### Locally running the connector
4229
```
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
30+
poetry run source-instagram spec
31+
poetry run source-instagram check --config secrets/config.json
32+
poetry run source-instagram discover --config secrets/config.json
33+
poetry run source-instagram read --config secrets/config.json --catalog sample_files/configured_catalog.json
4734
```
4835

49-
### Locally running the connector docker image
50-
36+
### Running unit tests
37+
To run unit tests locally, from the connector directory run:
38+
```
39+
poetry run pytest unit_tests
40+
```
5141

52-
#### Build
53-
**Via [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md) (recommended):**
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:
5445
```bash
55-
airbyte-ci connectors --name source-instagram build
46+
airbyte-ci connectors --name=source-instagram build
5647
```
5748

58-
An image will be built with the tag `airbyte/source-instagram:dev`.
49+
An image will be available on your host with the tag `airbyte/source-instagram:dev`.
5950

60-
**Via `docker build`:**
61-
```bash
62-
docker build -t airbyte/source-instagram:dev .
63-
```
6451

65-
#### Run
52+
### Running as a docker container
6653
Then run any of the connector commands as follows:
6754
```
6855
docker run --rm airbyte/source-instagram:dev spec
@@ -71,29 +58,34 @@ docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-instagram:dev discover
7158
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-instagram:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
7259
```
7360

74-
## Testing
61+
### Running our CI test suite
7562
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
7663
```bash
7764
airbyte-ci connectors --name=source-instagram test
7865
```
7966

8067
### 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.
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.
8269
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.
8370

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
71+
### Dependency Management
72+
All of your dependencies should be managed via Poetry.
73+
To add a new dependency, run:
74+
```bash
75+
poetry add <package-name>
76+
```
77+
78+
Please commit the changes to `pyproject.toml` and `poetry.lock` files.
8979

90-
### Publishing a new version of the connector
80+
## Publishing a new version of the connector
9181
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
9282
1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-instagram 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).
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`
9486
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/instagram.md`).
87+
4. Make sure the connector documentation and its changelog is up to date (`docs/integrations/sources/instagram.md`).
9688
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).
9789
6. Pat yourself on the back for being an awesome contributor.
9890
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
99-
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-instagram/metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ data:
77
connectorSubtype: api
88
connectorType: source
99
definitionId: 6acf6b55-4f1e-4fca-944e-1a3caef8aba8
10-
dockerImageTag: 3.0.2
10+
dockerImageTag: 3.0.3
1111
dockerRepository: airbyte/source-instagram
1212
githubIssueLabel: source-instagram
1313
icon: instagram.svg

0 commit comments

Comments
 (0)