Skip to content

Commit

Permalink
fix codegen (airbytehq#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-tricot authored Oct 18, 2020
1 parent 58999ff commit 4baf326
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
from .airbyte_catalog import AirbyteStream
from .airbyte_catalog import AirbyteCatalog
from .airbyte_connection_status import AirbyteConnectionStatus
from .airbyte_message import AirbyteMessage
from .airbyte_message import AirbyteLogMessage
from .airbyte_message import AirbyteRecordMessage
from .airbyte_message import AirbyteStateMessage
from .airbyte_type import AirbyteType
# generated by generate-protocol-files
from .airbyte_message import *

This file was deleted.

This file was deleted.

This file was deleted.

25 changes: 17 additions & 8 deletions airbyte-integrations/base-python/bin/generate-protocol-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@

set -e

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

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

FILES=$(cd ../../$YAML_DIR; ls -1 | grep yaml)
for f in $FILES
do
FILE_WITHOUT_EXTENSION=""$(echo -n $f | cut -d'.' -f 1)
docker run -v "$(pwd)"/../..:/airbyte airbyte/code-generator:dev \
--input airbyte/"$YAML_DIR"/"$FILE_WITHOUT_EXTENSION".yaml \
--output airbyte/"$OUTPUT_DIR"/"$FILE_WITHOUT_EXTENSION".py \
--disable-timestamp
function main() {
rm -rf "$ROOT_DIR/$OUTPUT_DIR"/*.py
echo "# generated by generate-protocol-files" > "$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

docker run -v "$ROOT_DIR":/airbyte airbyte/code-generator:dev \
--input "/airbyte/$YAML_DIR/$filename_wo_ext.yaml" \
--output "/airbyte/$OUTPUT_DIR/$filename_wo_ext.py" \
--disable-timestamp
done
}

main "$@"
5 changes: 3 additions & 2 deletions airbyte-integrations/base-python/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
apply from: rootProject.file('tools/gradle/commons/integrations/image.gradle')

task generateProtocolClassFiles(type: Exec) {
workingDir '.'
environment 'ROOT_DIR', rootDir.absolutePath
commandLine 'bin/generate-protocol-files.sh'
dependsOn ':airbyte-integrations:base-python:code-generator:buildImage'

outputs.upToDateWhen { false }
dependsOn ':airbyte-integrations:base-python:code-generator:buildImage'
}

build.dependsOn generateProtocolClassFiles
Expand Down

0 comments on commit 4baf326

Please sign in to comment.