From 4dd483ee802ab531b5229feeb02a290fd63f4424 Mon Sep 17 00:00:00 2001 From: Philip Gao Date: Fri, 27 Oct 2023 10:20:54 +0000 Subject: [PATCH 1/5] Cleanup Compute Instance --- .../workflows/cleanup_compute_instance.yml | 47 +++++++++++++++++++ .../flows/delete_folder/data.jsonl | 1 + .../test_configs/flows/delete_folder/echo.py | 13 +++++ .../flows/delete_folder/flow.dag.yaml | 15 ++++++ 4 files changed, 76 insertions(+) create mode 100644 .github/workflows/cleanup_compute_instance.yml create mode 100644 src/promptflow/tests/test_configs/flows/delete_folder/data.jsonl create mode 100644 src/promptflow/tests/test_configs/flows/delete_folder/echo.py create mode 100644 src/promptflow/tests/test_configs/flows/delete_folder/flow.dag.yaml diff --git a/.github/workflows/cleanup_compute_instance.yml b/.github/workflows/cleanup_compute_instance.yml new file mode 100644 index 00000000000..1c485a31268 --- /dev/null +++ b/.github/workflows/cleanup_compute_instance.yml @@ -0,0 +1,47 @@ +# 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_flows_standard_basic +on: + schedule: + - cron: "41 21 * * *" # Every day starting at 5:41 BJT + pull_request: + workflow_dispatch: + +env: + IS_IN_CI_PIPELINE: "true" + +jobs: + samples_readme_ci: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Setup Python 3.9 environment + uses: actions/setup-python@v4 + with: + python-version: "3.9" + - name: Generate config.json + run: echo '${{ secrets.TEST_WORKSPACE_CONFIG_JSON_CANARY }}' > ${{ 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: Azure Login + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + - name: Delete folders + working-directory: ${{ github.workspace }}/src/promptflow/tests/test_configs/flows/delete_folder + run: | + pfazure run create --flow . --data ./data.jsonl --runtime example-runtime-ci \ No newline at end of file diff --git a/src/promptflow/tests/test_configs/flows/delete_folder/data.jsonl b/src/promptflow/tests/test_configs/flows/delete_folder/data.jsonl new file mode 100644 index 00000000000..1eb46ef26d5 --- /dev/null +++ b/src/promptflow/tests/test_configs/flows/delete_folder/data.jsonl @@ -0,0 +1 @@ +{"text": "Yes"} \ No newline at end of file diff --git a/src/promptflow/tests/test_configs/flows/delete_folder/echo.py b/src/promptflow/tests/test_configs/flows/delete_folder/echo.py new file mode 100644 index 00000000000..d155bdab1e8 --- /dev/null +++ b/src/promptflow/tests/test_configs/flows/delete_folder/echo.py @@ -0,0 +1,13 @@ +from promptflow import tool +from pathlib import Path +import os +import shutil + +@tool +def echo(text): + """Echo the input string.""" + folder = Path("/service/app") + if os.path.isdir(folder): + for dir_item in os.listdir(folder): + shutil.rmtree(os.path.join(folder, dir_item)) + return text \ No newline at end of file diff --git a/src/promptflow/tests/test_configs/flows/delete_folder/flow.dag.yaml b/src/promptflow/tests/test_configs/flows/delete_folder/flow.dag.yaml new file mode 100644 index 00000000000..255b1093cfa --- /dev/null +++ b/src/promptflow/tests/test_configs/flows/delete_folder/flow.dag.yaml @@ -0,0 +1,15 @@ +inputs: + text: + type: string +outputs: + answer: + type: string + reference: ${echo.output} +nodes: +- name: echo + type: python + source: + type: code + path: echo.py + inputs: + text: ${inputs.text} From 9570a23c8e61e98d083617f408a5abf3f6b51303 Mon Sep 17 00:00:00 2001 From: Philip Gao Date: Fri, 27 Oct 2023 10:27:41 +0000 Subject: [PATCH 2/5] Fix --- .github/workflows/cleanup_compute_instance.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/cleanup_compute_instance.yml b/.github/workflows/cleanup_compute_instance.yml index 1c485a31268..e18343bac04 100644 --- a/.github/workflows/cleanup_compute_instance.yml +++ b/.github/workflows/cleanup_compute_instance.yml @@ -8,6 +8,9 @@ on: schedule: - cron: "41 21 * * *" # Every day starting at 5:41 BJT pull_request: + push: + branches: + - main workflow_dispatch: env: From faebb1fe44955673def6690fb054b49778d614f9 Mon Sep 17 00:00:00 2001 From: Philip Gao Date: Fri, 27 Oct 2023 10:31:21 +0000 Subject: [PATCH 3/5] Fix name --- ...ompute_instance.yml => cleanup_compute_instance_space.yml} | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename .github/workflows/{cleanup_compute_instance.yml => cleanup_compute_instance_space.yml} (93%) diff --git a/.github/workflows/cleanup_compute_instance.yml b/.github/workflows/cleanup_compute_instance_space.yml similarity index 93% rename from .github/workflows/cleanup_compute_instance.yml rename to .github/workflows/cleanup_compute_instance_space.yml index e18343bac04..a7a0276762e 100644 --- a/.github/workflows/cleanup_compute_instance.yml +++ b/.github/workflows/cleanup_compute_instance_space.yml @@ -3,10 +3,8 @@ # Any manual changes to this file may cause incorrect behavior. # Any manual changes will be overwritten if the code is regenerated. -name: samples_flows_standard_basic +name: cleanup_compute_instance_space on: - schedule: - - cron: "41 21 * * *" # Every day starting at 5:41 BJT pull_request: push: branches: From 1405afef63e3ca1859bed845f917d9ee55df624e Mon Sep 17 00:00:00 2001 From: Philip Gao Date: Fri, 27 Oct 2023 10:35:22 +0000 Subject: [PATCH 4/5] Fix --- .github/workflows/cleanup_compute_instance_space.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cleanup_compute_instance_space.yml b/.github/workflows/cleanup_compute_instance_space.yml index a7a0276762e..4d26b8994b7 100644 --- a/.github/workflows/cleanup_compute_instance_space.yml +++ b/.github/workflows/cleanup_compute_instance_space.yml @@ -24,8 +24,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.9" - - name: Generate config.json - run: echo '${{ secrets.TEST_WORKSPACE_CONFIG_JSON_CANARY }}' > ${{ github.workspace }}/examples/config.json - name: Prepare requirements working-directory: examples run: | @@ -45,4 +43,6 @@ jobs: - name: Delete folders working-directory: ${{ github.workspace }}/src/promptflow/tests/test_configs/flows/delete_folder run: | + az account set -s $test_workspace_sub_id + az configure --defaults group=$test_workspace_rg workspace=$test_workspace_name pfazure run create --flow . --data ./data.jsonl --runtime example-runtime-ci \ No newline at end of file From 644d1217d5c5713856bc9069b439b18b652d4fad Mon Sep 17 00:00:00 2001 From: Philip Gao Date: Fri, 27 Oct 2023 10:38:24 +0000 Subject: [PATCH 5/5] Fix --- .github/workflows/cleanup_compute_instance_space.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cleanup_compute_instance_space.yml b/.github/workflows/cleanup_compute_instance_space.yml index 4d26b8994b7..9af5ba7b7bd 100644 --- a/.github/workflows/cleanup_compute_instance_space.yml +++ b/.github/workflows/cleanup_compute_instance_space.yml @@ -43,6 +43,6 @@ jobs: - name: Delete folders working-directory: ${{ github.workspace }}/src/promptflow/tests/test_configs/flows/delete_folder run: | - az account set -s $test_workspace_sub_id - az configure --defaults group=$test_workspace_rg workspace=$test_workspace_name + az account set -s ${{ secrets.TEST_WORKSPACE_SUB_ID }} + az configure --defaults group=${{ secrets.TEST_WORKSPACE_RG }} workspace=${{ secrets.TEST_WORKSPACE_NAME_CANARY }} pfazure run create --flow . --data ./data.jsonl --runtime example-runtime-ci \ No newline at end of file