Skip to content

🎉 New Source: RKI (Robert Koch-Institut) Covid Public API #11732

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

Merged
merged 46 commits into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c8b42e0
Added source for RKI-covid-germany, updated spec.json, implemented so…
Zawar92 Mar 7, 2022
2c93e79
implemented incremental method for germany history cases with date as…
Zawar92 Mar 10, 2022
55e513f
main file added.
Zawar92 Mar 10, 2022
5041be2
added Incidence source with date as parameter. Incremental stream. sp…
Zawar92 Mar 13, 2022
ae21820
Added a full-refresh stream for germany/age-group .Added incremental …
Zawar92 Mar 14, 2022
d40604a
writting test unit test cases for incremental streams: german history…
Zawar92 Mar 21, 2022
c383fb7
Incremental streams for germanhistorydeaths, germanhistoryfrozenIncid…
Zawar92 Mar 21, 2022
b2f8fee
Added test stream for age group and germany.
Zawar92 Mar 23, 2022
51cc121
changes in Readme and source.py.
Zawar92 Mar 25, 2022
d829806
IncrementalMixin added to class GermanyHistoryCases. AFter review Inc…
Zawar92 Mar 28, 2022
7836aa0
Implemented Incremental mixin or GermanHistory Cases connector.
Zawar92 Apr 4, 2022
6299be9
corrected changes.
Zawar92 Apr 4, 2022
bfe7929
updated with master.
Zawar92 Apr 4, 2022
33f710b
adding integration test
Zawar92 Apr 4, 2022
99bcadb
fetch stream master
Zawar92 Apr 4, 2022
62e7df9
comment acceptence test.
Zawar92 Apr 5, 2022
1bd5a35
On path with master
Zawar92 Apr 5, 2022
b5391db
On path with master
Zawar92 Apr 5, 2022
3eaa129
updated the changes for PR request.
Zawar92 Apr 8, 2022
4f97496
updated with master.
Zawar92 Apr 8, 2022
c37d843
changed file source-rki-covid/integration_tests/configured_catalog.json
Zawar92 Apr 20, 2022
9ac1905
fetched upstream master before working.
Zawar92 Apr 27, 2022
1f259a8
corrected flake and blackformatting. Build gradel.
Zawar92 Apr 27, 2022
286e565
Worked on the suggestions.
Zawar92 Apr 28, 2022
3daf8dd
source_rki_covid/schemas/germany_age_groups.json
Zawar92 May 9, 2022
904e383
uodated abnormal_state.json
Zawar92 May 9, 2022
6ed6437
updated with master
Zawar92 May 10, 2022
dccea84
updated the schemas for german age groups and history hospitalization.
Zawar92 May 17, 2022
0082242
Merge branch 'zawar92/add_source_rki_covid' of github.com:Zawar92/air…
marcosmarxm May 18, 2022
0a2cb9a
Merge branch 'master' into marcos/test-pr-11732
marcosmarxm May 26, 2022
e351987
correct dockerfile and update airbyte_cdk version
marcosmarxm May 26, 2022
562906e
run format
marcosmarxm May 26, 2022
83827e6
update python version
marcosmarxm May 26, 2022
8c44676
correct dockerfile build
marcosmarxm May 26, 2022
bf78600
merge master
marcosmarxm May 26, 2022
5c7f8d4
add source in seed
marcosmarxm May 26, 2022
9ea2a53
update uuid for rki-covid source
marcosmarxm May 26, 2022
fdc266f
Merge branch 'master' into marcos/test-pr-11732
marcosmarxm May 27, 2022
f3b23ab
change docker
marcosmarxm May 27, 2022
857dc42
add bash
marcosmarxm May 27, 2022
6b3c29a
Merge branch 'master' into marcos/test-pr-11732
marcosmarxm May 27, 2022
5e36611
auto-bump connector version
octavia-squidington-iii May 27, 2022
75e5c33
run seed file
marcosmarxm May 27, 2022
8f0a47f
Merge branch 'zawar92/add_source_rki_covid' of github.com:Zawar92/air…
marcosmarxm May 27, 2022
ef8f98a
correct doc
marcosmarxm May 30, 2022
da459e4
auto-bump connector version
octavia-squidington-iii May 30, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,13 @@
icon: retently.svg
sourceType: api
releaseStage: alpha
- name: RKI Covid
sourceDefinitionId: d78e5de0-aa44-4744-aa4f-74c818ccfe19
dockerRepository: airbyte/source-rki-covid
dockerImageTag: 0.1.1
documentationUrl: https://docs.airbyte.io/integrations/sources/rki-covid
sourceType: api
releaseStage: alpha
- name: S3
sourceDefinitionId: 69589781-7828-43c5-9f63-8925b1c1ccc2
dockerRepository: airbyte/source-s3
Expand Down
20 changes: 20 additions & 0 deletions airbyte-config/init/src/main/resources/seed/source_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7148,6 +7148,26 @@
path_in_connector_config:
- "credentials"
- "client_secret"
- dockerImage: "airbyte/source-rki-covid:0.1.1"
spec:
documentationUrl: "https://docs.airbyte.com/integrations/sources/rki-covid"
connectionSpecification:
$schema: "http://json-schema.org/draft-07/schema#"
title: "RKI Covid Spec"
type: "object"
required:
- "start_date"
additionalProperties: false
properties:
start_date:
type: "string"
title: "Start Date"
description: "UTC date in the format 2017-01-25. Any data before this date\
\ will not be replicated."
order: 1
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-s3:0.1.14"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/sources/s3"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!Dockerfile
!main.py
!source_rki_covid
!setup.py
!secrets
34 changes: 34 additions & 0 deletions airbyte-integrations/connectors/source-rki-covid/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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 ./
# 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_rki_covid ./source_rki_covid

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

LABEL io.airbyte.version=0.1.1
LABEL io.airbyte.name=airbyte/source-rki-covid
144 changes: 144 additions & 0 deletions airbyte-integrations/connectors/source-rki-covid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# RKI Covid Source

This is the repository for the RkI (Robert Koch-Institut - von Marlon Lückert) Covid-19 source connector, written in Python.
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/rki-covid).

## Local development
### Developed Streams (Endpoints)
```
Germany:
1. /germany
2. /germany/age-groups
3. /germany/history/cases/:days
4. /germany/history/incidence/:days
5. /germany/history/deaths/:days
6. /germany/history/recovered/:days
7. /germany/history/frozen-incidence/:days
8. /germany/history/hospitalization/:days
```

### 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
pip install '.[tests]'
```
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.

To build using Gradle, from the Airbyte repository root, run:
```
./gradlew :airbyte-integrations:connectors:source-rki-covid:build
```

#### Create credentials
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/rki-covid)
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_rki_covid/spec.json` 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 rki-covid 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-rki-covid:dev
```

You can also build the connector image via Gradle:
```
./gradlew :airbyte-integrations:connectors:source-rki-covid: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-rki-covid:dev spec
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-rki-covid:dev check --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-rki-covid:dev discover --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-rki-covid: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 [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-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-rki-covid:unitTest
```
To run acceptance and custom integration tests:
```
./gradlew :airbyte-integrations:connectors:source-rki-covid: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,28 @@
# See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference)
# for more information about how to configure these tests
connector_image: airbyte/source-rki-covid:dev
tests:
spec:
- spec_path: "source_rki_covid/spec.json"
connection:
- config_path: "secrets/config.json"
status: "succeed"
discovery:
- config_path: "secrets/config.json"
basic_read:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
empty_streams: [ "germany", "germany_age_groups", "german_history_frozen_incidence"]
# 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.txt"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental: # TODO
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
future_state_path: "integration_tests/abnormal_state.json"
full_refresh:
- 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/source-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/source-acceptance-test \
--acceptance-test-config /test_input

21 changes: 21 additions & 0 deletions airbyte-integrations/connectors/source-rki-covid/bootstrap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The (Robert Koch-Institut - von Marlon Lückert) Covid-19 is [a REST based API](https://api.corona-zahlen.org/).
Connector is implemented with [Airbyte CDK](https://docs.airbyte.io/connector-development/cdk-python).

## Cases In Germany Covid api stream
The basic entry stream is 'germany'. All other streams are extended version of base stream and passing parameters also result in sliced data.
For production, every developer application can view multiple streams.

## Endpoints
* [Provides covid cases and other information in Germany.](https://api.corona-zahlen.org/germany) \(Non-Incremental\ Entry-Stream)
* [Provides covid cases and other information in Germany, group by age.](https://api.corona-zahlen.org/germany/age-groups) \(Non-Incremental\)
* [Provides cases in Germany based on days.](https://api.corona-zahlen.org/germany/germany/history/cases/:days) \(Incremental\)
* [Provides incidence rate of covid in Germany based on days.](https://api.corona-zahlen.org/germany/germany/history/incidence/:days) \(Incremental\)
* [Provides death rate in Germany over days](https://api.corona-zahlen.org/germany/germany/history/deaths/:days) \(Incremental\)
* [Provides recovery rate in Germany over days.](https://api.corona-zahlen.org/germany/germany/history/recovered/:days) \(Incremental\)
* [Provides frozen incidence in Germany over days.](https://api.corona-zahlen.org/germany/germany/history/frozen-incidence/:days) \(Incremental\)
* [Provides hospitalization rate in Germany over days.](https://api.corona-zahlen.org/germany/germany/history/hospitalization/:days) \(Incremental\)



Incremental streams have required parameter start-date. Without passing start-date as parameter full-refresh occurs.
As cursor field this connector uses "date".
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins {
id 'airbyte-python'
id 'airbyte-docker'
id 'airbyte-source-acceptance-test'
}

airbytePython {
moduleDirectory 'source_rki_covid'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"germany_history_cases": {
"date": "2024-04-06T00:00:00.000Z"
},
"german_history_incidence": {
"date": "2024-04-06T00:00:00.000Z"
},
"german_history_deaths": {
"date": "2024-04-06T00:00:00.000Z"
},
"german_history_recovered": {
"date": "2024-04-06T00:00:00.000Z"
},
"german_history_hospitalization": {
"date": "2024-04-07T00:00:00.000Z"
},
"german_history_frozen_incidence": {
"date": "2024-01-01T00:00:00.000Z"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#


import pytest

pytest_plugins = ("source_acceptance_test.plugin",)


@pytest.fixture(scope="session", autouse=True)
def connector_setup():
"""This fixture is a placeholder for external resources that acceptance test might require."""
yield
Loading