Skip to content

Commit

Permalink
add binary files
Browse files Browse the repository at this point in the history
  • Loading branch information
erohmensing committed Jun 7, 2024
1 parent 0f57239 commit 10fe3b3
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
13 changes: 13 additions & 0 deletions protocol-models/bin/generate-python-dataclasses-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -e

ROOT_DIR=${ROOT_DIR:-$(git rev-parse --show-toplevel)}
ROOT_DIR_NAME=${ROOT_DIR##*/}

[ -z "$ROOT_DIR" ] && exit 1

docker run --rm \
--volume "${ROOT_DIR}:/${ROOT_DIR_NAME}" \
--workdir "/${ROOT_DIR_NAME}" \
python:3.8 "/${ROOT_DIR_NAME}/protocol-models/bin/generate-python-dataclasses.sh"
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ ROOT_DIR_NAME=${ROOT_DIR##*/}
docker run --rm \
--volume "${ROOT_DIR}:/${ROOT_DIR_NAME}" \
--workdir "/${ROOT_DIR_NAME}" \
python:3.8 "/${ROOT_DIR_NAME}/protocol-models/bin/generate-python-classes.sh"
python:3.8 "/${ROOT_DIR_NAME}/protocol-models/bin/generate-python-pydantic.sh"
34 changes: 34 additions & 0 deletions protocol-models/bin/generate-python-pydantic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -e

git config --global --add safe.directory /airbyte-protocol

ROOT_DIR=${ROOT_DIR:-$(git rev-parse --show-toplevel)}

[ -z "$ROOT_DIR" ] && exit 1



YAML_DIR=protocol-models/src/main/resources/airbyte_protocol
OUTPUT_DIR=protocol-models/python/airbyte_protocol/models

python -m pip install --upgrade pip
pip install datamodel_code_generator==0.11.19

rm -rf "$ROOT_DIR/$OUTPUT_DIR"/*.py
mkdir -p "$ROOT_DIR/$OUTPUT_DIR"

echo "# generated by generate-python-classes" > "$ROOT_DIR/$OUTPUT_DIR"/__init__.py
echo "name = 'models'" >> "$ROOT_DIR/$OUTPUT_DIR"/__init__.py

for f in "$ROOT_DIR/$YAML_DIR"/*.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" \
--output "$ROOT_DIR/$OUTPUT_DIR/$filename_wo_ext.py" \
--use-title-as-name \
--disable-timestamp
done

0 comments on commit 10fe3b3

Please sign in to comment.