Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source google ads: migrate to python based image #31908

Merged
merged 7 commits into from Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 0 additions & 17 deletions airbyte-integrations/connectors/source-google-ads/Dockerfile

This file was deleted.

69 changes: 60 additions & 9 deletions airbyte-integrations/connectors/source-google-ads/README.md
Expand Up @@ -54,19 +54,70 @@ python main.py read --config secrets/config.json --catalog integration_tests/con

### Locally running the connector docker image

#### Build
First, make sure you build the latest Docker image:
```
docker build . -t airbyte/source-google-ads:dev


#### 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-google-ads build
```
Once the command is done, you will find your connector image in your local docker registry: `airbyte/source-google-ads: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

You can also build the connector image via Gradle:

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")
```
./gradlew :airbyte-integrations:connectors:source-google-ads:airbyteDocker

#### 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-google-ads:latest

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"]
```
When building via Gradle, the docker image name and tag, respectively, are the values of the `io.airbyte.name` and `io.airbyte.version` `LABEL`s in
the Dockerfile.
Please use this as an example. This is not optimized.

2. Build your image:
```bash
docker build -t airbyte/source-google-ads:dev .
# Running the spec command against your patched connector
docker run airbyte/source-google-ads:dev spec
```
#### Run
Then run any of the connector commands as follows:
```
Expand Down Expand Up @@ -126,4 +177,4 @@ You've checked out the repo, implemented a million dollar feature, and you're re
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)).
1. Create a Pull Request.
1. Pat yourself on the back for being an awesome contributor.
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
73 changes: 40 additions & 33 deletions airbyte-integrations/connectors/source-google-ads/metadata.yaml
@@ -1,13 +1,19 @@
data:
ab_internal:
ql: 400
sl: 300
allowedHosts:
hosts:
- accounts.google.com
- googleads.googleapis.com
- accounts.google.com
- googleads.googleapis.com
connectorBuildOptions:
baseImage: docker.io/airbyte/python-connector-base:1.1.0@sha256:bd98f6505c6764b1b5f99d3aedc23dfc9e9af631a62533f60eb32b1d3dbab20c
connectorSubtype: api
connectorType: source
definitionId: 253487c0-2246-43ba-a21f-5116b20a2c50
dockerImageTag: 2.0.0
dockerImageTag: 2.0.1
dockerRepository: airbyte/source-google-ads
documentationUrl: https://docs.airbyte.com/integrations/sources/google-ads
githubIssueLabel: source-google-ads
icon: google-adwords.svg
license: Elv2
Expand All @@ -18,37 +24,38 @@ data:
oss:
enabled: true
releaseStage: generally_available
suggestedStreams:
streams:
- campaigns
- accounts
- ad_group_ads
- ad_group_ad_report
- ad_groups
- click_view
- account_performance_report
- keyword_report
- campaign_labels
- ad_group_labels
- ad_group_ad_labels
- user_location_report
- geographic_report
- display_keyword_performance_report
- shopping_performance_report
- display_topics_performance_report
releases:
breakingChanges:
2.0.0:
message: This release updates the Source Google Ads connector so that its default streams and stream names match the related resources in Google Ads API. Users should refresh the source schema and reset affected streams after upgrading to ensure uninterrupted syncs.
upgradeDeadline: "2023-11-30"
1.0.0:
message: This release introduces fixes to custom query schema creation. Users should refresh the source schema and reset affected streams after upgrading to ensure uninterrupted syncs.
upgradeDeadline: "2023-10-31"
documentationUrl: https://docs.airbyte.com/integrations/sources/google-ads
tags:
- language:python
ab_internal:
sl: 300
ql: 400
message: This release introduces fixes to custom query schema creation. Users
should refresh the source schema and reset affected streams after upgrading
to ensure uninterrupted syncs.
upgradeDeadline: '2023-10-31'
2.0.0:
message: This release updates the Source Google Ads connector so that its
default streams and stream names match the related resources in Google Ads
API. Users should refresh the source schema and reset affected streams after
upgrading to ensure uninterrupted syncs.
upgradeDeadline: '2023-11-30'
suggestedStreams:
streams:
- campaigns
- accounts
- ad_group_ads
- ad_group_ad_report
- ad_groups
- click_view
- account_performance_report
- keyword_report
- campaign_labels
- ad_group_labels
- ad_group_ad_labels
- user_location_report
- geographic_report
- display_keyword_performance_report
- shopping_performance_report
- display_topics_performance_report
supportLevel: certified
metadataSpecVersion: "1.0"
tags:
- language:python
metadataSpecVersion: '1.0'
3 changes: 2 additions & 1 deletion docs/integrations/sources/google-ads.md
Expand Up @@ -278,6 +278,7 @@ Due to a limitation in the Google Ads API which does not allow getting performan

| Version | Date | Pull Request | Subject |
|:---------|:-----------|:---------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------|
| `2.0.1` | 2023-10-27 | [31908](https://github.com/airbytehq/airbyte/pull/31908) | Base image migration: remove Dockerfile and use the python-connector-base image |
| `2.0.0` | 2023-10-04 | [31048](https://github.com/airbytehq/airbyte/pull/31048) | Fix schem default streams, change names of streams. |
| `1.0.0` | 2023-09-28 | [30705](https://github.com/airbytehq/airbyte/pull/30705) | Fix schemas for custom queries |
| `0.11.1` | 2023-09-26 | [30758](https://github.com/airbytehq/airbyte/pull/30758) | Exception should not be raises if a stream is not found |
Expand Down Expand Up @@ -364,4 +365,4 @@ Due to a limitation in the Google Ads API which does not allow getting performan
| `0.1.4` | 2021-07-28 | [4962](https://github.com/airbytehq/airbyte/pull/4962) | Support new Report streams |
| `0.1.3` | 2021-07-23 | [4788](https://github.com/airbytehq/airbyte/pull/4788) | Support main streams, fix bug with exception `DATE_RANGE_TOO_NARROW` for incremental streams |
| `0.1.2` | 2021-07-06 | [4539](https://github.com/airbytehq/airbyte/pull/4539) | Add `AIRBYTE_ENTRYPOINT` for Kubernetes support |
| `0.1.1` | 2021-06-23 | [4288](https://github.com/airbytehq/airbyte/pull/4288) | Fix `Bugfix: Correctly declare required parameters` |
| `0.1.1` | 2021-06-23 | [4288](https://github.com/airbytehq/airbyte/pull/4288) | Fix `Bugfix: Correctly declare required parameters` |