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

Bump CDK consumers #3368

Merged
merged 7 commits into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions airbyte-cdk/python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

## 0.1.2
Fix an issue that caused infinite pagination: https://github.com/airbytehq/airbyte/pull/3366

## 0.1.1
Initial Release
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ def read_records(
stream_state = stream_state or {}
pagination_complete = False

next_page_token = None
while not pagination_complete:
next_page_token = None
request_headers = self.request_headers(stream_state=stream_state, stream_slice=stream_slice, next_page_token=next_page_token)
request = self._create_prepared_request(
path=self.path(stream_state=stream_state, stream_slice=stream_slice, next_page_token=next_page_token),
Expand Down
2 changes: 1 addition & 1 deletion airbyte-cdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

setup(
name="airbyte-cdk",
version="0.1.1",
version="0.1.2",
description="A framework for writing Airbyte Connectors.",
long_description=README,
long_description_content_type="text/markdown",
Expand Down
35 changes: 22 additions & 13 deletions airbyte-cdk/python/unit_tests/sources/streams/http/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@


class StubBasicReadHttpStream(HttpStream):

url_base = "https://test_base_url.com"
primary_key = ""

Expand Down Expand Up @@ -60,7 +59,6 @@ def parse_response(


def test_stub_basic_read_http_stream_read_records(mocker):

stream = StubBasicReadHttpStream()
blank_response = {} # Send a blank response is fine as we ignore the response in `parse_response anyway.
mocker.patch.object(StubBasicReadHttpStream, "_send_request", return_value=blank_response)
Expand All @@ -71,35 +69,47 @@ def test_stub_basic_read_http_stream_read_records(mocker):


class StubNextPageTokenHttpStream(StubBasicReadHttpStream):
current_page = 0

current_token = 0
max_token_number = 6
def __init__(self, pages: int = 5):
super().__init__()
self._pages = pages

def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
while self.current_token < 5:
self.current_token += 1
return {"token": "token"}
while self.current_page < self._pages:
page_token = {"page": self.current_page}
self.current_page += 1
return page_token
return None


def test_stub_next_page_token_http_stream_read_records(mocker):

stream = StubNextPageTokenHttpStream()
def test_pagination(mocker):
pages = 5
stream = StubNextPageTokenHttpStream(pages=pages)
blank_response = {} # Send a blank response is fine as we ignore the response in `parse_response anyway.
mocker.patch.object(StubNextPageTokenHttpStream, "_send_request", return_value=blank_response)

methods = ["request_params", "request_headers", "request_body_json"]
expected_next_page_tokens = [{"page": i} for i in range(pages)]

for method in methods:
mocker.patch.object(stream, method, wraps=getattr(stream, method))

records = list(stream.read_records(SyncMode.full_refresh))

for method in methods:
getattr(stream, method).assert_any_call(next_page_token=None, stream_slice=None, stream_state={}) # Assert first call happened
for token in expected_next_page_tokens:
getattr(stream, method).assert_any_call(next_page_token=token, stream_slice=None, stream_state={})

assert [{"data": 1}, {"data": 2}, {"data": 3}, {"data": 4}, {"data": 5}, {"data": 6}] == records


class StubBadUrlHttpStream(StubBasicReadHttpStream):

url_base = "bad_url"


def test_stub_bad_url_http_stream_read_records(mocker):

stream = StubBadUrlHttpStream()

with pytest.raises(requests.exceptions.RequestException):
Expand All @@ -112,7 +122,6 @@ def backoff_time(self, response: requests.Response) -> Optional[float]:


def test_stub_custom_backoff_http_stream(mocker):

stream = StubCustomBackoffHttpStream()
req = requests.Response()
req.status_code = 429
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"sourceDefinitionId": "ef69ef6e-aa7f-4af1-a01d-ef775033524e",
"name": "GitHub",
"dockerRepository": "airbyte/source-github-singer",
"dockerImageTag": "0.2.5",
"dockerImageTag": "0.2.6",
"documentationUrl": "https://hub.docker.com/r/airbyte/source-github-singer",
"icon": "github.svg"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- sourceDefinitionId: ef69ef6e-aa7f-4af1-a01d-ef775033524e
name: GitHub
dockerRepository: airbyte/source-github-singer
dockerImageTag: 0.2.5
dockerImageTag: 0.2.6
documentationUrl: https://hub.docker.com/r/airbyte/source-github-singer
icon: github.svg
- sourceDefinitionId: b5ea17b1-f170-46dc-bc31-cc744ca984c1
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/bases/source-acceptance-test/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import setuptools

MAIN_REQUIREMENTS = [
"airbyte-cdk==0.1.1",
"airbyte-cdk==0.1.2",
"docker==4.4.4",
"PyYAML==5.4.0",
"inflection==0.5.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ RUN pip install .

ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.4
LABEL io.airbyte.version=0.1.5
LABEL io.airbyte.name=airbyte/source-exchange-rates
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
author_email="[email protected]",
packages=find_packages(),
package_data={"": ["*.json", "schemas/*.json"]},
install_requires=["airbyte-cdk==0.1.1", "pendulum>=2,<3"],
install_requires=["airbyte-cdk==0.1.2", "pendulum>=2,<3"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN pip install .

ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.2.5
LABEL io.airbyte.version=0.2.6
LABEL io.airbyte.name=airbyte/source-github-singer

WORKDIR /airbyte
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
install_requires=[
"tap-github @ https://github.com/airbytehq/tap-github/tarball/v1.9.4-airbyte",
"requests==2.20.0",
"airbyte-cdk==0.1.1",
"airbyte-cdk==0.1.2",
],
package_data={"": ["*.json"]},
)
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-slack/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ RUN pip install .

ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.3
LABEL io.airbyte.version=0.1.4
LABEL io.airbyte.name=airbyte/source-slack
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-slack/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
author="Airbyte",
author_email="[email protected]",
packages=find_packages(),
install_requires=["airbyte-cdk==0.1.1", "pytest==6.1.2", "slack_sdk==3.4.2", "pendulum>=2,<3"],
install_requires=["airbyte-cdk==0.1.2", "pytest==6.1.2", "slack_sdk==3.4.2", "pendulum>=2,<3"],
package_data={"": ["*.json"]},
)
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-stripe/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ RUN pip install .

ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.7
LABEL io.airbyte.version=0.1.8
LABEL io.airbyte.name=airbyte/source-stripe
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-stripe/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
author_email="[email protected]",
packages=find_packages(),
package_data={"": ["*.json", "schemas/*.json", "schemas/shared/*.json"]},
install_requires=["airbyte-cdk==0.1.1", "stripe"],
install_requires=["airbyte-cdk==0.1.2", "stripe"],
)
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/airbyte-python.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AirbytePythonPlugin implements Plugin<Project> {
installVirtualenv = true
pip 'flake8:3.8.4'
pip 'black:20.8b1'
pip 'mypy:0.790'
pip 'mypy:0.812'
pip 'isort:5.6.4'
pip 'pytest:6.1.2'
pip 'pip:21.1'
Expand Down