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

🎉 Source Iterable: add new streams #5915

Merged
merged 14 commits into from
Oct 4, 2021
Merged

Conversation

gaart
Copy link
Contributor

@gaart gaart commented Sep 8, 2021

What

New streams added: Campaign Metrics, Events

How

  1. The standard Tests removed, Source Acceptance Tests added.
  2. The date-time fields fixed (createdAt, updateAt, etc. have date-time format in json schema, but the actual response was in timestamp format)
  3. New streams added: CampaignsMetrics, Events. Both streams have volatile fields. For two different queries, the results may differ, so the output is presented as a json object. CampaingsMetrics stream has a plain/text response type, plain text parser added.
  4. The templates stream does not work properly (there is a nested loop, and cursor_field for each iteration must be different, one cursor_field for all iterations at the moment) and some Acceptance Tests are failed. Because of this we have removed this stream from the config. This needs to be fixed yet.

Recommended reading order

  1. source.py
  2. api.py
  3. schemas/campaigns_metrics.json
  4. schemas/events.json

Pre-merge Checklist

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions
  • Connector version bumped like described here

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here

@github-actions github-actions bot added the area/connectors Connector related issues label Sep 8, 2021
@gaart
Copy link
Contributor Author

gaart commented Sep 8, 2021

/test connector=connectors/source-iterable

🕑 connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1214090271
❌ connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1214090271

@jrhizor jrhizor temporarily deployed to more-secrets September 8, 2021 16:16 Inactive
@gaart
Copy link
Contributor Author

gaart commented Sep 8, 2021

/test connector=connectors/source-iterable

🕑 connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1214739313
❌ connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1214739313

@jrhizor jrhizor temporarily deployed to more-secrets September 8, 2021 19:59 Inactive
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Sep 9, 2021
@gaart gaart linked an issue Sep 9, 2021 that may be closed by this pull request
@gaart
Copy link
Contributor Author

gaart commented Sep 9, 2021

/test connector=connectors/source-iterable

🕑 connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1217226337
✅ connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1217226337

@jrhizor jrhizor temporarily deployed to more-secrets September 9, 2021 12:11 Inactive
@@ -0,0 +1,8 @@
{
"properties": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there is a reason why we have so generic schema?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I can see there's no a strict schema for this

Copy link
Contributor

@keu keu Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this can be useful for users, because it lacks campaign id, also we definitely know at least some structure:

metric: <string>
value: <number>

Copy link
Contributor

@keu keu Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the id of campaign is inside of data, lets maybe rename it to metrics? or even better move it to the top level of object? i.e. campaign_metrics will looks like:

{
<id>: <campaign_id>,
<metric_i>: <value_i>,
...
}

instead of

{
data: {...}
}

{
"properties": {
"data": {
"type": ["null", "object"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question regarding events

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, custom fields

Copy link
Contributor

@keu keu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some questions

@gaart gaart requested a review from keu September 15, 2021 06:32
Copy link
Contributor

@vitaliizazmic vitaliizazmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only small changes.

try:
result[key] = int(value)
except ValueError:
result[key] = float(value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain what is it for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The response from the campaign_metrics endpoint is a csv file, the first line contains the name of the values, the second contains the values. There are 2 types of values: integer and floating point, so here we are casting from a string to the actual value type in a pretty naive way.

{
"api_key": "test-api-key",
"start_date": "2020-12-12T00:00:00Z"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline

"requests==2.25.1",
"airbyte-cdk~=0.1",
"pendulum~=1.2",
"requests",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you didn't set version?

yield {"data": self._parse_csv_string_to_dict(content)}

@staticmethod
def _parse_csv_string_to_dict(csv_string: str) -> Dict[str, Any]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

important to note that we assume that there is only one line in csv input

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mb move it outside of the class and make it return list of objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically there are two lines, the first one is for variable names, and the second – for values.
This is used only here at the moment, and we can extract it when necessary.
We return CampaignMetircs as a raw json, so converting to object and then back to dict looks unnecessary, what do you think?


return params

def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, any]]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about slice not by one campaign, but by 20-30, since we already doing a lot of sub reads

Copy link
Contributor

@keu keu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

# Conflicts:
#	airbyte-integrations/connectors/source-iterable/Dockerfile
#	airbyte-integrations/connectors/source-iterable/source_iterable/api.py
#	docs/integrations/sources/iterable.md
@gaart gaart temporarily deployed to more-secrets September 28, 2021 13:46 Inactive
@gaart
Copy link
Contributor Author

gaart commented Sep 28, 2021

/test connector=connectors/source-iterable

🕑 connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1282874272
✅ connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1282874272
Python tests coverage:

	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                 Stmts   Miss  Cover
	 ------------------------------------------------------------------------
	 source_acceptance_test/__init__.py                       2      0   100%
	 source_acceptance_test/base.py                          10      4    60%
	 source_acceptance_test/config.py                        74      8    89%
	 source_acceptance_test/conftest.py                     108    108     0%
	 source_acceptance_test/plugin.py                        47     47     0%
	 source_acceptance_test/tests/__init__.py                 4      0   100%
	 source_acceptance_test/tests/test_core.py              158    109    31%
	 source_acceptance_test/tests/test_full_refresh.py       18     11    39%
	 source_acceptance_test/tests/test_incremental.py        69     38    45%
	 source_acceptance_test/utils/__init__.py                 6      0   100%
	 source_acceptance_test/utils/asserts.py                 37      2    95%
	 source_acceptance_test/utils/common.py                  41     25    39%
	 source_acceptance_test/utils/compare.py                 47     20    57%
	 source_acceptance_test/utils/connector_runner.py        82     49    40%
	 source_acceptance_test/utils/json_schema_helper.py      75     11    85%
	 ------------------------------------------------------------------------
	 TOTAL                                                  778    432    44%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                          Stmts   Miss  Cover
	 -------------------------------------------------
	 source_iterable/__init__.py       2      2     0%
	 source_iterable/api.py          201    201     0%
	 source_iterable/source.py        15     15     0%
	 -------------------------------------------------
	 TOTAL                           218    218     0%

@jrhizor jrhizor temporarily deployed to more-secrets September 28, 2021 13:55 Inactive
@gaart gaart temporarily deployed to more-secrets September 29, 2021 12:09 Inactive
@gaart
Copy link
Contributor Author

gaart commented Sep 29, 2021

/test connector=connectors/source-iterable

🕑 connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1286726612
❌ connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1286726612
🐛 https://gradle.com/s/ss52pffe4z42g

@jrhizor jrhizor temporarily deployed to more-secrets September 29, 2021 12:12 Inactive
@gaart
Copy link
Contributor Author

gaart commented Oct 1, 2021

/test connector=connectors/source-iterable

🕑 connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1293980291
❌ connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1293980291
🐛 https://gradle.com/s/sfqmitgu7io7s

@jrhizor jrhizor temporarily deployed to more-secrets October 1, 2021 06:30 Inactive
@gaart
Copy link
Contributor Author

gaart commented Oct 1, 2021

/test connector=connectors/source-iterable

🕑 connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1294401566
❌ connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1294401566
🐛 https://gradle.com/s/x5hhyxsit74kg

@jrhizor jrhizor temporarily deployed to more-secrets October 1, 2021 09:01 Inactive
@gaart gaart temporarily deployed to more-secrets October 1, 2021 10:01 Inactive
@gaart
Copy link
Contributor Author

gaart commented Oct 1, 2021

/test connector=connectors/source-iterable

🕑 connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1294662876
✅ connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1294662876
Python tests coverage:

	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                 Stmts   Miss  Cover
	 ------------------------------------------------------------------------
	 source_acceptance_test/__init__.py                       2      0   100%
	 source_acceptance_test/base.py                          10      4    60%
	 source_acceptance_test/config.py                        74      8    89%
	 source_acceptance_test/conftest.py                     108    108     0%
	 source_acceptance_test/plugin.py                        47     47     0%
	 source_acceptance_test/tests/__init__.py                 4      0   100%
	 source_acceptance_test/tests/test_core.py              200     94    53%
	 source_acceptance_test/tests/test_full_refresh.py       18     11    39%
	 source_acceptance_test/tests/test_incremental.py        69     38    45%
	 source_acceptance_test/utils/__init__.py                 6      0   100%
	 source_acceptance_test/utils/asserts.py                 37      2    95%
	 source_acceptance_test/utils/common.py                  41     24    41%
	 source_acceptance_test/utils/compare.py                 47     20    57%
	 source_acceptance_test/utils/connector_runner.py        82     49    40%
	 source_acceptance_test/utils/json_schema_helper.py     111     11    90%
	 ------------------------------------------------------------------------
	 TOTAL                                                  856    416    51%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                          Stmts   Miss  Cover
	 -------------------------------------------------
	 source_iterable/__init__.py       2      2     0%
	 Name                          Stmts   Miss  CoverCoverage.py warning: No data was collected. (no-data-collected)
	 source_iterable/api.py          215    215     0%
	 source_iterable/source.py        15     15     0%
	 -------------------------------------------------
	 TOTAL                           232    232     0%

@jrhizor jrhizor temporarily deployed to more-secrets October 1, 2021 10:24 Inactive
@gaart
Copy link
Contributor Author

gaart commented Oct 4, 2021

/test connector=connectors/source-iterable

🕑 connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1303636984
✅ connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1303636984
Python tests coverage:

	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                 Stmts   Miss  Cover
	 ------------------------------------------------------------------------
	 source_acceptance_test/__init__.py                       2      0   100%
	 source_acceptance_test/base.py                          10      4    60%
	 source_acceptance_test/config.py                        74      8    89%
	 source_acceptance_test/conftest.py                     108    108     0%
	 source_acceptance_test/plugin.py                        47     47     0%
	 source_acceptance_test/tests/__init__.py                 4      0   100%
	 source_acceptance_test/tests/test_core.py              200     94    53%
	 source_acceptance_test/tests/test_full_refresh.py       18     11    39%
	 source_acceptance_test/tests/test_incremental.py        69     38    45%
	 source_acceptance_test/utils/__init__.py                 6      0   100%
	 source_acceptance_test/utils/asserts.py                 37      2    95%
	 source_acceptance_test/utils/common.py                  41     24    41%
	 source_acceptance_test/utils/compare.py                 47     20    57%
	 source_acceptance_test/utils/connector_runner.py        82     49    40%
	 source_acceptance_test/utils/json_schema_helper.py     111     11    90%
	 ------------------------------------------------------------------------
	 TOTAL                                                  856    416    51%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 /actions-runner/_work/airbyte/airbyte/airbyte-integrations/connectors/source-iterable/.venv/lib/python3.8/site-packages/coverage/control.py:761: CoverageWarning: No data was collected. (no-data-collected)
	 Name                          Stmts   Miss  Cover
	 -------------------------------------------------
	 source_iterable/__init__.py       2      2     0%
	 source_iterable/api.py          215    215     0%
	 source_iterable/source.py        15     15     0%
	 -------------------------------------------------
	 TOTAL                           232    232     0%

@jrhizor jrhizor temporarily deployed to more-secrets October 4, 2021 12:56 Inactive
@gaart
Copy link
Contributor Author

gaart commented Oct 4, 2021

/publish connector=connectors/source-iterable

🕑 connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1303855795
✅ connectors/source-iterable https://github.com/airbytehq/airbyte/actions/runs/1303855795

@jrhizor jrhizor temporarily deployed to more-secrets October 4, 2021 13:54 Inactive
@gaart gaart merged commit 8dae288 into master Oct 4, 2021
@gaart gaart deleted the gaart/5574-source-iterable branch October 4, 2021 14:57
schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 2022
* Add new streams

* Upd requirements versions

* Upd docs

* Remove tests for the templates stream

* Upd csv field parsing

* Fix file permissions

* Set dependency version

* Refactor

* Merge

* Upd licence

* Add bulk metrics retrieving

* Actualize schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source Iterable: add new endpoints
6 participants