Skip to content

Commit c8a00ea

Browse files
andnigmarcosmarxmoctavia-squidington-iii
authored
🎉 New Source: Senseforce (#18775)
* feat: initial commit source senseforce This commit is the initial commit to the senseforce.io source. It contains the auto-generated lowcode CDK source connector files as well as the spec definition of the connector. Not working yet. * feat: stream slicing and incremental sync [pass] This commit adds the stream slicing and incremental sync feature. This commit passes all configured acceptance tests. * docs: Update documentation * change: remove unused schema readme * change: remove catalog.json from integration_tests * add senseforce to source def * run format * correct tests * auto-bump connector version Co-authored-by: marcosmarxm <[email protected]> Co-authored-by: Octavia Squidington III <[email protected]>
1 parent 58e4ef6 commit c8a00ea

File tree

25 files changed

+646
-0
lines changed

25 files changed

+646
-0
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
@@ -1214,6 +1214,13 @@
12141214
icon: sendgrid.svg
12151215
sourceType: api
12161216
releaseStage: beta
1217+
- name: Senseforce
1218+
sourceDefinitionId: 39de93cb-1511-473e-a673-5cbedb9436af
1219+
dockerRepository: airbyte/source-senseforce
1220+
dockerImageTag: 0.1.0
1221+
documentationUrl: https://docs.airbyte.com/integrations/sources/senseforce
1222+
sourceType: api
1223+
releaseStage: alpha
12171224
- name: Shopify
12181225
sourceDefinitionId: 9da77001-af33-4bcd-be46-6252bf9342b9
12191226
dockerRepository: airbyte/source-shopify

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11684,6 +11684,82 @@
1168411684
supportsNormalization: false
1168511685
supportsDBT: false
1168611686
supported_destination_sync_modes: []
11687+
- dockerImage: "airbyte/source-senseforce:0.1.0"
11688+
spec:
11689+
documentationUrl: "https://docs.airbyte.io/integrations/sources/senseforce"
11690+
connectionSpecification:
11691+
$schema: "http://json-schema.org/draft-07/schema#"
11692+
title: "Senseforce Source Spec"
11693+
type: "object"
11694+
required:
11695+
- "access_token"
11696+
- "backend_url"
11697+
- "dataset_id"
11698+
- "start_date"
11699+
additionalProperties: true
11700+
properties:
11701+
access_token:
11702+
type: "string"
11703+
title: "API Access Token"
11704+
description: "Your API access token. See <a href=\"https://manual.senseforce.io/manual/sf-platform/public-api/get-your-access-token/\"\
11705+
>here</a>. The toke is case sensitive."
11706+
airbyte_secret: true
11707+
backend_url:
11708+
type: "string"
11709+
title: "Senseforce backend URL"
11710+
examples:
11711+
- "https://galaxyapi.senseforce.io"
11712+
description: "Your Senseforce API backend URL. This is the URL shown during\
11713+
\ the Login screen. See <a href=\"https://manual.senseforce.io/manual/sf-platform/public-api/get-your-access-token/\"\
11714+
>here</a> for more details. (Note: Most Senseforce backend APIs have the\
11715+
\ term 'galaxy' in their ULR)"
11716+
dataset_id:
11717+
type: "string"
11718+
title: "Dataset ID"
11719+
examples:
11720+
- "8f418098-ca28-4df5-9498-0df9fe78eda7"
11721+
description: "The ID of the dataset you want to synchronize. The ID can\
11722+
\ be found in the URL when opening the dataset. See <a href=\"https://manual.senseforce.io/manual/sf-platform/public-api/get-your-access-token/\"\
11723+
>here</a> for more details. (Note: As the Senseforce API only allows to\
11724+
\ synchronize a specific dataset, each dataset you want to synchronize\
11725+
\ needs to be implemented as a separate airbyte source)."
11726+
start_date:
11727+
type: "string"
11728+
title: "The first day (in UTC) when to read data from."
11729+
pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
11730+
description: "UTC date and time in the format 2017-01-25. Only data with\
11731+
\ \"Timestamp\" after this date will be replicated. Important note: This\
11732+
\ start date must be set to the first day of where your dataset provides\
11733+
\ data. If your dataset has data from 2020-10-10 10:21:10, set the start_date\
11734+
\ to 2020-10-10 or later"
11735+
examples:
11736+
- "2017-01-25"
11737+
slice_range:
11738+
type: "integer"
11739+
title: "Data request time increment in days"
11740+
default: 10
11741+
minimum: 1
11742+
maximum: 365
11743+
examples:
11744+
- 1
11745+
- 3
11746+
- 10
11747+
- 30
11748+
- 180
11749+
- 360
11750+
airbyte_hidden: true
11751+
description: "The time increment used by the connector when requesting data\
11752+
\ from the Senseforce API. The bigger the value is, the less requests\
11753+
\ will be made and faster the sync will be. On the other hand, the more\
11754+
\ seldom the state is persisted and the more likely one could run into\
11755+
\ rate limites. Furthermore, consider that large chunks of time might\
11756+
\ take a long time for the Senseforce query to return data - meaning it\
11757+
\ could take in effect longer than with more smaller time slices. If there\
11758+
\ are a lot of data per day, set this setting to 1. If there is only very\
11759+
\ little data per day, you might change the setting to 10 or more."
11760+
supportsNormalization: false
11761+
supportsDBT: false
11762+
supported_destination_sync_modes: []
1168711763
- dockerImage: "airbyte/source-shopify:0.2.0"
1168811764
spec:
1168911765
documentationUrl: "https://docs.airbyte.com/integrations/sources/shopify"
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_senseforce
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_senseforce ./source_senseforce
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-senseforce
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Senseforce Source
2+
3+
This is the repository for the Senseforce configuration based source connector.
4+
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/senseforce).
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-senseforce: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/senseforce)
18+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_senseforce/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 senseforce 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-senseforce:dev
31+
```
32+
33+
You can also build the connector image via Gradle:
34+
```
35+
./gradlew :airbyte-integrations:connectors:source-senseforce: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-senseforce:dev spec
44+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-senseforce:dev check --config /secrets/config.json
45+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-senseforce:dev discover --config /secrets/config.json
46+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-senseforce: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-senseforce:unitTest
61+
```
62+
To run acceptance and custom integration tests:
63+
```
64+
./gradlew :airbyte-integrations:connectors:source-senseforce: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+
#
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# See [Source Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/source-acceptance-tests-reference)
2+
# for more information about how to configure these tests
3+
connector_image: airbyte/source-senseforce:dev
4+
acceptance_tests:
5+
spec:
6+
tests:
7+
- spec_path: "source_senseforce/spec.yaml"
8+
connection:
9+
tests:
10+
- config_path: "secrets/config.json"
11+
status: "succeed"
12+
- config_path: "integration_tests/invalid_config.json"
13+
status: "failed"
14+
discovery:
15+
tests:
16+
- config_path: "secrets/config.json"
17+
basic_read:
18+
tests:
19+
- config_path: "secrets/config.json"
20+
configured_catalog_path: "integration_tests/configured_catalog.json"
21+
empty_streams: []
22+
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
23+
# expect_records:
24+
# path: "integration_tests/expected_records.txt"
25+
# extra_fields: no
26+
# exact_order: no
27+
# extra_records: yes
28+
incremental:
29+
tests:
30+
- config_path: "secrets/config.json"
31+
configured_catalog_path: "integration_tests/configured_catalog.json"
32+
full_refresh:
33+
tests:
34+
- config_path: "secrets/config.json"
35+
configured_catalog_path: "integration_tests/configured_catalog.json"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env sh
2+
3+
# Build latest connector image
4+
docker build . -t $(cat acceptance-test-config.yml | grep "connector_image" | head -n 1 | cut -d: -f2-)
5+
6+
# Pull latest acctest image
7+
docker pull airbyte/source-acceptance-test:latest
8+
9+
# Run
10+
docker run --rm -it \
11+
-v /var/run/docker.sock:/var/run/docker.sock \
12+
-v /tmp:/tmp \
13+
-v $(pwd):/test_input \
14+
airbyte/source-acceptance-test \
15+
--acceptance-test-config /test_input
16+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
id 'airbyte-python'
3+
id 'airbyte-docker'
4+
id 'airbyte-source-acceptance-test'
5+
}
6+
7+
airbytePython {
8+
moduleDirectory 'source_senseforce'
9+
}
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+
#
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dataset": {
3+
"airbyte_cursor": "5595570341.224"
4+
}
5+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
3+
#
4+
5+
6+
import pytest
7+
8+
pytest_plugins = ("source_acceptance_test.plugin",)
9+
10+
11+
@pytest.fixture(scope="session", autouse=True)
12+
def connector_setup():
13+
"""This fixture is a placeholder for external resources that acceptance test might require."""
14+
yield
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"streams": [
3+
{
4+
"stream": {
5+
"name": "dataset",
6+
"json_schema": {},
7+
"supported_defined_cursor": true,
8+
"supported_sync_modes": ["full_refresh", "incremental"]
9+
},
10+
"sync_mode": "incremental",
11+
"destination_sync_mode": "append",
12+
"cursor_field": ["airbyte_cursor"]
13+
}
14+
]
15+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"access_token": "somekey",
3+
"backend_url": "https://galaxyapi.senseforce.io",
4+
"dataset_id": "8f418098-ca28-4df5-9498-0df9fe78eda7",
5+
"start_date": "2020-07-22",
6+
"slice_range": 1
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"access_token": "somekey",
3+
"backend_url": "https://galaxyapi.senseforce.io",
4+
"dataset_id": "8f418098-ca28-4df5-9498-0df9fe78eda7",
5+
"start_date": "2020-07-22",
6+
"slice_range": 1
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dataset": {
3+
"airbyte_cursor": "1595570341.224"
4+
}
5+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
3+
#
4+
5+
6+
import sys
7+
8+
from airbyte_cdk.entrypoint import launch
9+
from source_senseforce import SourceSenseforce
10+
11+
if __name__ == "__main__":
12+
source = SourceSenseforce()
13+
launch(source, sys.argv[1:])
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-e ../../bases/source-acceptance-test
2+
-e .

0 commit comments

Comments
 (0)