|
26 | 26 | from airbyte_cdk.models import ( |
27 | 27 | AirbyteConnectionStatus, |
28 | 28 | AirbyteMessage, |
29 | | - AirbyteMessageSerializer, |
30 | 29 | AirbyteStateStats, |
31 | 30 | ConnectorSpecification, |
32 | 31 | FailureType, |
33 | 32 | Status, |
34 | 33 | Type, |
| 34 | + ab_message_to_string, |
35 | 35 | ) |
36 | 36 | from airbyte_cdk.sources import Source |
37 | 37 | from airbyte_cdk.sources.connector_state_manager import HashableStreamDescriptor |
|
47 | 47 |
|
48 | 48 | VALID_URL_SCHEMES = ["https"] |
49 | 49 | CLOUD_DEPLOYMENT_MODE = "cloud" |
50 | | -_HAS_LOGGED_FOR_SERIALIZATION_ERROR = False |
51 | 50 |
|
52 | 51 |
|
53 | 52 | class AirbyteEntrypoint(object): |
@@ -178,41 +177,41 @@ def run(self, parsed_args: argparse.Namespace) -> Iterable[str]: |
178 | 177 | if cmd == "spec": |
179 | 178 | message = AirbyteMessage(type=Type.SPEC, spec=source_spec) |
180 | 179 | yield from [ |
181 | | - self.airbyte_message_to_string(queued_message) |
| 180 | + ab_message_to_string(queued_message) |
182 | 181 | for queued_message in self._emit_queued_messages(self.source) |
183 | 182 | ] |
184 | | - yield self.airbyte_message_to_string(message) |
| 183 | + yield ab_message_to_string(message) |
185 | 184 | else: |
186 | 185 | raw_config = self.source.read_config(parsed_args.config) |
187 | 186 | config = self.source.configure(raw_config, temp_dir) |
188 | 187 |
|
189 | 188 | yield from [ |
190 | | - self.airbyte_message_to_string(queued_message) |
| 189 | + ab_message_to_string(queued_message) |
191 | 190 | for queued_message in self._emit_queued_messages(self.source) |
192 | 191 | ] |
193 | 192 | if cmd == "check": |
194 | 193 | yield from map( |
195 | | - AirbyteEntrypoint.airbyte_message_to_string, |
| 194 | + ab_message_to_string, |
196 | 195 | self.check(source_spec, config), |
197 | 196 | ) |
198 | 197 | elif cmd == "discover": |
199 | 198 | yield from map( |
200 | | - AirbyteEntrypoint.airbyte_message_to_string, |
| 199 | + ab_message_to_string, |
201 | 200 | self.discover(source_spec, config), |
202 | 201 | ) |
203 | 202 | elif cmd == "read": |
204 | 203 | config_catalog = self.source.read_catalog(parsed_args.catalog) |
205 | 204 | state = self.source.read_state(parsed_args.state) |
206 | 205 |
|
207 | 206 | yield from map( |
208 | | - AirbyteEntrypoint.airbyte_message_to_string, |
| 207 | + ab_message_to_string, |
209 | 208 | self.read(source_spec, config, config_catalog, state), |
210 | 209 | ) |
211 | 210 | else: |
212 | 211 | raise Exception("Unexpected command " + cmd) |
213 | 212 | finally: |
214 | 213 | yield from [ |
215 | | - self.airbyte_message_to_string(queued_message) |
| 214 | + ab_message_to_string(queued_message) |
216 | 215 | for queued_message in self._emit_queued_messages(self.source) |
217 | 216 | ] |
218 | 217 |
|
@@ -327,20 +326,6 @@ def set_up_secret_filter(config: TConfig, connection_specification: Mapping[str, |
327 | 326 | config_secrets = get_secrets(connection_specification, config) |
328 | 327 | update_secrets(config_secrets) |
329 | 328 |
|
330 | | - @staticmethod |
331 | | - def airbyte_message_to_string(airbyte_message: AirbyteMessage) -> str: |
332 | | - global _HAS_LOGGED_FOR_SERIALIZATION_ERROR |
333 | | - serialized_message = AirbyteMessageSerializer.dump(airbyte_message) |
334 | | - try: |
335 | | - return orjson.dumps(serialized_message).decode() |
336 | | - except Exception as exception: |
337 | | - if not _HAS_LOGGED_FOR_SERIALIZATION_ERROR: |
338 | | - logger.warning( |
339 | | - f"There was an error during the serialization of an AirbyteMessage: `{exception}`. This might impact the sync performances." |
340 | | - ) |
341 | | - _HAS_LOGGED_FOR_SERIALIZATION_ERROR = True |
342 | | - return json.dumps(serialized_message) |
343 | | - |
344 | 329 | @classmethod |
345 | 330 | def extract_state(cls, args: List[str]) -> Optional[Any]: |
346 | 331 | parsed_args = cls.parse_args(args) |
|
0 commit comments