Skip to content

Commit

Permalink
🚨Source Outbrain Amplify: Migrate to poetry (#41035)
Browse files Browse the repository at this point in the history
Co-authored-by: Christo Grabowski <[email protected]>
  • Loading branch information
btkcodedev and ChristoGrab authored Jul 9, 2024
1 parent c28de18 commit 8757e21
Show file tree
Hide file tree
Showing 9 changed files with 1,140 additions and 123 deletions.

This file was deleted.

38 changes: 0 additions & 38 deletions airbyte-integrations/connectors/source-outbrain-amplify/Dockerfile

This file was deleted.

62 changes: 55 additions & 7 deletions airbyte-integrations/connectors/source-outbrain-amplify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,70 @@ python main.py read --config secrets/config.json --catalog integration_tests/con

### Locally running the connector docker image

#### Build

**Via [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md) (recommended):**

#### Use `airbyte-ci` to build your connector
The Airbyte way of building this connector is to use our `airbyte-ci` tool.
You can follow install instructions [here](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md#L1).
Then running the following command will build your connector:

```bash
airbyte-ci connectors --name=source-outbrain-amplify build
airbyte-ci connectors --name source-outbrain-amplify build
```
Once the command is done, you will find your connector image in your local docker registry: `airbyte/source-outbrain-amplify:dev`.

##### Customizing our build process
When contributing on our connector you might need to customize the build process to add a system dependency or set an env var.
You can customize our build process by adding a `build_customization.py` module to your connector.
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.
It will be imported at runtime by our build process and the functions will be called if they exist.

Here is an example of a `build_customization.py` module:
```python
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
# Feel free to check the dagger documentation for more information on the Container object and its methods.
# https://dagger-io.readthedocs.io/en/sdk-python-v0.6.4/
from dagger import Container


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

async def post_connector_install(connector_container: Container) -> Container:
return await connector_container.with_env_variable("MY_POST_BUILD_ENV_VAR", "my_post_build_env_var_value")
```

An image will be built with the tag `airbyte/source-outbrain-amplify:dev`.
#### Build your own connector image
This connector is built using our dynamic built process in `airbyte-ci`.
The base image used to build it is defined within the metadata.yaml file under the `connectorBuildOptions`.
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).
It does not rely on a Dockerfile.

If you would like to patch our connector and build your own a simple approach would be to:

1. Create your own Dockerfile based on the latest version of the connector image.
```Dockerfile
FROM airbyte/source-outbrain-amplify:latest

**Via `docker build`:**
COPY . ./airbyte/integration_code
RUN pip install ./airbyte/integration_code

# The entrypoint and default env vars are already set in the base image
# ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
# ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
```
Please use this as an example. This is not optimized.

2. Build your image:
```bash
docker build -t airbyte/source-outbrain-amplify:dev .
# Running the spec command against your patched connector
docker run airbyte/source-outbrain-amplify:dev spec
```

#### Run

Then run any of the connector commands as follows:
Expand Down Expand Up @@ -114,4 +162,4 @@ You've checked out the repo, implemented a million dollar feature, and you're re
4. Make the connector documentation and its changelog is up to date (`docs/integrations/sources/outbrain-amplify.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.
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
data:
remoteRegistries:
pypi:
enabled: true
packageName: airbyte-source-outbrain-amplify
registries:
cloud:
enabled: true
oss:
enabled: true
ab_internal:
ql: 100
sl: 100
connectorBuildOptions:
baseImage: docker.io/airbyte/python-connector-base:1.2.2@sha256:57703de3b4c4204bd68a7b13c9300f8e03c0189bffddaffc796f1da25d2dbea0
connectorSubtype: api
connectorTestSuitesOptions:
- suite: unitTests
- suite: acceptanceTests
testSecrets:
- fileName: config.json
name: SECRET_SOURCE-OUTBRAIN-AMPLIFY__CREDS
secretStore:
alias: airbyte-connector-testing-secret-store
type: GSM
connectorType: source
definitionId: 4fe962d0-a70e-4516-aa99-c551abf46352
dockerImageTag: 0.1.2
dockerImageTag: 0.1.3
dockerRepository: airbyte/source-outbrain-amplify
documentationUrl: https://docs.airbyte.com/integrations/sources/outbrain-amplify
githubIssueLabel: source-outbrain-amplify
icon: icon.svg
license: MIT
name: Outbrain Amplify
registries:
cloud:
enabled: true
oss:
enabled: true
releaseStage: alpha
documentationUrl: https://docs.airbyte.com/integrations/sources/outbrain-amplify
remoteRegistries:
pypi:
enabled: true
packageName: airbyte-source-outbrain-amplify
supportLevel: community
tags:
- language:python
- cdk:python
ab_internal:
sl: 100
ql: 100
supportLevel: community
connectorTestSuitesOptions:
- suite: unitTests
- suite: acceptanceTests
testSecrets:
- name: SECRET_SOURCE-OUTBRAIN-AMPLIFY__CREDS
fileName: config.json
secretStore:
type: GSM
alias: airbyte-connector-testing-secret-store
metadataSpecVersion: "1.0"
Loading

0 comments on commit 8757e21

Please sign in to comment.