From 3c1eab3e27d6d499d85940da6b4e9354cf839398 Mon Sep 17 00:00:00 2001 From: "Pedro S. Lopez" Date: Wed, 4 May 2022 18:48:34 -0400 Subject: [PATCH] generate `AirbyeTraceMessage.type` enum with descriptive class name (#12581) * generate AirbyeTraceMessage `type` enum with descriptive class name * add comment on `title` usage Co-authored-by: Sherif A. Nada * apply changes to bases/airbyte-protocol Co-authored-by: Sherif A. Nada --- airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py | 4 ++-- airbyte-cdk/python/bin/generate-protocol-files.sh | 1 + .../airbyte_protocol/models/airbyte_protocol.py | 4 ++-- .../bases/airbyte-protocol/bin/generate-protocol-files.sh | 1 + .../src/main/resources/airbyte_protocol/airbyte_protocol.yaml | 1 + 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py b/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py index 6d80c4042675..e309b7f00d8d 100644 --- a/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py +++ b/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py @@ -60,7 +60,7 @@ class Config: message: str = Field(..., description="the log message") -class Type1(Enum): +class TraceType(Enum): ERROR = "ERROR" @@ -161,7 +161,7 @@ class AirbyteTraceMessage(BaseModel): class Config: extra = Extra.allow - type: Type1 = Field(..., description="the type of trace message") + type: TraceType = Field(..., description="the type of trace message", title="trace type") emitted_at: float = Field(..., description="the time in ms that the message was emitted") error: Optional[AirbyteErrorTraceMessage] = Field(None, description="error trace message: the error object") diff --git a/airbyte-cdk/python/bin/generate-protocol-files.sh b/airbyte-cdk/python/bin/generate-protocol-files.sh index b268f4d53185..e3fea30173b3 100755 --- a/airbyte-cdk/python/bin/generate-protocol-files.sh +++ b/airbyte-cdk/python/bin/generate-protocol-files.sh @@ -18,6 +18,7 @@ function main() { docker run --user "$(id -u):$(id -g)" -v "$ROOT_DIR":/airbyte airbyte/code-generator:dev \ --input "/airbyte/$YAML_DIR/$filename_wo_ext.yaml" \ --output "/airbyte/$OUTPUT_DIR/$filename_wo_ext.py" \ + --use-title-as-name \ --disable-timestamp done } diff --git a/airbyte-integrations/bases/airbyte-protocol/airbyte_protocol/models/airbyte_protocol.py b/airbyte-integrations/bases/airbyte-protocol/airbyte_protocol/models/airbyte_protocol.py index 31c62eb174e7..5af49e796db1 100644 --- a/airbyte-integrations/bases/airbyte-protocol/airbyte_protocol/models/airbyte_protocol.py +++ b/airbyte-integrations/bases/airbyte-protocol/airbyte_protocol/models/airbyte_protocol.py @@ -57,7 +57,7 @@ class Config: message: str = Field(..., description="the log message") -class Type1(Enum): +class TraceType(Enum): ERROR = "ERROR" @@ -157,7 +157,7 @@ class AirbyteTraceMessage(BaseModel): class Config: extra = Extra.allow - type: Type1 = Field(..., description="the type of trace message") + type: TraceType = Field(..., description="the type of trace message", title="trace type") emitted_at: float = Field(..., description="the time in ms that the message was emitted") error: Optional[AirbyteErrorTraceMessage] = Field(None, description="error trace message: the error object") diff --git a/airbyte-integrations/bases/airbyte-protocol/bin/generate-protocol-files.sh b/airbyte-integrations/bases/airbyte-protocol/bin/generate-protocol-files.sh index 44480c2f54fd..422297178cd9 100755 --- a/airbyte-integrations/bases/airbyte-protocol/bin/generate-protocol-files.sh +++ b/airbyte-integrations/bases/airbyte-protocol/bin/generate-protocol-files.sh @@ -18,6 +18,7 @@ function main() { docker run --user "$(id -u):$(id -g)" -v "$ROOT_DIR":/airbyte airbyte/code-generator:dev \ --input "/airbyte/$YAML_DIR/$filename_wo_ext.yaml" \ --output "/airbyte/$OUTPUT_DIR/$filename_wo_ext.py" \ + --use-title-as-name \ --disable-timestamp done } diff --git a/airbyte-protocol/models/src/main/resources/airbyte_protocol/airbyte_protocol.yaml b/airbyte-protocol/models/src/main/resources/airbyte_protocol/airbyte_protocol.yaml index 1eabc18c01eb..760c5e895ef4 100644 --- a/airbyte-protocol/models/src/main/resources/airbyte_protocol/airbyte_protocol.yaml +++ b/airbyte-protocol/models/src/main/resources/airbyte_protocol/airbyte_protocol.yaml @@ -106,6 +106,7 @@ definitions: - emitted_at properties: type: + title: "trace type" # this title is required to avoid python codegen conflicts with the "type" parameter in AirbyteMessage. See https://github.com/airbytehq/airbyte/pull/12581 description: "the type of trace message" type: string enum: