Skip to content

Commit

Permalink
Python CDK: Relax pydantic version requirement (#28854)
Browse files Browse the repository at this point in the history
* relax pydantic dep

* Automated Commit - Format and Process Resources Changes

* update protocol models

* format change

---------

Co-authored-by: flash1293 <flash1293@users.noreply.github.com>
  • Loading branch information
Joe Reuter and flash1293 authored Aug 2, 2023
1 parent 33a94ce commit 60e1d72
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 16 deletions.
3 changes: 0 additions & 3 deletions airbyte-cdk/python/airbyte_cdk/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@
AirbyteStreamStatusTraceMessage,
AirbyteTraceMessage,
AuthFlowType,
AuthSpecification,
AuthType,
ConfiguredAirbyteCatalog,
ConfiguredAirbyteStream,
ConnectorSpecification,
DestinationSyncMode,
EstimateType,
FailureType,
Level,
OAuth2Specification,
OAuthConfigSpecification,
OrchestratorType,
Status,
Expand Down
4 changes: 2 additions & 2 deletions airbyte-cdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@
packages=find_packages(exclude=("unit_tests",)),
package_data={"airbyte_cdk": ["py.typed", "sources/declarative/declarative_component_schema.yaml"]},
install_requires=[
"airbyte-protocol-models==0.3.6",
"airbyte-protocol-models==0.4.0",
"backoff",
"dpath~=2.0.1",
"isodate~=0.6.1",
"jsonschema~=3.2.0",
"jsonref~=0.2",
"pendulum",
"genson==1.2.2",
"pydantic~=1.9.2",
"pydantic>=1.9.2,<2.0.0",
"python-dateutil",
"PyYAML>=6.0.1",
"requests",
Expand Down
4 changes: 2 additions & 2 deletions airbyte-cdk/python/unit_tests/sources/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ class TestBaseConfig:
"properties": {
"count": {"title": "Count", "type": "integer"},
"name": {"title": "Name", "type": "string"},
"selected_strategy": {"const": "option1", "title": "Selected " "Strategy", "type": "string"},
"selected_strategy": {"const": "option1", "title": "Selected " "Strategy", "type": "string", "default": "option1"},
},
"required": ["name", "count"],
"title": "Choice1",
"type": "object",
},
{
"properties": {
"selected_strategy": {"const": "option2", "title": "Selected " "Strategy", "type": "string"},
"selected_strategy": {"const": "option2", "title": "Selected " "Strategy", "type": "string", "default": "option2"},
"sequence": {"items": {"type": "string"}, "title": "Sequence", "type": "array"},
},
"required": ["sequence"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.11.4
Relax checking of `oneOf` common property and allow optional `default` keyword additional to `const` keyword.

## 0.11.3
Refactor test_oauth_flow_parameters to validate advanced_auth instead of the deprecated authSpecification

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ COPY pytest.ini setup.py ./
COPY connector_acceptance_test ./connector_acceptance_test
RUN pip install .

LABEL io.airbyte.version=0.11.3
LABEL io.airbyte.version=0.11.4
LABEL io.airbyte.name=airbyte/connector-acceptance-test

ENTRYPOINT ["python", "-m", "pytest", "-p", "connector_acceptance_test.plugin", "-r", "fEsx"]
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ def test_oneof_usage(self, actual_connector_spec: ConnectorSpecification):
for n, variant in enumerate(variants):
prop_obj = variant["properties"][const_common_prop]
assert (
"default" not in prop_obj
), f"There should not be 'default' keyword in common property {oneof_path}[{n}].{const_common_prop}. Use `const` instead. {docs_msg}"
assert (
"enum" not in prop_obj
), f"There should not be 'enum' keyword in common property {oneof_path}[{n}].{const_common_prop}. Use `const` instead. {docs_msg}"
"default" not in prop_obj or prop_obj["default"] == prop_obj["const"]
), f"'default' needs to be identical to const in common property {oneof_path}[{n}].{const_common_prop}. It's recommended to just use `const`. {docs_msg}"
assert "enum" not in prop_obj or (
len(prop_obj["enum"]) == 1 and prop_obj["enum"][0] == prop_obj["const"]
), f"'enum' needs to be an array with a single item identical to const in common property {oneof_path}[{n}].{const_common_prop}. It's recommended to just use `const`. {docs_msg}"

def test_required(self):
"""Check that connector will fail if any required field is missing"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,76 @@ def parametrize_test_case(*test_cases: Dict[str, Any]) -> Callable:
}
},
},
"should_fail": False,
},
{
"test_id": "different_default_in_common_property",
"connector_spec": {
"type": "object",
"properties": {
"credentials": {
"type": "object",
"oneOf": [
{
"type": "object",
"properties": {
"common": {"type": "string", "const": "option1", "default": "optionX"},
"option1": {"type": "string"},
},
}
],
}
},
},
"should_fail": True,
},
{
"test_id": "enum_keyword_in_common_property",
"connector_spec": {
"type": "object",
"properties": {
"credentials": {
"type": "object",
"oneOf": [
{
"type": "object",
"properties": {
"common": {"type": "string", "const": "option1", "enum": ["option1"]},
"option1": {"type": "string"},
},
},
{
"type": "object",
"properties": {
"common": {"type": "string", "const": "option2", "enum": ["option2"]},
"option2": {"type": "string"},
},
},
],
}
},
},
"should_fail": False,
},
{
"test_id": "different_enum_in_common_property",
"connector_spec": {
"type": "object",
"properties": {
"credentials": {
"type": "object",
"oneOf": [
{
"type": "object",
"properties": {
"common": {"type": "string", "const": "option1", "enum": ["option1", "option2"]},
"option1": {"type": "string"},
},
}
],
}
},
},
"should_fail": True,
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ data:
license: MIT
name: Scaffold Java Jdbc
releaseDate: TODO
releaseStage: alpha
supportLevel: community
releaseStage: alpha
documentationUrl: https://docs.airbyte.com/integrations/sources/scaffold-java-jdbc
tags:
- language:java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ data:
license: MIT
name: Scaffold Source Http
releaseDate: TODO
releaseStage: alpha
supportLevel: community
releaseStage: alpha
documentationUrl: https://docs.airbyte.com/integrations/sources/scaffold-source-http
tags:
- language:python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ data:
license: MIT
name: Scaffold Source Python
releaseDate: TODO
releaseStage: alpha
supportLevel: community
releaseStage: alpha
documentationUrl: https://docs.airbyte.com/integrations/sources/scaffold-source-python
tags:
- language:python
Expand Down

0 comments on commit 60e1d72

Please sign in to comment.