1
0
mirror of synced 2025-12-25 02:09:19 -05:00

Source Freshcaller: Migrate to poetry (#40618)

Co-authored-by: Natik Gadzhi <natik@respawn.io>
This commit is contained in:
Christo Grabowski
2024-07-05 09:27:24 -07:00
committed by GitHub
parent 834ae6332d
commit d2d548f08f
8 changed files with 1169 additions and 157 deletions

View File

@@ -1,6 +0,0 @@
*
!Dockerfile
!main.py
!source_freshcaller
!setup.py
!secrets

View File

@@ -1,38 +0,0 @@
FROM python:3.9.11-alpine3.15 as base
# build and load all requirements
FROM base as builder
WORKDIR /airbyte/integration_code
# upgrade pip to the latest version
RUN apk --no-cache upgrade \
&& pip install --upgrade pip \
&& apk --no-cache add tzdata build-base
COPY setup.py ./
# install necessary packages to a temporary folder
RUN pip install --prefix=/install .
# build a clean environment
FROM base
WORKDIR /airbyte/integration_code
# copy all loaded and built libraries to a pure basic image
COPY --from=builder /install /usr/local
# add default timezone settings
COPY --from=builder /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN echo "Etc/UTC" > /etc/timezone
# bash is installed for more convenient debugging.
RUN apk --no-cache add bash
# copy payload code only
COPY main.py ./
COPY source_freshcaller ./source_freshcaller
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
LABEL io.airbyte.version=0.3.1
LABEL io.airbyte.name=airbyte/source-freshcaller

View File

@@ -1,4 +1,4 @@
# Freshcaller Source
# Freshcaller source connector
This is the repository for the Freshcaller source connector, written in Python.
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/freshcaller).
@@ -7,33 +7,16 @@ For information about how to use this connector within Airbyte, see [the documen
### Prerequisites
**To iterate on this connector, make sure to complete this prerequisites section.**
- Python (~=3.9)
- Poetry (~=1.7) - installation instructions [here](https://python-poetry.org/docs/#installation)
#### Minimum Python version required `= 3.7.0`
### Installing the connector
#### Build & Activate Virtual Environment and install dependencies
From this connector directory, create a virtual environment:
From this connector directory, run:
```bash
poetry install --with dev
```
python -m venv .venv
```
This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
development environment of choice. To activate it from the terminal, run:
```
source .venv/bin/activate
pip install -r requirements.txt
pip install '.[tests]'
```
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
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
should work as you expect.
#### Create credentials
@@ -48,31 +31,32 @@ and place them into `secrets/config.json`.
### Locally running the connector
```
python main.py spec
python main.py check --config secrets/config.json
python main.py discover --config secrets/config.json
python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
poetry run main.py spec
poetry run main.py check --config secrets/config.json
poetry run main.py discover --config secrets/config.json
poetry run main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
```
### Locally running the connector docker image
### Running unit tests
#### Build
To run unit tests locally, from the connector directory run:
**Via [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md) (recommended):**
```
poetry run pytest unit_tests
```
### Building the docker image
1. Install [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)
2. Run the following command to build the docker image:
```bash
airbyte-ci connectors --name=source-freshcaller build
```
An image will be built with the tag `airbyte/source-freshcaller:dev`.
An image will be available on your host with the tag `airbyte/source-freshcaller:dev`.
**Via `docker build`:**
```bash
docker build -t airbyte/source-freshcaller:dev .
```
#### Run
### Running as a docker container
Then run any of the connector commands as follows:
@@ -83,7 +67,7 @@ docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-freshcaller:dev discov
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-freshcaller:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
```
## Testing
### Running our CI test suite
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
@@ -93,25 +77,31 @@ airbyte-ci connectors --name=source-freshcaller test
### Customizing acceptance Tests
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.
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.
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.
## Dependency Management
### Dependency Management
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.
We split dependencies between two groups, dependencies that are:
All of your dependencies should be managed via Poetry.
To add a new dependency, run:
- required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
- required for the testing need to go to `TEST_REQUIREMENTS` list
```bash
poetry add <package-name>
```
### Publishing a new version of the connector
Please commit the changes to `pyproject.toml` and `poetry.lock` files.
## Publishing a new version of the connector
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-freshcaller test`
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).
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)):
- bump the `dockerImageTag` value in in `metadata.yaml`
- bump the `version` value in `pyproject.toml`
3. Make sure the `metadata.yaml` content is up to date.
4. Make the connector documentation and its changelog is up to date (`docs/integrations/sources/freshcaller.md`).
4. Make sure the connector documentation and its changelog is up to date (`docs/integrations/sources/freshcaller.md`).
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).
6. Pat yourself on the back for being an awesome contributor.
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
8. Once your PR is merged, the new version of the connector will be automatically published to Docker Hub and our connector registry.

View File

@@ -1,37 +1,39 @@
data:
ab_internal:
ql: 100
sl: 200
connectorBuildOptions:
baseImage: docker.io/airbyte/python-connector-base:1.2.2@sha256:57703de3b4c4204bd68a7b13c9300f8e03c0189bffddaffc796f1da25d2dbea0
connectorSubtype: api
connectorTestSuitesOptions:
- suite: acceptanceTests
testSecrets:
- fileName: config.json
name: SECRET_SOURCE-FRESHCALLER__CREDS
secretStore:
alias: airbyte-connector-testing-secret-store
type: GSM
connectorType: source
definitionId: 8a5d48f6-03bb-4038-a942-a8d3f175cca3
dockerImageTag: 0.3.1
dockerImageTag: 0.3.2
dockerRepository: airbyte/source-freshcaller
documentationUrl: https://docs.airbyte.com/integrations/sources/freshcaller
githubIssueLabel: source-freshcaller
icon: freshcaller.svg
license: MIT
name: Freshcaller
remoteRegistries:
pypi:
enabled: true
packageName: airbyte-source-freshcaller
registries:
cloud:
enabled: true
oss:
enabled: true
releaseStage: alpha
remoteRegistries:
pypi:
enabled: true
packageName: airbyte-source-freshcaller
supportLevel: community
documentationUrl: https://docs.airbyte.com/integrations/sources/freshcaller
tags:
- language:python
- cdk:low-code
ab_internal:
sl: 100
ql: 100
connectorTestSuitesOptions:
- suite: acceptanceTests
testSecrets:
- name: SECRET_SOURCE-FRESHCALLER__CREDS
fileName: config.json
secretStore:
type: GSM
alias: airbyte-connector-testing-secret-store
metadataSpecVersion: "1.0"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,28 @@
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry]
version = "0.3.2"
name = "source-freshcaller"
description = "Source implementation for Freshcaller"
authors = ["Airbyte <contact@airbyte.io>"]
license = "MIT"
readme = "README.md"
documentation = "https://docs.airbyte.com/integrations/sources/freshcaller"
homepage = "https://airbyte.com"
repository = "https://github.com/airbytehq/airbyte"
[[tool.poetry.packages]]
include = "source_freshcaller"
[tool.poetry.dependencies]
python = "^3.9,<3.12"
airbyte-cdk = "0.55.2"
[tool.poetry.scripts]
source-freshcaller = "source_freshcaller.run:run"
[tool.poetry.group.dev.dependencies]
requests-mock = "^1.9.3"
pytest-mock = "^3.12.0"
pytest = "^8.0.0"

View File

@@ -1,46 +0,0 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
from setuptools import find_packages, setup
MAIN_REQUIREMENTS = [
"airbyte-cdk",
]
TEST_REQUIREMENTS = [
"pytest~=6.2",
"pytest-mock~=3.6.1",
"requests-mock~=1.9.3",
]
setup(
entry_points={
"console_scripts": [
"source-freshcaller=source_freshcaller.run:run",
],
},
name="source_freshcaller",
description="Source implementation for Freshcaller.",
author="Airbyte",
author_email="contact@airbyte.io",
packages=find_packages(),
install_requires=MAIN_REQUIREMENTS,
package_data={
"": [
# Include yaml files in the package (if any)
"*.yml",
"*.yaml",
# Include all json files in the package, up to 4 levels deep
"*.json",
"*/*.json",
"*/*/*.json",
"*/*/*/*.json",
"*/*/*/*/*.json",
]
},
extras_require={
"tests": TEST_REQUIREMENTS,
},
)

View File

@@ -46,9 +46,10 @@ Please read [How to find your API key](https://support.freshdesk.com/en/support/
| Version | Date | Pull Request | Subject |
| :------ | :--------- | :------------------------------------------------------- | :------------------------------------------------ |
| 0.3.2 | 2024-07-01 | [40618](https://github.com/airbytehq/airbyte/pull/40618) | Migrate to base image and poetry, update CDK |
| 0.3.1 | 2023-11-28 | [32874](https://github.com/airbytehq/airbyte/pull/32874) | 🐛 Source: fix page_size_option parameter in spec |
| 0.3.0 | 2023-10-24 | [31102](https://github.com/airbytehq/airbyte/pull/14759) | ✨ Source: Migrate to Low Code CDK |
| 0.2.0 | 2023-05-15 | [26065](https://github.com/airbytehq/airbyte/pull/26065) | Fix spec type check for `start_date` |
| 0.1.0 | 2022-08-11 | [14759](https://github.com/airbytehq/airbyte/pull/14759) | 🎉 New Source: Freshcaller |
</details>
</details>