From 09011d42596af7ce5124f236b01b1ef402eda248 Mon Sep 17 00:00:00 2001 From: Alberto Miorin <32617+amiorin@users.noreply.github.com> Date: Tue, 21 Dec 2021 06:37:36 +0100 Subject: [PATCH] Fix #1670: Python generated code is missing when using pip install git+https (#1799) --- .github/workflows/py-generate2.yml | 43 ++++++++++++++++++++++++ ingestion-generated/Makefile | 15 +++++++++ ingestion-generated/README.md | 14 ++++++++ ingestion-generated/requirements-dev.txt | 3 ++ ingestion-generated/setup.py | 39 +++++++++++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 .github/workflows/py-generate2.yml create mode 100644 ingestion-generated/Makefile create mode 100644 ingestion-generated/README.md create mode 100644 ingestion-generated/requirements-dev.txt create mode 100644 ingestion-generated/setup.py diff --git a/.github/workflows/py-generate2.yml b/.github/workflows/py-generate2.yml new file mode 100644 index 00000000000..b569c8a3b69 --- /dev/null +++ b/.github/workflows/py-generate2.yml @@ -0,0 +1,43 @@ +# Copyright 2021 Collate +# Licensed 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. + +name: Validate Pydantic Models 2 + +on: + pull_request: + branches: + - main + paths: + - 'catalog-rest-service/src/main/resources/json/**' + +jobs: + validate: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + working-directory: ingestion-generated + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install Ubuntu related dependencies + run: | + sudo apt-get install -y libsasl2-dev unixodbc-dev python3-venv + - name: Install Python + run: | + python3 -m venv env + - name: Generate models + run: | + source env/bin/activate + make generate \ No newline at end of file diff --git a/ingestion-generated/Makefile b/ingestion-generated/Makefile new file mode 100644 index 00000000000..4778c0bf429 --- /dev/null +++ b/ingestion-generated/Makefile @@ -0,0 +1,15 @@ +generate: + mkdir -p src/metadata/generated + python3 -m pip install --upgrade pip setuptools + python3 -m pip install --upgrade -r requirements-dev.txt + datamodel-codegen --input ../catalog-rest-service/src/main/resources/json --input-file-type jsonschema --output src/metadata/generated + +clean: + rm -rf src/metadata/generated + rm -rf build + rm -rf dist + +publish: clean generate + python setup.py install sdist bdist_wheel + twine check dist/* + twine upload dist/* diff --git a/ingestion-generated/README.md b/ingestion-generated/README.md new file mode 100644 index 00000000000..27770900a5c --- /dev/null +++ b/ingestion-generated/README.md @@ -0,0 +1,14 @@ +--- +This guide will help you setup the Ingestion framework and connectors +--- + +![Python version 3.8+](https://img.shields.io/badge/python-3.8%2B-blue) + +OpenMetadata Ingesiton is a simple framework to build connectors and ingest metadata of various systems through OpenMetadata APIs. It could be used in an orchestration framework(e.g. Apache Airflow) to ingest metadata. +**Prerequisites** + +- Python >= 3.8.x + +### Docs + +Please refer to the documentation here https://docs.open-metadata.org/connectors diff --git a/ingestion-generated/requirements-dev.txt b/ingestion-generated/requirements-dev.txt new file mode 100644 index 00000000000..8e9637171a9 --- /dev/null +++ b/ingestion-generated/requirements-dev.txt @@ -0,0 +1,3 @@ +datamodel-code-generator==0.11.14 +twine +wheel \ No newline at end of file diff --git a/ingestion-generated/setup.py b/ingestion-generated/setup.py new file mode 100644 index 00000000000..d7d917629c4 --- /dev/null +++ b/ingestion-generated/setup.py @@ -0,0 +1,39 @@ +# Copyright 2021 Collate +# Licensed 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. +import os + +from setuptools import setup, find_namespace_packages + + +def get_long_description(): + root = os.path.dirname(__file__) + with open(os.path.join(root, "README.md")) as f: + description = f.read() + return description + + +setup(name="openmetadata-ingestion-generated", + version="0.5.0", + url="https://open-metadata.org/", + author="OpenMetadata Committers", + license="Apache License 2.0", + description="These are the generated Python classes from JSON Schema", + long_description=get_long_description(), + long_description_content_type="text/markdown", + python_requires=">=3.8", + package_dir={"": "src"}, + zip_safe=False, + project_urls={ + "Documentation": "https://docs.open-metadata.org/", + "Source": "https://github.com/open-metadata/OpenMetadata", + }, + packages=find_namespace_packages(where="./src", exclude=["tests*"]), + )