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

Feature/source kobo tool #94

Open
wants to merge 75 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
57e26f6
kobo toolbox
siddhant3030 Feb 16, 2023
03d7d0a
connector working here
siddhant3030 Feb 23, 2023
1c15b7b
normalisation is done here
siddhant3030 Feb 24, 2023
f7bb4a1
refactor
siddhant3030 Mar 3, 2023
ed9aa21
kobo tool box added pagination in data read
Ishankoradia Mar 9, 2023
8d8dc50
cleanup
Ishankoradia Mar 9, 2023
9e627f8
updated stream name with the form name
Ishankoradia Mar 10, 2023
2626ce4
unit test cases, acceptance test cases, cleanup and refactoring of code
Ishankoradia Mar 15, 2023
f40965d
added svg logo, documentation .md file and added the connector in seed
Ishankoradia Mar 16, 2023
e907446
minor changes
Ishankoradia Mar 16, 2023
98b052d
Merge branch 'master' into feature/source_kobo_tool
siddhant3030 Mar 16, 2023
ceb312f
updated the PR number in docs
Ishankoradia Mar 16, 2023
7553867
Merge branch 'master' into feature/source_kobo_tool
siddhant3030 Mar 16, 2023
62cb19b
incremental sync
Ishankoradia Mar 17, 2023
0e7db8a
Merge branch 'master' into feature/source_kobo_tool
siddhant3030 Mar 17, 2023
d12db06
Merge branch 'master' into feature/source_kobo_tool
siddhant3030 Mar 18, 2023
2486625
Merge branch 'master' into feature/source_kobo_tool
siddhant3030 Mar 19, 2023
72c3204
incremental sync in kobo connector
Ishankoradia Mar 20, 2023
20bf345
fixed issue
siddhant3030 Mar 21, 2023
fe9f8d6
yaml file 2 space indentation and removing supportsNomarlization option
Ishankoradia Mar 22, 2023
04bdea0
added additionalProperties in spec.yaml file
Ishankoradia Mar 22, 2023
cd76db1
Merge remote-tracking branch 'origin/feature/kobo_incremental' into f…
Ishankoradia Mar 22, 2023
959bd82
Merge remote-tracking branch 'origin/feature/source_kobo_tool' into f…
Ishankoradia Mar 22, 2023
93b48b8
helpers file not needed - base schema function removed
Ishankoradia Mar 22, 2023
70eae8d
incremental sync test cases and cleanup, formatting
Ishankoradia Mar 22, 2023
4caf31b
doc changes - added incremental sync modes and normalization mode not…
Ishankoradia Mar 22, 2023
ea7bc17
Merge branch 'master' into feature/source_kobo_tool
siddhant3030 Mar 27, 2023
3e1a08e
using greater than equal while querying api
Ishankoradia Mar 29, 2023
95e4507
Merge branch 'master' into feature/source_kobo_tool
siddhant3030 Mar 29, 2023
86bb45e
Merge branch 'master' into feature/source_kobo_tool
siddhant3030 Mar 31, 2023
0ed4b5b
Merge branch 'master' into feature/source_kobo_tool
siddhant3030 Mar 31, 2023
93b8d46
Merge branch 'master' into feature/source_kobo_tool
siddhant3030 Apr 1, 2023
ba9bb82
Merge branch 'master' into feature/source_kobo_tool
siddhant3030 Apr 4, 2023
26951df
updated cursor field to endtime - update docs, test cases and stream …
Ishankoradia Apr 13, 2023
5865f8a
Merge remote-tracking branch 'origin/master' into feature/source_kobo…
Ishankoradia May 3, 2023
32a2a89
changing cursor field to _submission_time
Ishankoradia May 3, 2023
3cad24a
added a base url for the kobo connector
Ishankoradia Jul 10, 2023
436a9bb
added the feature of excluding fields while syncing with kobo connector
Ishankoradia Jul 12, 2023
353c7f9
change stream name
Ishankoradia Jul 13, 2023
54ca877
Merge pull request #41 from DevDataPlatform/feature/kobo-multiple-bas…
siddhant3030 Aug 3, 2023
b4ce6a8
added new base url for lahi
Ishankoradia Sep 8, 2023
6095e0b
Merge branch 'master' into feature/source_kobo_tool
Sep 25, 2023
ab0eff7
return each record inside {data}
Sep 28, 2023
b2dd317
upgrade version tag
Sep 28, 2023
95667cb
renamed image
Sep 29, 2023
65ae3cf
put data into the stream schema
Sep 29, 2023
fa6911b
formatting only
Sep 30, 2023
30e6cb5
Merge branch 'feature/source_kobo_tool' into kobotoolbox-for-050
Sep 30, 2023
7b86e7d
Merge pull request #59 from DalgoT4D/kobotoolbox-for-050
fatchat Oct 11, 2023
cc1c3b6
KoboStreamEndTime and KoboStreamSubmissionTime classes
Nov 30, 2023
25e3d5a
refactored
Dec 2, 2023
62f5139
remove unused import
Dec 4, 2023
39170a0
ensure that "forms_using_endtime" is in the config
Dec 4, 2023
e35a651
tz calculations
Dec 4, 2023
c703b88
helper to set tzinfo
Dec 4, 2023
ee5d388
use "end" as a cursor
Dec 6, 2023
575bb72
added "end" to the json schema
Dec 6, 2023
a613ac8
put end into the record
Dec 6, 2023
3700641
Merge pull request #69 from DalgoT4D/58-users-should-be-able-to-selec…
fatchat Dec 7, 2023
216e569
bump version number to 0.2.0
Dec 7, 2023
79c4290
Merge branch 'master' into feature/source_kobo_tool
Dec 12, 2023
46bb88b
check if state contains a cursor
May 30, 2024
c465a93
Merge pull request #88 from DalgoT4D/87-check-for-cursor-in-saved-con…
fatchat May 30, 2024
cc1860c
Merge branch 'master' into feature/source_kobo_tool
Aug 7, 2024
913bad7
Merge branch 'master' into feature/source_kobo_tool
Aug 16, 2024
e51017b
don't update the cursor in read_records unless the sync mode is incre…
Sep 15, 2024
69c7bb4
Merge pull request #107 from DalgoT4D/104-kobo-toolbox-connector-insi…
fatchat Sep 15, 2024
ac948e8
check for cursor in state in case state is empty
Aug 17, 2024
b7d5c13
step through tenant expenses month-wise
Aug 27, 2024
2482a95
put the demandDate into the demands
Aug 27, 2024
16de814
rolled back the attempt at fetching demands month-wise
Aug 28, 2024
cf902e2
iterate over all tenants
Sep 2, 2024
5733e0e
each stream needs to iterate over the list of tenant ids
Sep 3, 2024
99f77ef
wataer connections stream
Sep 4, 2024
bacac54
Merge branch 'master' into feature/source_kobo_tool
Sep 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!Dockerfile
!main.py
!source_kobotoolbox
!setup.py
!secrets
35 changes: 35 additions & 0 deletions airbyte-integrations/connectors/source-kobotoolbox/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM python:3.10.8-slim-bullseye as base

# build and load all requirements
FROM base as builder
WORKDIR /airbyte/integration_code

# upgrade pip to the latest version
RUN apt-get update && apt-get install -y && rm -rf /var/lib/apt/lists/* \
# apk --no-cache upgrade \
&& pip install --upgrade pip \
&& python3 -m pip install --upgrade setuptools

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

# copy payload code only
COPY main.py ./
COPY source_kobotoolbox ./source_kobotoolbox

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

LABEL io.airbyte.version=0.2.0
LABEL io.airbyte.name=tech4dev/source-kobotoolbox
129 changes: 129 additions & 0 deletions airbyte-integrations/connectors/source-kobotoolbox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Kobotoolbox Source

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

## Local development

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

#### Minimum Python version required `= 3.9.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
From the Airbyte repository root, run:
```
./gradlew :airbyte-integrations:connectors:source-kobotoolbox:build
```

#### Create credentials
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/kobotoolbox)
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_kobotoolbox/spec.yaml` file.
Note that the `secrets` directory is gitignored by default, 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 kobotoolbox 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
First, make sure you build the latest Docker image:
```
docker build . -t airbyte/source-kobotoolbox:dev
```

You can also build the connector image via Gradle:
```
./gradlew :airbyte-integrations:connectors:source-kobotoolbox:airbyteDocker
```
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.

#### Run
Then run any of the connector commands as follows:
```
docker run --rm airbyte/source-kobotoolbox:dev spec
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-kobotoolbox:dev check --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-kobotoolbox:dev discover --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-kobotoolbox: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.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
```
python -m pytest integration_tests -p integration_tests.acceptance
```
To run your integration tests with docker

### Using gradle to run tests
All commands should be run from airbyte project root.
To run unit tests:
```
./gradlew :airbyte-integrations:connectors:source-kobotoolbox:unitTest
```
To run acceptance and custom integration tests:
```
./gradlew :airbyte-integrations:connectors:source-kobotoolbox:integrationTest
```

## 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:
* required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
* required for the testing need to go to `TEST_REQUIREMENTS` list

### 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 unit and integration tests.
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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-kobotoolbox:dev
acceptance_tests:
spec:
tests:
- spec_path: "source_kobotoolbox/spec.yaml"
connection:
tests:
- config_path: "secrets/config.json"
status: "succeed"
- config_path: "integration_tests/invalid_config.json"
status: "failed"
discovery:
tests:
- config_path: "secrets/config.json"
basic_read:
tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: []
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.jsonl"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental:
tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env sh

# Build latest connector image
docker build . -t $(cat acceptance-test-config.yml | grep "connector_image" | head -n 1 | cut -d: -f2-)

# Pull latest acctest image
docker pull airbyte/connector-acceptance-test:latest

# Run
docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/tmp \
-v $(pwd):/test_input \
airbyte/connector-acceptance-test \
--acceptance-test-config /test_input

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id 'airbyte-python'
id 'airbyte-docker'
id 'airbyte-connector-acceptance-test'
}

airbytePython {
moduleDirectory 'source_kobotoolbox_singer'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Daily Issue Form": {
"endtime": "2024-01-01T00:00:00"
}
}
Loading
Loading