-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f57239
commit 10fe3b3
Showing
4 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |