Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions protocol-models/bin/generate-python-dataclasses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ mkdir -p "$ROOT_DIR/$OUTPUT_DIR"
echo "# generated by generate-python-dataclasses" > "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
echo "name = 'models'" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py

for f in "$ROOT_DIR/$YAML_DIR"/*.yaml; do
if [ -f $ROOT_DIR/$YAML_DIR/airbyte_protocol.yaml ]; then
echo ERROR: File airbyte_protocol.yaml exists in both $ROOT_DIR/$YAML_DIR and $ROOT_DIR/$YAML_DIR/v0. Only one is expected
exit 1
fi

for f in "$ROOT_DIR/$YAML_DIR"/*.yaml "$ROOT_DIR/$YAML_DIR"/v0/airbyte_protocol.yaml; do
filename_wo_ext=$(basename "$f" | cut -d . -f 1)
echo "from .$filename_wo_ext import *" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py

datamodel-codegen \
--input-file-type jsonschema \
--input "$ROOT_DIR/$YAML_DIR/$filename_wo_ext.yaml" \
--input "$f" \
Comment on lines -31 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would no longer generate the v0 file right? do we need that for anything else? (not sure if there are other consumers of the protocol)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh maybe the output is still the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that it never generated the V0 files. However when I compared v0 and v2 airbyte_protocol.yaml files, they were the same (except some formatting and comments differing)

--output "$ROOT_DIR/$OUTPUT_DIR/$filename_wo_ext.py" \
--output-model-type dataclasses.dataclass \
--target-python-version 3.9 \
Expand Down
9 changes: 7 additions & 2 deletions protocol-models/bin/generate-python-pydantic-v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ mkdir -p "$ROOT_DIR/$OUTPUT_DIR"
echo "# generated by generate-python-pydantic-v2" > "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
echo "name = 'models'" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py

for f in "$ROOT_DIR/$YAML_DIR"/*.yaml; do
if [ -f $ROOT_DIR/$YAML_DIR/airbyte_protocol.yaml ]; then
echo ERROR: File airbyte_protocol.yaml exists in both $ROOT_DIR/$YAML_DIR and $ROOT_DIR/$YAML_DIR/v0. Only one is expected
exit 1
fi

for f in "$ROOT_DIR/$YAML_DIR"/*.yaml "$ROOT_DIR/$YAML_DIR"/v0/airbyte_protocol.yaml; do
filename_wo_ext=$(basename "$f" | cut -d . -f 1)
echo "from .$filename_wo_ext import *" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py

datamodel-codegen \
--input-file-type jsonschema \
--input "$ROOT_DIR/$YAML_DIR/$filename_wo_ext.yaml" \
--input "$f" \
--output "$ROOT_DIR/$OUTPUT_DIR/$filename_wo_ext.py" \
--output-model-type pydantic_v2.BaseModel \
--target-python-version 3.10 \
Expand Down
9 changes: 7 additions & 2 deletions protocol-models/bin/generate-python-pydantic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@ mkdir -p "$ROOT_DIR/$OUTPUT_DIR"
echo "# generated by generate-python-pydantic.sh" > "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
echo "name = 'models'" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py

for f in "$ROOT_DIR/$YAML_DIR"/*.yaml; do
if [ -f $ROOT_DIR/$YAML_DIR/airbyte_protocol.yaml ]; then
echo ERROR: File airbyte_protocol.yaml exists in both $ROOT_DIR/$YAML_DIR and $ROOT_DIR/$YAML_DIR/v0. Only one is expected
exit 1
fi

for f in "$ROOT_DIR/$YAML_DIR"/*.yaml "$ROOT_DIR/$YAML_DIR"/v0/airbyte_protocol.yaml; do
filename_wo_ext=$(basename "$f" | cut -d . -f 1)
echo "from .$filename_wo_ext import *" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py

datamodel-codegen \
--input "$ROOT_DIR/$YAML_DIR/$filename_wo_ext.yaml" \
--input "$f" \
--output "$ROOT_DIR/$OUTPUT_DIR/$filename_wo_ext.py" \
--use-title-as-name \
--disable-timestamp
Expand Down
Loading