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 Typeform: Migrate to Low Code #29916

Merged
merged 25 commits into from Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
37bfb90
migrate typeform to low code
topefolorunso Aug 28, 2023
a125515
Merge branch 'master' of https://github.com/topefolorunso/airbyte int…
topefolorunso Aug 28, 2023
bcc4c43
Merge branch 'master' into typeform-low-code
marcosmarxm Aug 31, 2023
2a9e7f1
format manifest.yaml
topefolorunso Sep 1, 2023
ddde69e
add oauth
topefolorunso Sep 2, 2023
d84528f
fix path
topefolorunso Sep 2, 2023
056e6d8
fix partition router
topefolorunso Sep 2, 2023
a97f08f
Merge branch 'master' of https://github.com/airbytehq/airbyte into ty…
topefolorunso Sep 2, 2023
2a6fdb8
fix oauth
topefolorunso Sep 2, 2023
65809fc
fixes
marcosmarxm Sep 4, 2023
806350b
Merge branch 'master' of https://github.com/airbytehq/airbyte into ty…
topefolorunso Sep 4, 2023
beeb7c9
unit test FormIdPartitionRouter.stream_slices
topefolorunso Sep 4, 2023
da36bf4
Merge branch 'master' of https://github.com/airbytehq/airbyte into ty…
topefolorunso Sep 6, 2023
a2511a2
Merge branch 'master' of https://github.com/airbytehq/airbyte into ty…
topefolorunso Sep 6, 2023
721dfb9
fix
topefolorunso Sep 6, 2023
8cdad94
remove unit tests, unnecessary for low code
sh4sh Sep 7, 2023
c1ee445
revert unrelated commit
sh4sh Sep 7, 2023
669d8b9
Merge branch 'master' into typeform-low-code
sh4sh Sep 7, 2023
119cea5
fix spec path in acceptance test config
sh4sh Sep 7, 2023
80a978f
formatting
sh4sh Sep 7, 2023
d3b5ba0
formatting
sh4sh Sep 7, 2023
d6c9432
Revert "remove unit tests, unnecessary for low code"
sh4sh Sep 7, 2023
e00ccc2
fix releaseStage to generally_available
sh4sh Sep 7, 2023
b90b8ae
formatting
sh4sh Sep 7, 2023
6e52712
formatting unit test
sh4sh Sep 7, 2023
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
Expand Up @@ -27,6 +27,7 @@ definitions:
client_secret: "{{ config['credentials']['client_secret'] }}"
refresh_token: "{{ config['credentials']['refresh_token'] }}"
refresh_token_updater: {}
grant_type: refresh_token
sh4sh marked this conversation as resolved.
Show resolved Hide resolved
retriever:
type: SimpleRetriever
record_selector:
Expand Down
@@ -1,6 +1,5 @@
*
!Dockerfile
!Dockerfile.test
!main.py
!source_typeform
!setup.py
Expand Down
36 changes: 29 additions & 7 deletions airbyte-integrations/connectors/source-typeform/Dockerfile
@@ -1,16 +1,38 @@
FROM python:3.9-slim

# Bash is installed for more convenient debugging.
RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/*
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 ./
RUN pip install .
COPY source_typeform ./source_typeform
# 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_typeform ./source_typeform

ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=1.0.0
LABEL io.airbyte.version=1.1.0
LABEL io.airbyte.name=airbyte/source-typeform
65 changes: 8 additions & 57 deletions airbyte-integrations/connectors/source-typeform/README.md
@@ -1,34 +1,10 @@
# Typeform Source

This is the repository for the Typeform source connector, written in Python.
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/typeform).
This is the repository for the Typeform configuration based source connector.
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.com/integrations/sources/typeform).

## Local development

### Prerequisites
**To iterate on this connector, make sure to complete this prerequisites section.**

#### Minimum Python version required `= 3.7.0`

#### Build & Activate Virtual Environment and install dependencies
From this connector directory, create a virtual environment:
```
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
```
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.

#### Building via Gradle
You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow.

Expand All @@ -38,22 +14,14 @@ To build using Gradle, from the Airbyte repository root, run:
```

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

**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source typeform test creds`
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
```

### Locally running the connector docker image

#### Build
Expand All @@ -78,32 +46,15 @@ docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-typeform:dev discover
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-typeform:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
```
## Testing
Make sure to familiarize yourself with [pytest test discovery](https://docs.pytest.org/en/latest/goodpractices.html#test-discovery) to know how your test files and methods should be named.
First install test dependencies into your virtual environment:
```
pip install .[tests]
```
### Unit Tests
To run unit tests locally, from the connector directory run:
```
python -m pytest unit_tests
```

### Integration Tests
There are two types of integration tests: Acceptance Tests (Airbyte's test suite for all source connectors) and custom integration tests (which are specific to this connector).
#### Custom Integration tests
Place custom tests inside `integration_tests/` folder, then, from the connector root, run
```
python -m pytest integration_tests
```
#### Acceptance Tests
Customize `acceptance-test-config.yml` file to configure tests. See [Connector Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
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.
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.
To run your integration tests with acceptance tests, from the connector root, run

To run your integration tests with Docker, run:
```
python -m pytest integration_tests -p integration_tests.acceptance
./acceptance-test-docker.sh
```
To run your integration tests with docker

### Using gradle to run tests
All commands should be run from airbyte project root.
Expand Down
3 changes: 3 additions & 0 deletions airbyte-integrations/connectors/source-typeform/__init__.py
@@ -0,0 +1,3 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
@@ -1,42 +1,42 @@
# See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference)
# for more information about how to configure these tests
connector_image: airbyte/source-typeform:1.0.0
test_strictness_level: "high"
acceptance_tests:
spec:
tests:
- spec_path: "source_typeform/spec.json"
backward_compatibility_tests_config:
disable_for_version: "0.3.0"
- spec_path: "source_typeform/manifest.yaml"
backward_compatibility_tests_config:
disable_for_version: "0.3.0"
connection:
tests:
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "secrets/config_oauth.json"
status: "succeed"
- config_path: "integration_tests/invalid_config.json"
status: "failed"
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "secrets/config_oauth.json"
status: "succeed"
- config_path: "integration_tests/invalid_config.json"
status: "failed"
discovery:
tests:
- config_path: "secrets/config.json"
backward_compatibility_tests_config:
disable_for_version: "0.3.0"
- config_path: "secrets/config.json"
backward_compatibility_tests_config:
disable_for_version: "0.3.0"
basic_read:
tests:
- config_path: "secrets/config.json"
empty_streams:
- name: webhooks
bypass_reason: "no data"
expect_records:
path: "integration_tests/expected_records.jsonl"
fail_on_extra_columns: true
- config_path: "secrets/config.json"
empty_streams:
- name: webhooks
bypass_reason: "no data"
expect_records:
path: "integration_tests/expected_records.jsonl"
fail_on_extra_columns: true
incremental:
tests:
- config_path: "secrets/incremental_config.json"
configured_catalog_path: "integration_tests/configured_catalog_incremental.json"
future_state:
future_state_path: "integration_tests/abnormal_state.json"
cursor_paths:
"responses": ["SdMKQYkv", "submitted_at"]
- config_path: "secrets/incremental_config.json"
configured_catalog_path: "integration_tests/configured_catalog_incremental.json"
future_state:
future_state_path: "integration_tests/abnormal_state.json"
full_refresh:
tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
@@ -1,2 +1,3 @@
#!/usr/bin/env sh

source "$(git rev-parse --show-toplevel)/airbyte-integrations/bases/connector-acceptance-test/acceptance-test-docker.sh"
Expand Up @@ -2,21 +2,15 @@
{
"type": "STREAM",
"stream": {
"stream_descriptor": { "name": "responses" },
"stream_state": {
"SdMKQYkv": {
"submitted_at": 9999999999
},
"XtrcGoGJ": {
"submitted_at": 9999999999
},
"kRt99jlK": {
"submitted_at": 9999999999
},
"VWO7mLtl": {
"submitted_at": 9999999999
}
},
"stream_descriptor": { "name": "responses" }
"states": [
{
"partition": { "form_id": "SdMKQYkv" },
"cursor": { "submitted_at": "2050-09-04T16:39:47Z" }
}
]
}
}
}
]
Expand Up @@ -11,4 +11,6 @@
@pytest.fixture(scope="session", autouse=True)
def connector_setup():
"""This fixture is a placeholder for external resources that acceptance test might require."""
# TODO: setup test dependencies if needed. otherwise remove the TODO comments
yield
# TODO: clean up test dependencies
@@ -0,0 +1,3 @@
{
"fix-me": "TODO"
}
@@ -0,0 +1,16 @@
[
{
"type": "STREAM",
"stream": {
"stream_descriptor": { "name": "responses" },
"stream_state": {
"states": [
{
"partition": { "form_id": "SdMKQYkv" },
"cursor": { "submitted_at": "2021-09-04T16:39:47Z" }
}
]
}
}
}
]
21 changes: 11 additions & 10 deletions airbyte-integrations/connectors/source-typeform/metadata.yaml
Expand Up @@ -2,27 +2,28 @@ data:
allowedHosts:
hosts:
- api.typeform.com
registries:
cloud:
enabled: true
dockerImageTag: 1.1.0
oss:
enabled: true
connectorSubtype: api
connectorType: source
definitionId: e7eff203-90bf-43e5-a240-19ea3056c474
dockerImageTag: 1.0.0
dockerImageTag: 1.1.0
dockerRepository: airbyte/source-typeform
githubIssueLabel: source-typeform
icon: typeform.svg
license: MIT
name: Typeform
registries:
cloud:
enabled: true
dockerImageTag: 1.0.0
oss:
enabled: true
releaseStage: generally_available
releaseDate: 2021-07-10
releaseStage: alpha
supportLevel: community
documentationUrl: https://docs.airbyte.com/integrations/sources/typeform
tags:
- language:python
- language:low-code
ab_internal:
sl: 200
ql: 400
supportLevel: certified
metadataSpecVersion: "1.0"
8 changes: 3 additions & 5 deletions airbyte-integrations/connectors/source-typeform/setup.py
Expand Up @@ -5,11 +5,9 @@

from setuptools import find_packages, setup

MAIN_REQUIREMENTS = [
"airbyte-cdk",
]
MAIN_REQUIREMENTS = ["airbyte-cdk~=0.1"]

TEST_REQUIREMENTS = ["requests-mock~=1.9.3", "pytest~=6.1", "pytest-mock~=3.6", "requests_mock~=1.8"]
TEST_REQUIREMENTS = ["requests-mock~=1.9.3", "pytest~=6.2", "pytest-mock~=3.6.1"]

setup(
name="source_typeform",
Expand All @@ -18,7 +16,7 @@
author_email="contact@airbyte.io",
packages=find_packages(),
install_requires=MAIN_REQUIREMENTS,
package_data={"": ["*.json", "schemas/*.json", "schemas/shared/*.json"]},
package_data={"": ["*.json", "*.yaml", "schemas/*.json", "schemas/shared/*.json"]},
extras_require={
"tests": TEST_REQUIREMENTS,
},
Expand Down
@@ -1,29 +1,7 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
"""
MIT License

Copyright (c) 2020 Airbyte

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

from .source import SourceTypeform

Expand Down