pierrejeambrun commented on code in PR #31253: URL: https://github.com/apache/airflow/pull/31253#discussion_r1199805003
########## clients/gen/python-nextgen.sh: ########## @@ -0,0 +1,65 @@ +#!/bin/bash +set -ueo pipefail +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +CLIENTS_GEN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +readonly CLIENTS_GEN_DIR + +CLEANUP_DIRS=(client docs test README.md) +readonly CLEANUP_DIRS + +# shellcheck source=./clients/gen/common.sh +source "${CLIENTS_GEN_DIR}/common.sh" + +VERSION=2.6.0 +readonly VERSION + +python_config=( + "packageVersion=${VERSION}" +) + +validate_input "$@" + +gen_client python-nextgen \ + --package-name client \ + --git-repo-id airflow-client-python-nextgen \ + --additional-properties "${python_config[*]}" + +echo "--- Patching generated code..." + +# Post-processing of the generated Python wrapper. + +INPLACE_ARG=("-i") +if [[ "$OSTYPE" == "darwin"* ]]; then + INPLACE_ARG=(-i '') +fi + +touch "${OUTPUT_DIR}/__init__.py" +find "${OUTPUT_DIR}/test" -type f -name \*.py -exec sed "${INPLACE_ARG[@]}" -e 's/client/airflow_client.client/g' {} + +find "${OUTPUT_DIR}" -type f -a -name \*.md -exec sed "${INPLACE_ARG[@]}" -e 's/# client/# Apache Airflow Python Client/g' {} + +find "${OUTPUT_DIR}" -type f -a -name \*.md -exec sed "${INPLACE_ARG[@]}" -e 's/import client/import airflow_client.client/g' {} + +find "${OUTPUT_DIR}" -type f -a -name \*.md -exec sed "${INPLACE_ARG[@]}" -e 's/from client/from airflow_client.client/g' {} + +find "${OUTPUT_DIR}" -type f -a -name \*.md -exec sed "${INPLACE_ARG[@]}" -e 's/getattr(client\.models/getattr(airflow_client.client.models/g' {} + + +# fix imports +find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed "${INPLACE_ARG[@]}" -e 's/import client\./import airflow_client.client./g' {} + +find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed "${INPLACE_ARG[@]}" -e 's/from client/from airflow_client.client/g' {} + +find "${OUTPUT_DIR}/client/" -type f -name \*.py -exec sed "${INPLACE_ARG[@]}" -e 's/getattr(client\.models/getattr(airflow_client.client.models/g' {} + Review Comment: I think we do because the file structure is a little bit different from the 'default' behavior. Can you try generating the client without it and running a few requests, to confirm if this is necessary ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
