Skip to content

Commit

Permalink
Hosted extractor Unknown Object bug (#1971)
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino authored Oct 10, 2024
1 parent 276e10d commit 9a7fe65
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [7.63.1] - 2024-10-10
### Fixed
- [Feature Preview - alpha] Dumping `HostedExtractor` `Job` and `Source` data classes creates valid JSON/YAML
even when unknown fields are present.

## [7.63.0] - 2024-10-10
### Removed
- Removed support for Python 3.8 and 3.9.
Expand Down
2 changes: 1 addition & 1 deletion cognite/client/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import annotations

__version__ = "7.63.0"
__version__ = "7.63.1"
__api_subversion__ = "20230101"
2 changes: 1 addition & 1 deletion cognite/client/data_classes/hosted_extractors/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def __init__(
def dump(self, camel_case: bool = True) -> dict[str, Any]:
output = super().dump(camel_case)
output["format"] = self.format.dump(camel_case)
if isinstance(self.config, JobConfig):
if self.config is not None:
output["config"] = self.config.dump(camel_case)
return output

Expand Down
16 changes: 8 additions & 8 deletions cognite/client/data_classes/hosted_extractors/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,11 @@ def as_write(self) -> NoReturn:

def dump(self, camel_case: bool = True) -> dict[str, Any]:
output = super().dump(camel_case)
if isinstance(self.authentication, MQTTAuthentication):
if self.authentication is not None:
output["authentication"] = self.authentication.dump(camel_case)
if isinstance(self.ca_certificate, CACertificate):
if self.ca_certificate is not None:
output["caCertificate" if camel_case else "ca_certificate"] = self.ca_certificate.dump(camel_case)
if isinstance(self.auth_certificate, AuthCertificate):
if self.auth_certificate is not None:
output["authCertificate" if camel_case else "auth_certificate"] = self.auth_certificate.dump(camel_case)
return output

Expand Down Expand Up @@ -722,11 +722,11 @@ def dump(self, camel_case: bool = True) -> dict[str, Any]:
output["bootstrapBrokers" if camel_case else "bootstrap_brokers"] = [
broker.dump(camel_case) for broker in self.bootstrap_brokers
]
if isinstance(self.authentication, MQTTAuthentication):
if self.authentication is not None:
output["authentication"] = self.authentication.dump(camel_case)
if isinstance(self.ca_certificate, CACertificate):
if self.ca_certificate is not None:
output["caCertificate" if camel_case else "ca_certificate"] = self.ca_certificate.dump(camel_case)
if isinstance(self.auth_certificate, AuthCertificate):
if self.auth_certificate is not None:
output["authCertificate" if camel_case else "auth_certificate"] = self.auth_certificate.dump(camel_case)
return output

Expand Down Expand Up @@ -901,9 +901,9 @@ def as_write(self) -> RestSourceWrite:

def dump(self, camel_case: bool = True) -> dict[str, Any]:
output = super().dump(camel_case)
if isinstance(self.ca_certificate, CACertificate):
if self.ca_certificate is not None:
output["caCertificate" if camel_case else "ca_certificate"] = self.ca_certificate.dump(camel_case)
if isinstance(self.auth_certificate, AuthCertificate):
if self.auth_certificate is not None:
output["authCertificate" if camel_case else "auth_certificate"] = self.auth_certificate.dump(camel_case)
return output

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "cognite-sdk"

version = "7.63.0"
version = "7.63.1"
description = "Cognite Python SDK"
readme = "README.md"
documentation = "https://cognite-sdk-python.readthedocs-hosted.com"
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import yaml

from cognite.client.data_classes.hosted_extractors.jobs import Job


class TestJob:
def test_load_yaml_dump_unknown_config(self) -> None:
raw_yaml = """externalId: myJob
sourceId: my_eventhub
destinationId: EventHubTarget
targetStatus: running
status: running
createdTime: 123
lastUpdatedTime: 1234
format:
type: value
encoding: utf16
compression: gzip
config:
some: new_config
that: has not been seen before"""

assert Job.load(raw_yaml).dump() == yaml.safe_load(raw_yaml)

0 comments on commit 9a7fe65

Please sign in to comment.