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

🎉 New Source: Iterable #2895

Merged
merged 18 commits into from
Apr 20, 2021
Merged

Conversation

yevhenii-ldv
Copy link
Contributor

What

Creating new source Iterable based on Base Python

closes #2412

Pre-merge Checklist

  • Run integration tests
  • Publish Docker images

Recommended reading order

  1. test.java
  2. component.ts
  3. the rest

@yevhenii-ldv
Copy link
Contributor Author

yevhenii-ldv commented Apr 15, 2021

/test connector=source-iterable

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

list(Lists(authenticator=authenticator)._list_records(stream_state={}))
return True, None
except Exception as e:
return False, e
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's better to add more detail message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

:return:
"""

for templete in self.template_types:
Copy link

Choose a reason for hiding this comment

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

Is it a typo: templete vs template?

args = {"stream_state": stream_state}

request = self._create_prepared_request(
path=self.path().format(templete, message),
Copy link

Choose a reason for hiding this comment

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

Typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@yevhenii-ldv yevhenii-ldv linked an issue Apr 16, 2021 that may be closed by this pull request
@yevhenii-ldv yevhenii-ldv requested a review from sherifnada April 16, 2021 15:57
Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

This looks great! very easy to follow. Few comments and we should be ready to go. Think we can merge on Monday?

url_base = "https://api.iterable.com/api/"

# Hardcode the value because it is not returned from the API
BACKOFF_TIME_CONSTANT = 10.0
Copy link
Contributor

Choose a reason for hiding this comment

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

is the expected behavior to wait 10 seconds? BTW the default behavior for backing off in the framework is an exponential backoff. So if that behavior is acceptable, we don't need this and we don't need to implement backoff_time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I saw the default behavior for backing off and find that we can't use the default backoff for 429 error, because we just ignore it.

def should_give_up(exc):
# If a 4XX error makes it this far, it means it was unexpected and probably consistent, so we shouldn't back off
return exc.response is not None and 400 <= exc.response.status_code < 500

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see. I have a fix for this in the latest refactor of the framework -- this is a bug. It should have and exc.response.status_code != 429. We'll be able to refactor this soon to rely on the default backoff behavior.

parent_stream_record: Mapping = None,
) -> MutableMapping[str, Any]:

params = super(IterableExportStream, self).request_params(stream_state=stream_state)
Copy link
Contributor

Choose a reason for hiding this comment

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

are the params to super needed?

Suggested change
params = super(IterableExportStream, self).request_params(stream_state=stream_state)
params = super().request_params(stream_state=stream_state)

return params

def path(self, **kwargs) -> str:
return f"/export/data.json?dataTypeName={self.data_field}"
Copy link
Contributor

Choose a reason for hiding this comment

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

should dataTypeName be specified in request_params instead?

def get_auth_header(self) -> Mapping[str, Any]:
return {}

def get_auth_params(self) -> 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.

if auth is not in the headers, is it worth creating an entire Authenticator class? Why don't we just pass the token in the constructor parameters for each stream and then the base IterableStream class can add it in the request_params method? authenticator is an optional parameter for HTTP streams anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, good idea, updated

:return:
"""

for template in self.template_types:
Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm I see why you had to do this...not ideal that we are overriding an _ method. Working on an upcoming refactor that will hopefully make this much cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I solved this problem and used only the read_stream method with setting stream_params, please look at the PR after the update.

* Iterable #2897: support incremental sync

Co-authored-by: ykurochkin <y.kurochkin@zazmic.com>
@yevhenii-ldv
Copy link
Contributor Author

yevhenii-ldv commented Apr 19, 2021

/test connector=source-iterable

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

@yevhenii-ldv
Copy link
Contributor Author

yevhenii-ldv commented Apr 20, 2021

/publish connector=connectors/source-iterable

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

@yevhenii-ldv
Copy link
Contributor Author

yevhenii-ldv commented Apr 20, 2021

/test connector=source-iterable

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

@yevhenii-ldv yevhenii-ldv merged commit f8286e4 into master Apr 20, 2021
@yevhenii-ldv yevhenii-ldv deleted the ykurochkin/new-connector-iterable branch April 20, 2021 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source Iterable: Implement Read New Source: Iterable
4 participants