Skip to content

Commit 772c73b

Browse files
authored
fix: python generation scripts (#137)
1 parent ec12662 commit 772c73b

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

protocol-models/bin/generate-python-dataclasses.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@ mkdir -p "$ROOT_DIR/$OUTPUT_DIR"
2222
echo "# generated by generate-python-dataclasses" > "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
2323
echo "name = 'models'" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
2424

25-
for f in "$ROOT_DIR/$YAML_DIR"/*.yaml; do
25+
if [ -f $ROOT_DIR/$YAML_DIR/airbyte_protocol.yaml ]; then
26+
echo ERROR: File airbyte_protocol.yaml exists in both $ROOT_DIR/$YAML_DIR and $ROOT_DIR/$YAML_DIR/v0. Only one is expected
27+
exit 1
28+
fi
29+
30+
for f in "$ROOT_DIR/$YAML_DIR"/*.yaml "$ROOT_DIR/$YAML_DIR"/v0/airbyte_protocol.yaml; do
2631
filename_wo_ext=$(basename "$f" | cut -d . -f 1)
2732
echo "from .$filename_wo_ext import *" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
2833

2934
datamodel-codegen \
3035
--input-file-type jsonschema \
31-
--input "$ROOT_DIR/$YAML_DIR/$filename_wo_ext.yaml" \
36+
--input "$f" \
3237
--output "$ROOT_DIR/$OUTPUT_DIR/$filename_wo_ext.py" \
3338
--output-model-type dataclasses.dataclass \
3439
--target-python-version 3.9 \

protocol-models/bin/generate-python-pydantic-v2.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@ mkdir -p "$ROOT_DIR/$OUTPUT_DIR"
2222
echo "# generated by generate-python-pydantic-v2" > "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
2323
echo "name = 'models'" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
2424

25-
for f in "$ROOT_DIR/$YAML_DIR"/*.yaml; do
25+
if [ -f $ROOT_DIR/$YAML_DIR/airbyte_protocol.yaml ]; then
26+
echo ERROR: File airbyte_protocol.yaml exists in both $ROOT_DIR/$YAML_DIR and $ROOT_DIR/$YAML_DIR/v0. Only one is expected
27+
exit 1
28+
fi
29+
30+
for f in "$ROOT_DIR/$YAML_DIR"/*.yaml "$ROOT_DIR/$YAML_DIR"/v0/airbyte_protocol.yaml; do
2631
filename_wo_ext=$(basename "$f" | cut -d . -f 1)
2732
echo "from .$filename_wo_ext import *" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
2833

2934
datamodel-codegen \
3035
--input-file-type jsonschema \
31-
--input "$ROOT_DIR/$YAML_DIR/$filename_wo_ext.yaml" \
36+
--input "$f" \
3237
--output "$ROOT_DIR/$OUTPUT_DIR/$filename_wo_ext.py" \
3338
--output-model-type pydantic_v2.BaseModel \
3439
--target-python-version 3.10 \

protocol-models/bin/generate-python-pydantic.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ mkdir -p "$ROOT_DIR/$OUTPUT_DIR"
2222
echo "# generated by generate-python-pydantic.sh" > "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
2323
echo "name = 'models'" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
2424

25-
for f in "$ROOT_DIR/$YAML_DIR"/*.yaml; do
25+
if [ -f $ROOT_DIR/$YAML_DIR/airbyte_protocol.yaml ]; then
26+
echo ERROR: File airbyte_protocol.yaml exists in both $ROOT_DIR/$YAML_DIR and $ROOT_DIR/$YAML_DIR/v0. Only one is expected
27+
exit 1
28+
fi
29+
30+
for f in "$ROOT_DIR/$YAML_DIR"/*.yaml "$ROOT_DIR/$YAML_DIR"/v0/airbyte_protocol.yaml; do
2631
filename_wo_ext=$(basename "$f" | cut -d . -f 1)
2732
echo "from .$filename_wo_ext import *" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
2833

2934
datamodel-codegen \
30-
--input "$ROOT_DIR/$YAML_DIR/$filename_wo_ext.yaml" \
35+
--input "$f" \
3136
--output "$ROOT_DIR/$OUTPUT_DIR/$filename_wo_ext.py" \
3237
--use-title-as-name \
3338
--disable-timestamp

0 commit comments

Comments
 (0)