Skip to content

Commit e3ff75f

Browse files
jrhizormarcosmarxmoctavia-squidington-iii
authored
🎉 New Source: Whisky Hunter API [low-code CDK] (#17918)
* initial commit for source-whisky-hunter * better logs * finish up connector * fix catalog * fix bug in connector_runner.py that doesn't allow falsey configs * add bootstrap.md * add docs * fix typo * fix source-accept test * auto-bump connector version Co-authored-by: marcosmarxm <[email protected]> Co-authored-by: Octavia Squidington III <[email protected]>
1 parent 067e36d commit e3ff75f

File tree

32 files changed

+726
-4
lines changed

32 files changed

+726
-4
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,13 @@
11561156
icon: webflow.svg
11571157
sourceType: api
11581158
releaseStage: alpha
1159+
- name: Whisky Hunter
1160+
sourceDefinitionId: e65f84c0-7598-458a-bfac-f770c381ff5d
1161+
dockerRepository: airbyte/source-whisky-hunter
1162+
dockerImageTag: 0.1.0
1163+
documentationUrl: https://docs.airbyte.com/integrations/sources/whisky-hunter
1164+
sourceType: api
1165+
releaseStage: alpha
11591166
- name: WooCommerce
11601167
sourceDefinitionId: 2a2552ca-9f78-4c1c-9eb7-4d0dc66d72df
11611168
dockerRepository: airbyte/source-woocommerce

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11844,6 +11844,18 @@
1184411844
supportsNormalization: false
1184511845
supportsDBT: false
1184611846
supported_destination_sync_modes: []
11847+
- dockerImage: "airbyte/source-whisky-hunter:0.1.0"
11848+
spec:
11849+
documentationUrl: "https://docs.airbyte.io/integrations/sources/whisky-hunter"
11850+
connectionSpecification:
11851+
$schema: "http://json-schema.org/draft-07/schema#"
11852+
title: "Whisky Hunter Spec"
11853+
type: "object"
11854+
additionalProperties: true
11855+
properties: {}
11856+
supportsNormalization: false
11857+
supportsDBT: false
11858+
supported_destination_sync_modes: []
1184711859
- dockerImage: "airbyte/source-woocommerce:0.1.2"
1184811860
spec:
1184911861
documentationUrl: "https://docs.airbyte.com/integrations/sources/woocommerce"

airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/tests/test_core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,10 @@ def _validate_records_structure(records: List[AirbyteRecordMessage], configured_
360360
continue
361361
record_fields = set(get_object_structure(record.data))
362362
common_fields = set.intersection(record_fields, schema_pathes)
363-
assert common_fields, f" Record from {record.stream} stream should have some fields mentioned by json schema, {schema_pathes}"
363+
364+
assert (
365+
common_fields
366+
), f" Record {record} from {record.stream} stream with fields {record_fields} should have some fields mentioned by json schema: {schema_pathes}"
364367

365368
@staticmethod
366369
def _validate_schema(records: List[AirbyteRecordMessage], configured_catalog: ConfiguredAirbyteCatalog):

airbyte-integrations/bases/source-acceptance-test/source_acceptance_test/utils/connector_runner.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def _prepare_volumes(self, config: Optional[Mapping], state: Optional[Mapping],
3939
self.input_folder.mkdir(parents=True)
4040
self.output_folder.mkdir(parents=True)
4141

42-
if config:
42+
# using "is not None" to allow falsey config objects like {} to still write
43+
if config is not None:
4344
with open(str(self.input_folder / "tap_config.json"), "w") as outfile:
4445
json.dump(dict(config), outfile)
4546

@@ -149,7 +150,7 @@ def read(cls, container: Container, command: str = None, with_ext: bool = True)
149150
raise
150151
if exit_status["StatusCode"]:
151152
error = exit_status["Error"] or exception or line
152-
logging.error(f"Docker container was failed, " f'code {exit_status["StatusCode"]}, error:\n{error}')
153+
logging.error(f"Docker container failed, " f'code {exit_status["StatusCode"]}, error:\n{error}')
153154
if with_ext:
154155
raise ContainerError(
155156
container=container,

airbyte-integrations/bases/source-acceptance-test/unit_tests/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def test_read(schema, record, should_fail):
268268
]
269269
t = _TestBasicRead()
270270
if should_fail:
271-
with pytest.raises(AssertionError, match="stream should have some fields mentioned by json schema"):
271+
with pytest.raises(AssertionError, match="should have some fields mentioned by json schema"):
272272
t.test_read(None, catalog, input_config, [], docker_runner_mock, MagicMock())
273273
else:
274274
t.test_read(None, catalog, input_config, [], docker_runner_mock, MagicMock())

airbyte-integrations/builds.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
| Twilio | [![source-twilio](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-twilio%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-twilio) |
119119
| Typeform | [![source-typeform](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-typeform%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-typeform) |
120120
| US Census | [![source-us-census](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-us-census%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-us-census) |
121+
| Whisky Hunter | [![source-whisky-hunter](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-whisky-hunter%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-whisky-hunter) |
121122
| Wrike | [![source-wrike](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-wrike%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-wrike) |
122123
| YouTube Analytics | [![source-youtube-analytics](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-youtube-analytics%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-youtube-analytics) |
123124
| Zendesk Chat | [![source-zendesk-chat](https://img.shields.io/endpoint?url=https%3A%2F%2Fdnsgjos7lj2fu.cloudfront.net%2Ftests%2Fsummary%2Fsource-zendesk-chat%2Fbadge.json)](https://dnsgjos7lj2fu.cloudfront.net/tests/summary/source-zendesk-chat) |
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
!Dockerfile
3+
!main.py
4+
!source_whisky_hunter
5+
!setup.py
6+
!secrets
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM python:3.9.11-alpine3.15 as base
2+
3+
# build and load all requirements
4+
FROM base as builder
5+
WORKDIR /airbyte/integration_code
6+
7+
# upgrade pip to the latest version
8+
RUN apk --no-cache upgrade \
9+
&& pip install --upgrade pip \
10+
&& apk --no-cache add tzdata build-base
11+
12+
13+
COPY setup.py ./
14+
# install necessary packages to a temporary folder
15+
RUN pip install --prefix=/install .
16+
17+
# build a clean environment
18+
FROM base
19+
WORKDIR /airbyte/integration_code
20+
21+
# copy all loaded and built libraries to a pure basic image
22+
COPY --from=builder /install /usr/local
23+
# add default timezone settings
24+
COPY --from=builder /usr/share/zoneinfo/Etc/UTC /etc/localtime
25+
RUN echo "Etc/UTC" > /etc/timezone
26+
27+
# bash is installed for more convenient debugging.
28+
RUN apk --no-cache add bash
29+
30+
# copy payload code only
31+
COPY main.py ./
32+
COPY source_whisky_hunter ./source_whisky_hunter
33+
34+
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
35+
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
36+
37+
LABEL io.airbyte.version=0.1.0
38+
LABEL io.airbyte.name=airbyte/source-whisky-hunter
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Whisky Hunter Source
2+
3+
This is the repository for the Whisky Hunter configuration based source connector.
4+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/whisky-hunter).
5+
6+
## Local development
7+
8+
#### Building via Gradle
9+
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.
10+
11+
To build using Gradle, from the Airbyte repository root, run:
12+
```
13+
./gradlew :airbyte-integrations:connectors:source-whisky-hunter:build
14+
```
15+
16+
#### Create credentials
17+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/whisky-hunter)
18+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_whisky_hunter/spec.yaml` file.
19+
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
20+
See `integration_tests/sample_config.json` for a sample config file.
21+
22+
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source whisky-hunter test creds`
23+
and place them into `secrets/config.json`.
24+
25+
### Locally running the connector docker image
26+
27+
#### Build
28+
First, make sure you build the latest Docker image:
29+
```
30+
docker build . -t airbyte/source-whisky-hunter:dev
31+
```
32+
33+
You can also build the connector image via Gradle:
34+
```
35+
./gradlew :airbyte-integrations:connectors:source-whisky-hunter:airbyteDocker
36+
```
37+
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
38+
the Dockerfile.
39+
40+
#### Run
41+
Then run any of the connector commands as follows:
42+
```
43+
docker run --rm airbyte/source-whisky-hunter:dev spec
44+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-whisky-hunter:dev check --config /secrets/config.json
45+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-whisky-hunter:dev discover --config /secrets/config.json
46+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-whisky-hunter:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
47+
```
48+
## Testing
49+
50+
#### Acceptance Tests
51+
Customize `acceptance-test-config.yml` file to configure tests. See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference) for more information.
52+
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.
53+
54+
To run your integration tests with docker
55+
56+
### Using gradle to run tests
57+
All commands should be run from airbyte project root.
58+
To run unit tests:
59+
```
60+
./gradlew :airbyte-integrations:connectors:source-whisky-hunter:unitTest
61+
```
62+
To run acceptance and custom integration tests:
63+
```
64+
./gradlew :airbyte-integrations:connectors:source-whisky-hunter:integrationTest
65+
```
66+
67+
## Dependency Management
68+
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.
69+
We split dependencies between two groups, dependencies that are:
70+
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
71+
* required for the testing need to go to `TEST_REQUIREMENTS` list
72+
73+
### Publishing a new version of the connector
74+
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
75+
1. Make sure your changes are passing unit and integration tests.
76+
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)).
77+
1. Create a Pull Request.
78+
1. Pat yourself on the back for being an awesome contributor.
79+
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
3+
#

0 commit comments

Comments
 (0)