Skip to content

Commit 12cbe82

Browse files
authored
Source plausible: Migrate to manifest-only (#44085)
1 parent d26bc47 commit 12cbe82

File tree

12 files changed

+135
-1518
lines changed

12 files changed

+135
-1518
lines changed

airbyte-integrations/connectors/source-plausible/README.md

+26-62
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,63 @@
11
# Plausible source connector
22

3-
This is the repository for the Plausible configuration based source connector.
4-
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.com/integrations/sources/plausible).
3+
This directory contains the manifest-only connector for `source-plausible`.
4+
This _manifest-only_ connector is not a Python package on its own, as it runs inside of the base `source-declarative-manifest` image.
55

6-
## Local development
7-
8-
### Prerequisites
9-
10-
* Python (`^3.9`)
11-
* Poetry (`^1.7`) - installation instructions [here](https://python-poetry.org/docs/#installation)
12-
13-
14-
### Installing the connector
15-
16-
From this connector directory, run:
17-
```bash
18-
poetry install --with dev
19-
```
20-
21-
22-
### Create credentials
6+
For information about how to configure and use this connector within Airbyte, see [the connector's full documentation](https://docs.airbyte.com/integrations/sources/plausible).
237

24-
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/plausible)
25-
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `src/source_plausible/spec.yaml` file.
26-
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
27-
See `sample_files/sample_config.json` for a sample config file.
28-
29-
30-
### Locally running the connector
31-
32-
```
33-
poetry run source-plausible spec
34-
poetry run source-plausible check --config secrets/config.json
35-
poetry run source-plausible discover --config secrets/config.json
36-
poetry run source-plausible read --config secrets/config.json --catalog sample_files/configured_catalog.json
37-
```
38-
39-
### Running tests
8+
## Local development
409

41-
To run tests locally, from the connector directory run:
10+
We recommend using the Connector Builder to edit this connector.
11+
Using either Airbyte Cloud or your local Airbyte OSS instance, navigate to the **Builder** tab and select **Import a YAML**.
12+
Then select the connector's `manifest.yaml` file to load the connector into the Builder. You're now ready to make changes to the connector!
4213

43-
```
44-
poetry run pytest tests
45-
```
14+
If you prefer to develop locally, you can follow the instructions below.
4615

4716
### Building the docker image
4817

18+
You can build any manifest-only connector with `airbyte-ci`:
19+
4920
1. Install [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)
5021
2. Run the following command to build the docker image:
22+
5123
```bash
5224
airbyte-ci connectors --name=source-plausible build
5325
```
5426

5527
An image will be available on your host with the tag `airbyte/source-plausible:dev`.
5628

29+
### Creating credentials
30+
31+
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/plausible)
32+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `spec` object in the connector's `manifest.yaml` file.
33+
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
5734

5835
### Running as a docker container
5936

60-
Then run any of the connector commands as follows:
61-
```
37+
Then run any of the standard source connector commands:
38+
39+
```bash
6240
docker run --rm airbyte/source-plausible:dev spec
6341
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-plausible:dev check --config /secrets/config.json
6442
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-plausible:dev discover --config /secrets/config.json
6543
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-plausible:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
6644
```
6745

68-
### Running our CI test suite
46+
### Running the CI test suite
6947

7048
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
71-
```bash
72-
airbyte-ci connectors --name=source-plausible test
73-
```
74-
75-
### Customizing acceptance Tests
76-
77-
Customize `acceptance-test-config.yml` file to configure acceptance tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
78-
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.
7949

80-
### Dependency Management
81-
82-
All of your dependencies should be managed via Poetry.
83-
To add a new dependency, run:
8450
```bash
85-
poetry add <package-name>
51+
airbyte-ci connectors --name=source-plausible test
8652
```
8753

88-
Please commit the changes to `pyproject.toml` and `poetry.lock` files.
89-
9054
## Publishing a new version of the connector
91-
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
92-
1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-plausible test`
93-
2. Bump the connector version (please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors)):
55+
56+
If you want to contribute changes to `source-plausible`, here's how you can do that:
57+
1. Make your changes locally, or load the connector's manifest into Connector Builder and make changes there.
58+
2. Make sure your changes are passing our test suite with `airbyte-ci connectors --name=source-plausible test`
59+
3. Bump the connector version (please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors)):
9460
- bump the `dockerImageTag` value in in `metadata.yaml`
95-
- bump the `version` value in `pyproject.toml`
96-
3. Make sure the `metadata.yaml` content is up to date.
9761
4. Make sure the connector documentation and its changelog is up to date (`docs/integrations/sources/plausible.md`).
9862
5. Create a Pull Request: use [our PR naming conventions](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#pull-request-title-convention).
9963
6. Pat yourself on the back for being an awesome contributor.

airbyte-integrations/connectors/source-plausible/__init__.py

-3
This file was deleted.

airbyte-integrations/connectors/source-plausible/acceptance-test-config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ connector_image: airbyte/source-plausible:dev
44
acceptance_tests:
55
spec:
66
tests:
7-
- spec_path: "source_plausible/spec.yaml"
7+
- spec_path: "manifest.yaml"
88
connection:
99
tests:
1010
- config_path: "secrets/config.json"

airbyte-integrations/connectors/source-plausible/main.py

-8
This file was deleted.

airbyte-integrations/connectors/source-plausible/source_plausible/manifest.yaml airbyte-integrations/connectors/source-plausible/manifest.yaml

+103-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
version: 0.78.1
2-
1+
version: 4.3.0
32
type: DeclarativeSource
4-
53
check:
64
type: CheckStream
75
stream_names:
86
- stats
9-
107
definitions:
118
streams:
129
stats:
@@ -17,7 +14,11 @@ definitions:
1714
retriever:
1815
type: SimpleRetriever
1916
requester:
20-
$ref: "#/definitions/base_requester"
17+
type: HttpRequester
18+
url_base: "{{ config['api_url'] or 'https://plausible.io/api/v1/stats' }}"
19+
authenticator:
20+
type: BearerAuthenticator
21+
api_token: "{{ config['api_key'] }}"
2122
path: /timeseries
2223
http_method: GET
2324
request_parameters:
@@ -37,17 +38,110 @@ definitions:
3738
schema_loader:
3839
type: InlineSchemaLoader
3940
schema:
40-
$ref: "#/schemas/stats"
41+
type: object
42+
description: Timeseries data over a given time period.
43+
properties:
44+
bounce_rate:
45+
type:
46+
- integer
47+
- "null"
48+
description: Bounce rate percentage.
49+
title: Bounce Rate
50+
date:
51+
type: string
52+
description: The date, in your site's time zone, in ISO 8601 format.
53+
title: Date
54+
pageviews:
55+
type: integer
56+
description: The number of pageview events.
57+
title: Pageviews
58+
visit_duration:
59+
type:
60+
- integer
61+
- "null"
62+
description: Visit duration in seconds.
63+
title: Visit Duration
64+
visitors:
65+
type: integer
66+
description: The number of unique visitors.
67+
title: Visitors
68+
visits:
69+
type: integer
70+
description: The number of visits/sessions.
71+
title: Visits
72+
title: Stats
73+
additionalProperties: true
4174
base_requester:
4275
type: HttpRequester
4376
url_base: "{{ config['api_url'] or 'https://plausible.io/api/v1/stats' }}"
4477
authenticator:
4578
type: BearerAuthenticator
4679
api_token: "{{ config['api_key'] }}"
47-
4880
streams:
49-
- $ref: "#/definitions/streams/stats"
50-
81+
- type: DeclarativeStream
82+
name: stats
83+
primary_key:
84+
- date
85+
retriever:
86+
type: SimpleRetriever
87+
requester:
88+
type: HttpRequester
89+
url_base: "{{ config['api_url'] or 'https://plausible.io/api/v1/stats' }}"
90+
authenticator:
91+
type: BearerAuthenticator
92+
api_token: "{{ config['api_key'] }}"
93+
path: /timeseries
94+
http_method: GET
95+
request_parameters:
96+
site_id: "{{ config['site_id'] }}"
97+
period: custom
98+
metrics: visitors,pageviews,bounce_rate,visit_duration,visits
99+
date: "{{ config['start_date'] or '2019-01-01' }},{{ today_utc() }}"
100+
record_selector:
101+
type: RecordSelector
102+
extractor:
103+
type: DpathExtractor
104+
field_path:
105+
- results
106+
record_filter:
107+
type: RecordFilter
108+
condition: "{{ record['bounce_rate'] is not none }}"
109+
schema_loader:
110+
type: InlineSchemaLoader
111+
schema:
112+
type: object
113+
description: Timeseries data over a given time period.
114+
properties:
115+
bounce_rate:
116+
type:
117+
- integer
118+
- "null"
119+
description: Bounce rate percentage.
120+
title: Bounce Rate
121+
date:
122+
type: string
123+
description: The date, in your site's time zone, in ISO 8601 format.
124+
title: Date
125+
pageviews:
126+
type: integer
127+
description: The number of pageview events.
128+
title: Pageviews
129+
visit_duration:
130+
type:
131+
- integer
132+
- "null"
133+
description: Visit duration in seconds.
134+
title: Visit Duration
135+
visitors:
136+
type: integer
137+
description: The number of unique visitors.
138+
title: Visitors
139+
visits:
140+
type: integer
141+
description: The number of visits/sessions.
142+
title: Visits
143+
title: Stats
144+
additionalProperties: true
51145
spec:
52146
type: Spec
53147
connection_specification:
@@ -98,11 +192,9 @@ spec:
98192
- YYYY-MM-DD
99193
order: 3
100194
additionalProperties: true
101-
102195
metadata:
103196
autoImportSchema:
104197
stats: false
105-
106198
schemas:
107199
stats:
108200
type: object

airbyte-integrations/connectors/source-plausible/metadata.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ data:
66
enabled: false
77
remoteRegistries:
88
pypi:
9-
enabled: true
9+
enabled: false
1010
packageName: airbyte-source-plausible
1111
connectorBuildOptions:
1212
# Please update to the latest version of the connector base image.
1313
# https://hub.docker.com/r/airbyte/python-connector-base
1414
# Please use the full address with sha256 hash to guarantee build reproducibility.
15-
baseImage: docker.io/airbyte/python-connector-base:2.0.0@sha256:c44839ba84406116e8ba68722a0f30e8f6e7056c726f447681bb9e9ece8bd916
15+
baseImage: docker.io/airbyte/source-declarative-manifest:4.4.1@sha256:a8c0f0d32782957beef2c65bac98756b04fff2f3ffc4568a6676d3c83a422a5b
1616
connectorSubtype: api
1717
connectorType: source
1818
definitionId: 603ba446-3d75-41d7-92f3-aba901f8b897
19-
dockerImageTag: 0.1.14
19+
dockerImageTag: 0.2.0
2020
dockerRepository: airbyte/source-plausible
2121
githubIssueLabel: source-plausible
2222
icon: plausible.svg
@@ -27,8 +27,8 @@ data:
2727
supportLevel: community
2828
documentationUrl: https://docs.airbyte.com/integrations/sources/plausible
2929
tags:
30-
- language:python
3130
- cdk:low-code
31+
- language:manifest-only
3232
ab_internal:
3333
sl: 100
3434
ql: 100

0 commit comments

Comments
 (0)