-
Notifications
You must be signed in to change notification settings - Fork 891
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into mengla/change_gpt4v_default_value
- Loading branch information
Showing
7 changed files
with
148 additions
and
19 deletions.
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 |
---|---|---|
|
@@ -154,6 +154,7 @@ | |
"restx", | ||
"httpx", | ||
"tiiuae", | ||
"nohup", | ||
"metagenai" | ||
], | ||
"flagWords": [ | ||
|
96 changes: 96 additions & 0 deletions
96
.github/workflows/samples_tutorials_flow_deploy_create_service_with_flow.yml
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,96 @@ | ||
# This code is autogenerated. | ||
# Code is generated by running custom script: python3 readme.py | ||
# Any manual changes to this file may cause incorrect behavior. | ||
# Any manual changes will be overwritten if the code is regenerated. | ||
|
||
name: samples_tutorials_flow_deploy_create_service_with_flow | ||
on: | ||
schedule: | ||
- cron: "49 22 * * *" # Every day starting at 6:49 BJT | ||
pull_request: | ||
branches: [ main ] | ||
paths: [ examples/**, .github/workflows/samples_tutorials_flow_deploy_create_service_with_flow.yml ] | ||
workflow_dispatch: | ||
|
||
env: | ||
IS_IN_CI_PIPELINE: "true" | ||
|
||
jobs: | ||
samples_readme_ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Setup Python 3.9 environment | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.9" | ||
- name: Generate config.json for canary workspace (scheduled runs only) | ||
if: github.event_name == 'schedule' | ||
run: echo '${{ secrets.TEST_WORKSPACE_CONFIG_JSON_CANARY }}' > ${{ github.workspace }}/examples/config.json | ||
- name: Generate config.json for production workspace | ||
if: github.event_name != 'schedule' | ||
run: echo '${{ secrets.EXAMPLE_WORKSPACE_CONFIG_JSON_PROD }}' > ${{ github.workspace }}/examples/config.json | ||
- name: Prepare requirements | ||
working-directory: examples | ||
run: | | ||
if [[ -e requirements.txt ]]; then | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
fi | ||
- name: Prepare dev requirements | ||
working-directory: examples | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r dev_requirements.txt | ||
- name: Refine .env file | ||
working-directory: examples/tutorials/flow-deploy/create-service-with-flow | ||
run: | | ||
AOAI_API_KEY=${{ secrets.AOAI_API_KEY_TEST }} | ||
AOAI_API_ENDPOINT=${{ secrets.AOAI_API_ENDPOINT_TEST }} | ||
AOAI_API_ENDPOINT=$(echo ${AOAI_API_ENDPOINT//\//\\/}) | ||
if [[ -e .env.example ]]; then | ||
echo "env replacement" | ||
sed -i -e "s/<your_AOAI_key>/$AOAI_API_KEY/g" -e "s/<your_AOAI_endpoint>/$AOAI_API_ENDPOINT/g" .env.example | ||
mv .env.example .env | ||
fi | ||
- name: Create run.yml | ||
working-directory: examples/tutorials/flow-deploy/create-service-with-flow | ||
run: | | ||
gpt_base=${{ secrets.AOAI_API_ENDPOINT_TEST }} | ||
gpt_base=$(echo ${gpt_base//\//\\/}) | ||
if [[ -e run.yml ]]; then | ||
sed -i -e "s/\${azure_open_ai_connection.api_key}/${{ secrets.AOAI_API_KEY_TEST }}/g" -e "s/\${azure_open_ai_connection.api_base}/$gpt_base/g" run.yml | ||
fi | ||
- name: Azure Login | ||
uses: azure/login@v1 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
- name: Extract Steps examples/tutorials/flow-deploy/create-service-with-flow/README.md | ||
working-directory: ${{ github.workspace }} | ||
run: | | ||
python scripts/readme/extract_steps_from_readme.py -f examples/tutorials/flow-deploy/create-service-with-flow/README.md -o examples/tutorials/flow-deploy/create-service-with-flow | ||
- name: Cat script | ||
working-directory: examples/tutorials/flow-deploy/create-service-with-flow | ||
run: | | ||
cat bash_script.sh | ||
- name: Run scripts | ||
working-directory: examples/tutorials/flow-deploy/create-service-with-flow | ||
run: | | ||
export aoai_api_key=${{secrets.AOAI_API_KEY_TEST }} | ||
export aoai_api_endpoint=${{ secrets.AOAI_API_ENDPOINT_TEST }} | ||
export test_workspace_sub_id=${{ secrets.TEST_WORKSPACE_SUB_ID }} | ||
export test_workspace_rg=${{ secrets.TEST_WORKSPACE_RG }} | ||
export test_workspace_name=${{ secrets.TEST_WORKSPACE_NAME_CANARY }} | ||
bash bash_script.sh | ||
- name: Pip List for Debug | ||
if : ${{ always() }} | ||
working-directory: examples/tutorials/flow-deploy/create-service-with-flow | ||
run: | | ||
pip list | ||
- name: Upload artifact | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: artifact | ||
path: examples/tutorials/flow-deploy/create-service-with-flow/bash_script.sh |
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
38 changes: 38 additions & 0 deletions
38
examples/tutorials/flow-deploy/create-service-with-flow/README.md
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,38 @@ | ||
# Create service with flow | ||
|
||
This example shows how to create a simple service with flow. | ||
|
||
You can create your own service by utilize `flow-as-function`. | ||
|
||
This folder contains a example on how to build a service with a flow. | ||
Reference [here](./simple_score.py) for a minimal service example. | ||
The output of score.py will be a json serialized dictionary. | ||
You can use json parser to parse the output. | ||
|
||
## 1. Start the service and put in background | ||
|
||
```bash | ||
nohup python simple_score.py & | ||
# Note: added this to run in our CI pipeline, not needed for user. | ||
sleep 10 | ||
``` | ||
|
||
## 2. Test the service with request | ||
|
||
Executing the following command to send a request to execute a flow. | ||
|
||
```bash | ||
curl -X POST http://127.0.0.1:5000/score --header "Content-Type: application/json" --data '{"flow_input": "some_flow_input", "node_input": "some_node_input"}' | ||
``` | ||
|
||
Sample output of the request: | ||
|
||
```json | ||
{ | ||
"output": { | ||
"value": "some_flow_input" | ||
} | ||
} | ||
``` | ||
|
||
Reference [here](./simple_score.py) for more. |
12 changes: 0 additions & 12 deletions
12
examples/tutorials/flow-deploy/create-service-with-flow/readme.md
This file was deleted.
Oops, something went wrong.
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