airbyte-source-commcare 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.1
2
+ Name: airbyte-source-commcare
3
+ Version: 0.1.2
4
+ Summary: Source implementation for Commcare.
5
+ Home-page: https://airbyte.com
6
+ License: MIT
7
+ Author: Airbyte
8
+ Author-email: contact@airbyte.io
9
+ Requires-Python: >=3.9,<3.12
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Requires-Dist: airbyte-cdk (==0.80.0)
16
+ Requires-Dist: bigquery-schema-generator (==1.5.1)
17
+ Requires-Dist: flatten-json (==0.1.13)
18
+ Requires-Dist: gbqschema-converter (==1.2.1)
19
+ Project-URL: Documentation, https://docs.airbyte.com/integrations/sources/commcare
20
+ Project-URL: Repository, https://github.com/airbytehq/airbyte
21
+ Description-Content-Type: text/markdown
22
+
23
+ # Commcare source connector
24
+
25
+
26
+ This is the repository for the Commcare source connector, written in Python.
27
+ For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.com/integrations/sources/commcare).
28
+
29
+ ## Local development
30
+
31
+ ### Prerequisites
32
+ * Python (~=3.9)
33
+ * Poetry (~=1.7) - installation instructions [here](https://python-poetry.org/docs/#installation)
34
+
35
+
36
+ ### Installing the connector
37
+ From this connector directory, run:
38
+ ```bash
39
+ poetry install --with dev
40
+ ```
41
+
42
+
43
+ ### Create credentials
44
+ **If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/commcare)
45
+ to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_commcare/spec.yaml` file.
46
+ Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
47
+ See `sample_files/sample_config.json` for a sample config file.
48
+
49
+
50
+ ### Locally running the connector
51
+ ```
52
+ poetry run source-commcare spec
53
+ poetry run source-commcare check --config secrets/config.json
54
+ poetry run source-commcare discover --config secrets/config.json
55
+ poetry run source-commcare read --config secrets/config.json --catalog sample_files/configured_catalog.json
56
+ ```
57
+
58
+ ### Running unit tests
59
+ To run unit tests locally, from the connector directory run:
60
+ ```
61
+ poetry run pytest unit_tests
62
+ ```
63
+
64
+ ### Building the docker image
65
+ 1. Install [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)
66
+ 2. Run the following command to build the docker image:
67
+ ```bash
68
+ airbyte-ci connectors --name=source-commcare build
69
+ ```
70
+
71
+ An image will be available on your host with the tag `airbyte/source-commcare:dev`.
72
+
73
+
74
+ ### Running as a docker container
75
+ Then run any of the connector commands as follows:
76
+ ```
77
+ docker run --rm airbyte/source-commcare:dev spec
78
+ docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-commcare:dev check --config /secrets/config.json
79
+ docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-commcare:dev discover --config /secrets/config.json
80
+ docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-commcare:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
81
+ ```
82
+
83
+ ### Running our CI test suite
84
+ You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
85
+ ```bash
86
+ airbyte-ci connectors --name=source-commcare test
87
+ ```
88
+
89
+ ### Customizing acceptance Tests
90
+ 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.
91
+ 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.
92
+
93
+ ### Dependency Management
94
+ All of your dependencies should be managed via Poetry.
95
+ To add a new dependency, run:
96
+ ```bash
97
+ poetry add <package-name>
98
+ ```
99
+
100
+ Please commit the changes to `pyproject.toml` and `poetry.lock` files.
101
+
102
+ ## Publishing a new version of the connector
103
+ You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
104
+ 1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-commcare test`
105
+ 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)):
106
+ - bump the `dockerImageTag` value in in `metadata.yaml`
107
+ - bump the `version` value in `pyproject.toml`
108
+ 3. Make sure the `metadata.yaml` content is up to date.
109
+ 4. Make sure the connector documentation and its changelog is up to date (`docs/integrations/sources/commcare.md`).
110
+ 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).
111
+ 6. Pat yourself on the back for being an awesome contributor.
112
+ 7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
113
+ 8. Once your PR is merged, the new version of the connector will be automatically published to Docker Hub and our connector registry.
@@ -0,0 +1,9 @@
1
+ source_commcare/__init__.py,sha256=e2gcZC5sfkJ_uidHqoPCVmqUdL9mhpMrw4Ix4uIzSng,128
2
+ source_commcare/run.py,sha256=aZZ10q2rM_fY8lmNk4Gmb_pOhDJvv-biHN6V-ut5Y6I,236
3
+ source_commcare/schemas/TODO.md,sha256=buGbe_7mhRgtXK4cy-WI8y4HUKWnOYA6OPZCcFQJ2CI,1650
4
+ source_commcare/source.py,sha256=X_4bNim1LBDCVjqnhWViaFgsjPvMTXkZZ1yNRGRf1Aw,12956
5
+ source_commcare/spec.yaml,sha256=CMpevuCDKMFZmq16CdeilpvXKbCiQPjmI1fcgzvJQuQ,1019
6
+ airbyte_source_commcare-0.1.2.dist-info/METADATA,sha256=gj95ccLSMkTzBKazgR0t5Jhla1eobyINkmM-Wil7GYk,5377
7
+ airbyte_source_commcare-0.1.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
8
+ airbyte_source_commcare-0.1.2.dist-info/entry_points.txt,sha256=VN7tZop8Ykxus1n-_6w4MVOlQ_uY0lQRF9w1ghGuJk0,59
9
+ airbyte_source_commcare-0.1.2.dist-info/RECORD,,
@@ -1,5 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: poetry-core 1.9.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
-
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ source-commcare=source_commcare.run:run
3
+
@@ -0,0 +1,30 @@
1
+ # TODO: Define your stream schemas
2
+
3
+ Your connector must describe the schema of each stream it can output using [JSONSchema](https://json-schema.org).
4
+
5
+ The simplest way to do this is to describe the schema of your streams using one `.json` file per stream. You can also dynamically generate the schema of your stream in code, or you can combine both approaches: start with a `.json` file and dynamically add properties to it.
6
+
7
+ The schema of a stream is the return value of `Stream.get_json_schema`.
8
+
9
+ ## Static schemas
10
+
11
+ By default, `Stream.get_json_schema` reads a `.json` file in the `schemas/` directory whose name is equal to the value of the `Stream.name` property. In turn `Stream.name` by default returns the name of the class in snake case. Therefore, if you have a class `class EmployeeBenefits(HttpStream)` the default behavior will look for a file called `schemas/employee_benefits.json`. You can override any of these behaviors as you need.
12
+
13
+ Important note: any objects referenced via `$ref` should be placed in the `shared/` directory in their own `.json` files.
14
+
15
+ ## Dynamic schemas
16
+
17
+ If you'd rather define your schema in code, override `Stream.get_json_schema` in your stream class to return a `dict` describing the schema using [JSONSchema](https://json-schema.org).
18
+
19
+ ## Dynamically modifying static schemas
20
+
21
+ Override `Stream.get_json_schema` to run the default behavior, edit the returned value, then return the edited value:
22
+
23
+ ```
24
+ def get_json_schema(self):
25
+ schema = super().get_json_schema()
26
+ schema['dynamically_determined_property'] = "property"
27
+ return schema
28
+ ```
29
+
30
+ Delete this file once you're done. Or don't. Up to you :)
@@ -1,102 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: airbyte-source-commcare
3
- Version: 0.1.0
4
- Summary: Source implementation for Commcare.
5
- Author: Airbyte
6
- Author-email: contact@airbyte.io
7
- Description-Content-Type: text/markdown
8
- Requires-Dist: airbyte-cdk
9
- Requires-Dist: bigquery-schema-generator ~=1.5
10
- Requires-Dist: gbqschema-converter ~=1.2.0
11
- Requires-Dist: flatten-json ~=0.1.13
12
- Provides-Extra: tests
13
- Requires-Dist: requests-mock ~=1.9.3 ; extra == 'tests'
14
- Requires-Dist: pytest ~=6.1 ; extra == 'tests'
15
- Requires-Dist: pytest-mock ~=3.6.1 ; extra == 'tests'
16
-
17
- # Commcare Source
18
-
19
- This is the repository for the Commcare source connector, written in Python.
20
- For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/commcare).
21
-
22
-
23
- **To iterate on this connector, make sure to complete this prerequisites section.**
24
-
25
-
26
- From this connector directory, create a virtual environment:
27
- ```
28
- python -m venv .venv
29
- ```
30
-
31
- This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
32
- development environment of choice. To activate it from the terminal, run:
33
- ```
34
- source .venv/bin/activate
35
- pip install -r requirements.txt
36
- pip install '.[tests]'
37
- ```
38
- If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
39
-
40
- Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
41
- used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
42
- 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
43
- should work as you expect.
44
-
45
- **If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/commcare)
46
- to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_commcare/spec.yaml` file.
47
- Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
48
- See `integration_tests/sample_config.json` for a sample config file.
49
-
50
- **If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source commcare test creds`
51
- and place them into `secrets/config.json`.
52
-
53
- ```
54
- python main.py spec
55
- python main.py check --config secrets/config.json
56
- python main.py discover --config secrets/config.json
57
- python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json
58
- ```
59
-
60
-
61
-
62
- **Via [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md) (recommended):**
63
- ```bash
64
- airbyte-ci connectors --name=source-commcare build
65
- ```
66
-
67
- An image will be built with the tag `airbyte/source-commcare:dev`.
68
-
69
- **Via `docker build`:**
70
- ```bash
71
- docker build -t airbyte/source-commcare:dev .
72
- ```
73
-
74
- Then run any of the connector commands as follows:
75
- ```
76
- docker run --rm airbyte/source-commcare:dev spec
77
- docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-commcare:dev check --config /secrets/config.json
78
- docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-commcare:dev discover --config /secrets/config.json
79
- docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-commcare:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json
80
- ```
81
-
82
- You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
83
- ```bash
84
- airbyte-ci connectors --name=source-commcare test
85
- ```
86
-
87
- 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.
88
- 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.
89
-
90
- 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.
91
- We split dependencies between two groups, dependencies that are:
92
- * required for your connector to work need to go to `MAIN_REQUIREMENTS` list.
93
- * required for the testing need to go to `TEST_REQUIREMENTS` list
94
-
95
- You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
96
- 1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-commcare test`
97
- 2. Bump the connector version in `metadata.yaml`: increment the `dockerImageTag` value. Please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors).
98
- 3. Make sure the `metadata.yaml` content is up to date.
99
- 4. Make the connector documentation and its changelog is up to date (`docs/integrations/sources/commcare.md`).
100
- 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).
101
- 6. Pat yourself on the back for being an awesome contributor.
102
- 7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
@@ -1,19 +0,0 @@
1
- integration_tests/__init__.py,sha256=4Hw-PX1-VgESLF16cDdvuYCzGJtHntThLF4qIiULWeo,61
2
- integration_tests/abnormal_state.json,sha256=-DJMcBhq1do1ntOZXzsaGmxvbDTmYmFS0cSSaUoRLZ4,86
3
- integration_tests/acceptance.py,sha256=8eU9iSDbmHyufPvAouJGhPMgPAFTCP8IKIKHLm7u5TE,435
4
- integration_tests/catalog.json,sha256=yj0WO6sFU4GCciYUBWjzvvfqrBh869doeOC2Pp5EI1Y,3
5
- integration_tests/configured_catalog.json,sha256=1tbuuekIkjKW6NKdwW9ulYAYNjErYgAJqDsq08etQLE,397
6
- integration_tests/invalid_config.json,sha256=kXy1C-2u6aW122jeDBlv1taNZDYjzdjRyer_2B1xgk8,142
7
- integration_tests/sample_config.json,sha256=Lh9_zss5lxbqGFYpZnvi8qo5eIMNcuQ6GBDKbw1dVhM,115
8
- integration_tests/sample_state.json,sha256=HBR6G9QPoPDFAlfAKwRmeNaQ5_56xehMLtwWr4mxd5k,63
9
- source_commcare/__init__.py,sha256=e2gcZC5sfkJ_uidHqoPCVmqUdL9mhpMrw4Ix4uIzSng,128
10
- source_commcare/run.py,sha256=aZZ10q2rM_fY8lmNk4Gmb_pOhDJvv-biHN6V-ut5Y6I,236
11
- source_commcare/source.py,sha256=X_4bNim1LBDCVjqnhWViaFgsjPvMTXkZZ1yNRGRf1Aw,12956
12
- source_commcare/spec.yaml,sha256=CMpevuCDKMFZmq16CdeilpvXKbCiQPjmI1fcgzvJQuQ,1019
13
- unit_tests/__init__.py,sha256=4Hw-PX1-VgESLF16cDdvuYCzGJtHntThLF4qIiULWeo,61
14
- unit_tests/test_source.py,sha256=qneLJGlvcpoyFlnvwzwP2voDtzi8z6c_N-lu0won5wM,682
15
- airbyte_source_commcare-0.1.0.dist-info/METADATA,sha256=-GDqr4YKVK8LGyoTB9nmPitvdARyMlTt9LOzmE5dJUc,5536
16
- airbyte_source_commcare-0.1.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
17
- airbyte_source_commcare-0.1.0.dist-info/entry_points.txt,sha256=zVJihl1jgNaayMgxgA1G9KN85LZ9T8bbss4VfqE78Bg,60
18
- airbyte_source_commcare-0.1.0.dist-info/top_level.txt,sha256=WCua9CoU5uJ26Af2zVYpamondw5woLFReykWLPCjX7s,45
19
- airbyte_source_commcare-0.1.0.dist-info/RECORD,,
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- source-commcare = source_commcare.run:run
@@ -1,3 +0,0 @@
1
- integration_tests
2
- source_commcare
3
- unit_tests
@@ -1,3 +0,0 @@
1
- #
2
- # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3
- #
@@ -1,5 +0,0 @@
1
- {
2
- "Assess a referred patient": {
3
- "indexed_on": "2023-11-25T20:30:30.2423"
4
- }
5
- }
@@ -1,16 +0,0 @@
1
- #
2
- # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3
- #
4
-
5
-
6
- import pytest
7
-
8
- pytest_plugins = ("connector_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
- # TODO: setup test dependencies if needed. otherwise remove the TODO comments
15
- yield
16
- # TODO: clean up test dependencies
@@ -1 +0,0 @@
1
- {}
@@ -1,16 +0,0 @@
1
- {
2
- "streams": [
3
- {
4
- "stream": {
5
- "name": "Assess a referred patient",
6
- "json_schema": {},
7
- "supported_sync_modes": ["full_refresh", "incremental"],
8
- "source_defined_cursor": true,
9
- "default_cursor_field": ["indexed_on"]
10
- },
11
- "sync_mode": "incremental",
12
- "cursor_field": ["indexed_on"],
13
- "destination_sync_mode": "append"
14
- }
15
- ]
16
- }
@@ -1,6 +0,0 @@
1
- {
2
- "app_id": "wrong app_id",
3
- "api_key": "wrong api key",
4
- "start_date": "This has the wrong format",
5
- "project_space": "project_space"
6
- }
@@ -1,6 +0,0 @@
1
- {
2
- "app_id": "App ID",
3
- "api_key": "API KEY",
4
- "project_space": "project_space",
5
- "start_date": "Start Date"
6
- }
@@ -1,5 +0,0 @@
1
- {
2
- "todo-stream-name": {
3
- "todo-field-name": "value"
4
- }
5
- }
unit_tests/__init__.py DELETED
@@ -1,3 +0,0 @@
1
- #
2
- # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3
- #
unit_tests/test_source.py DELETED
@@ -1,25 +0,0 @@
1
- #
2
- # Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3
- #
4
-
5
- from unittest.mock import MagicMock, Mock
6
-
7
- import pytest
8
- from source_commcare.source import SourceCommcare
9
-
10
-
11
- @pytest.fixture(name="config")
12
- def config_fixture():
13
- return {"api_key": "apikey", "app_id": "appid", "start_date": "2022-01-01T00:00:00Z"}
14
-
15
-
16
- def test_check_connection_ok(mocker, config):
17
- source = SourceCommcare()
18
- logger_mock = Mock()
19
- assert source.check_connection(logger_mock, config=config) == (True, None)
20
-
21
-
22
- def test_check_connection_fail(mocker, config):
23
- source = SourceCommcare()
24
- logger_mock = MagicMock()
25
- assert source.check_connection(logger_mock, config={}) == (False, None)