From 6be89ed8467a3b9dc18904e9329c8844e952b25c Mon Sep 17 00:00:00 2001 From: MANKARNI <45879275+MANKARNI@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:23:11 +0530 Subject: [PATCH 01/11] Add or update the Azure App Service build and deployment workflow config --- .github/workflows/main_waflask.yml | 78 ++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/main_waflask.yml diff --git a/.github/workflows/main_waflask.yml b/.github/workflows/main_waflask.yml new file mode 100644 index 000000000..f5e99e4dd --- /dev/null +++ b/.github/workflows/main_waflask.yml @@ -0,0 +1,78 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions +# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions + +name: Build and deploy Python app to Azure Web App - WAFlask + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python version + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Create and start virtual environment + run: | + python -m venv venv + source venv/bin/activate + + - name: Install dependencies + run: pip install -r requirements.txt + + # Optional: Add step to run tests here (PyTest, Django test suites, etc.) + + - name: Zip artifact for deployment + run: zip release.zip ./* -r + + - name: Upload artifact for deployment jobs + uses: actions/upload-artifact@v4 + with: + name: python-app + path: | + release.zip + !venv/ + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + permissions: + id-token: write #This is required for requesting the JWT + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: python-app + + - name: Unzip artifact for deployment + run: unzip release.zip + + + - name: Login to Azure + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_BE6386CC4B264459A12A3106085FB550 }} + tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_355BA6A6F341456999E45B56471DF620 }} + subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_4774091AF4C54216A24B6128302B9B3A }} + + - name: 'Deploy to Azure Web App' + uses: azure/webapps-deploy@v3 + id: deploy-to-webapp + with: + app-name: 'WAFlask' + slot-name: 'Production' + \ No newline at end of file From 84dd1fc697fd364d44c4721a3f62c97cdbc9590b Mon Sep 17 00:00:00 2001 From: MANKARNI <45879275+MANKARNI@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:54:54 +0530 Subject: [PATCH 02/11] Create index2.html --- templates/index2.html | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 templates/index2.html diff --git a/templates/index2.html b/templates/index2.html new file mode 100644 index 000000000..91071d90f --- /dev/null +++ b/templates/index2.html @@ -0,0 +1,30 @@ + + + Hello Azure - Python Quickstart + + + + + +
+
+ Azure Logo + +

Welcome to Azure

+
+
+
+ + + +
+ +
+
+ +
+
+
+
+ + From 420d478427597b9f690c4604cf9a5088cfa34d8b Mon Sep 17 00:00:00 2001 From: MANKARNI <45879275+MANKARNI@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:56:34 +0530 Subject: [PATCH 03/11] Update index.html --- templates/index.html | 169 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 140 insertions(+), 29 deletions(-) diff --git a/templates/index.html b/templates/index.html index 9cdba30cd..404cf2ca3 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,30 +1,141 @@ - - - Hello Azure - Python Quickstart - - - - - -
-
- Azure Logo - -

Welcome to Azure

-
-
-
- + + + + + + ETL Convy + + + +
+

ETL Convy

+

Service to Convert Informatical ETL Files to Azure Data Factory Template

+
+
+

Upload XML File

+ + + +
+ + +
+ © 2023 ETL Convy +
+
+ + + + From b6b059f6a5e5f8138f0236503c75712ac5b57d5b Mon Sep 17 00:00:00 2001 From: MANKARNI <45879275+MANKARNI@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:58:32 +0530 Subject: [PATCH 04/11] Create app_bk.py --- app_bk.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app_bk.py diff --git a/app_bk.py b/app_bk.py new file mode 100644 index 000000000..3d1808cf6 --- /dev/null +++ b/app_bk.py @@ -0,0 +1,32 @@ +import os + +from flask import (Flask, redirect, render_template, request, + send_from_directory, url_for) + +app = Flask(__name__) + + +@app.route('/') +def index(): + print('Request for index page received') + return render_template('index.html') + +@app.route('/favicon.ico') +def favicon(): + return send_from_directory(os.path.join(app.root_path, 'static'), + 'favicon.ico', mimetype='image/vnd.microsoft.icon') + +@app.route('/hello', methods=['POST']) +def hello(): + name = request.form.get('name') + + if name: + print('Request for hello page received with name=%s' % name) + return render_template('hello.html', name = name) + else: + print('Request for hello page received with no name or blank name -- redirecting') + return redirect(url_for('index')) + + +if __name__ == '__main__': + app.run() From 5ce35fbce72eb150742a0551830d5943f15cac7e Mon Sep 17 00:00:00 2001 From: MANKARNI <45879275+MANKARNI@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:00:00 +0530 Subject: [PATCH 05/11] Create styles.css --- templates/styles.css | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 templates/styles.css diff --git a/templates/styles.css b/templates/styles.css new file mode 100644 index 000000000..4e7fc9866 --- /dev/null +++ b/templates/styles.css @@ -0,0 +1,21 @@ +* { + font-family: Arial, Helvetica, sans-serif; + } + + html, body { + margin: 0; + border: 0; + padding: 0; + background-color: #fff; + } + + main { + margin: auto; + width: 50%; + padding: 20px; + } + + main > h1 { + text-align: center; + font-size: 3.5em; + } From bf0843376e7b8f176a478d5a4e7c0da51825170d Mon Sep 17 00:00:00 2001 From: MANKARNI <45879275+MANKARNI@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:41:26 +0530 Subject: [PATCH 06/11] Update app.py --- app.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 3d1808cf6..7ea2606e5 100644 --- a/app.py +++ b/app.py @@ -1,7 +1,9 @@ import os from flask import (Flask, redirect, render_template, request, - send_from_directory, url_for) + send_from_directory, url_for, jsonify, send_file) +import json +import azure_oai_connector app = Flask(__name__) @@ -9,7 +11,35 @@ @app.route('/') def index(): print('Request for index page received') - return render_template('index.html') + return render_template('index.html') # Render index page + +@app.route('/uploads', methods=['POST']) +def process_xml(): + try: + xml_file = request.files['file'] + xml_content = xml_file.read() # Read the XML content + + # Call Azure OAI and process the response + # (Replace this with your actual logic) + # For demonstration purposes, we'll return a dummy response + azure_oai_response = azure_oai_connector.process_xml_data(xml_content) + + print("response") + print(azure_oai_response) + + # Save the response as a JSON file (optional) + with open('azure_oai_response.json', 'w') as json_file: + json.dump(azure_oai_response, json_file, indent=4) + + # Inside your process_xml route + return jsonify({'message': 'Processing successful. Download the JSON file:', 'file_link': '/download/response.json'}), 200 + + except Exception as e: + return jsonify({'error': str(e)}), 500 + +@app.route('/download/response.json') +def download_response(): + return send_file('azure_oai_response.json', as_attachment=True) @app.route('/favicon.ico') def favicon(): From cb9719a7006bcb8d80b613399244f3b0a7355650 Mon Sep 17 00:00:00 2001 From: MANKARNI <45879275+MANKARNI@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:43:21 +0530 Subject: [PATCH 07/11] Create azure_oai_connector.py --- azure_oai_connector.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 azure_oai_connector.py diff --git a/azure_oai_connector.py b/azure_oai_connector.py new file mode 100644 index 000000000..578f1aed0 --- /dev/null +++ b/azure_oai_connector.py @@ -0,0 +1,37 @@ +import os + +from promptflow.core import Prompty, AzureOpenAIModelConfiguration + +AZURE_OPENAI_ENDPOINT="https://aoai-etl.openai.azure.com/" +AZURE_OPENAI_CHAT_DEPLOYMENT="Trial4o" +AZURE_OPENAI_API_KEY="c81b1674d1f84cccbbd858fa136f6405" +AZURE_OPENAI_API_VERSION="2024-02-15-preview" + +model_config = AzureOpenAIModelConfiguration( + azure_deployment=AZURE_OPENAI_CHAT_DEPLOYMENT, + api_key=AZURE_OPENAI_API_KEY, + api_version=AZURE_OPENAI_API_VERSION, + azure_endpoint=AZURE_OPENAI_ENDPOINT +) + +prompty = Prompty.load("chat.prompty", model={'configuration': model_config}) + +# in_file_object = open("m_Sample_Hackathon.xml", "r+") +# input_xml = in_file_object.read() + +#print(result) + +# oai_connector.py +def process_xml_data(xml_data): + print("In aoi connector") + # response = prompty( + # # chat_history=[ + # # {"role": "user", "content": "Does Azure OpenAI support customer managed keys?"}, + # # {"role": "assistant", "content": "Yes, customer managed keys are supported by Azure OpenAI."} + # # ], + # chat_input=xml_data) + + # Code to send XML data to Azure OpenAI and return the response + ... + response = {'message': 'response from Azure OAI json response'} + return response From fd49d910ccda942daf80c68b235bdd818207e335 Mon Sep 17 00:00:00 2001 From: MANKARNI <45879275+MANKARNI@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:44:28 +0530 Subject: [PATCH 08/11] Create chat.prompty --- chat.prompty | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 chat.prompty diff --git a/chat.prompty b/chat.prompty new file mode 100644 index 000000000..70eb794a9 --- /dev/null +++ b/chat.prompty @@ -0,0 +1,33 @@ +--- +name: Chat Prompt +description: A basic prompt that uses the chat API to answer questions +model: + api: chat + configuration: + type: azure_openai + parameters: + max_tokens: 256 + temperature: 0.2 +inputs: + chat_input: + type: string + chat_history: + type: list + is_chat_history: true + default: [] +outputs: + response: + type: string +sample: + chat_input: What is the meaning of life? +--- +system: +You are an AI assistant who can convert Informatica XML template file to Azure Data Factory (ADF) pipeline JSON file including all field based transformations, source and target mappings. + +{% for item in history %} +{{item.role}}: +{{item.content}} +{% endfor %} + +user: +{{chat_input}} From ce0b90a0a4885fac08b126dbc86ac0fc100a3ce5 Mon Sep 17 00:00:00 2001 From: MANKARNI <45879275+MANKARNI@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:46:48 +0530 Subject: [PATCH 09/11] Update requirements.txt --- requirements.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/requirements.txt b/requirements.txt index c785af01f..4085d55d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,9 @@ Flask==2.2.2 gunicorn Werkzeug==2.2.2 +promptflow==1.14.0 +promptflow-core==1.14.0 +promptflow-devkit==1.14.0 +promptflow-tracing==1.14.0 +jsonschema==4.23.0 +jsonschema-specifications==2023.12.1 From c5d3401117adbf3ce1fee466039ab776155ffb3b Mon Sep 17 00:00:00 2001 From: MANKARNI <45879275+MANKARNI@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:55:38 +0530 Subject: [PATCH 10/11] Update requirements.txt --- requirements.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4085d55d3..493910df1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,6 @@ -Flask==2.2.2 +Flask==3.0.3 +Flask-Cors==4.0.1 +flask-restx==1.3.0 gunicorn Werkzeug==2.2.2 promptflow==1.14.0 From 8e80cd65402e635a2a990e47b8899766e4e468e1 Mon Sep 17 00:00:00 2001 From: MANKARNI <45879275+MANKARNI@users.noreply.github.com> Date: Thu, 8 Aug 2024 18:57:45 +0530 Subject: [PATCH 11/11] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 493910df1..4ca681a20 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ Flask==3.0.3 Flask-Cors==4.0.1 flask-restx==1.3.0 gunicorn -Werkzeug==2.2.2 +Werkzeug promptflow==1.14.0 promptflow-core==1.14.0 promptflow-devkit==1.14.0