diff --git a/examples/flows/chat/chat-with-pdf/README.md b/examples/flows/chat/chat-with-pdf/README.md index 6f4b7acc79f..306f85c0f1b 100644 --- a/examples/flows/chat/chat-with-pdf/README.md +++ b/examples/flows/chat/chat-with-pdf/README.md @@ -31,6 +31,8 @@ fi ### CLI Example +#### Run flow + ```bash # test with default input value in flow.dag.yaml pf flow test --flow . @@ -47,3 +49,21 @@ pf run create --flow . --data ./data/bert-paper-qna-3-line.jsonl --stream --colu # visualize run output details pf run visualize --name $run_name ``` + +#### Submit run to cloud + +Assume we already have a connection named `open_ai_connection` in workspace. + +```bash +# set default workspace +az account set -s +az configure --defaults group= workspace= +``` + +``` bash +# create run +pfazure run create --flow . --data ./data/bert-paper-qna-3-line.jsonl --stream --column-mapping question='${data.question}' pdf_url='${data.pdf_url}' chat_history='${data.chat_history}' config='{ \"EMBEDDING_MODEL_DEPLOYMENT_NAME\": \"text-embedding-ada-002\", \"CHAT_MODEL_DEPLOYMENT_NAME\": \"gpt-35-turbo\", \"PROMPT_TOKEN_LIMIT\": \"2000\", \"MAX_COMPLETION_TOKENS\": \"256\", \"VERBOSE\": \"True\", \"CHUNK_SIZE\": \"256\", \"CHUNK_OVERLAP\": \"32\" }' --name $run_name --runtime chat_with_pdf_runtime +# pfazure run create --flow . --data ./data/bert-paper-qna-3-line.jsonl --stream --column-mapping question='${data.question}' pdf_url='${data.pdf_url}' chat_history='${data.chat_history}' config='{ \"EMBEDDING_MODEL_DEPLOYMENT_NAME\": \"text-embedding-ada-002\", \"CHAT_MODEL_DEPLOYMENT_NAME\": \"gpt-35-turbo\", \"PROMPT_TOKEN_LIMIT\": \"2000\", \"MAX_COMPLETION_TOKENS\": \"256\", \"VERBOSE\": \"True\", \"CHUNK_SIZE\": \"256\", \"CHUNK_OVERLAP\": \"32\" }' --name $run_name # automatic runtime +``` + +Note: Click portal_url of the run to view the final snapshot. diff --git a/examples/flows/chat/chat-with-pdf/chat-with-pdf-azure.ipynb b/examples/flows/chat/chat-with-pdf/chat-with-pdf-azure.ipynb index 29094def1ab..479f2e6bcec 100644 --- a/examples/flows/chat/chat-with-pdf/chat-with-pdf-azure.ipynb +++ b/examples/flows/chat/chat-with-pdf/chat-with-pdf-azure.ipynb @@ -65,7 +65,7 @@ "# Get a handle to workspace\n", "pf = azure.PFClient.from_config(credential=credential)\n", "runtime = \"chat_with_pdf_runtime\" # TODO add guide to create runtime\n", - "# runtime = None # serverless" + "# runtime = None # automatic runtime" ] }, { diff --git a/examples/flows/chat/chat-with-pdf/flow.dag.yaml b/examples/flows/chat/chat-with-pdf/flow.dag.yaml index 2fc490edad7..778a0d1ed30 100644 --- a/examples/flows/chat/chat-with-pdf/flow.dag.yaml +++ b/examples/flows/chat/chat-with-pdf/flow.dag.yaml @@ -77,3 +77,5 @@ nodes: question: ${inputs.question} history: ${inputs.chat_history} env_ready_signal: ${setup_env.output} +environment: + python_requirements_txt: requirements.txt diff --git a/examples/flows/chat/chat-with-pdf/tests/azure_chat_with_pdf_test.py b/examples/flows/chat/chat-with-pdf/tests/azure_chat_with_pdf_test.py index 64f91ecc68b..be836c6f90a 100644 --- a/examples/flows/chat/chat-with-pdf/tests/azure_chat_with_pdf_test.py +++ b/examples/flows/chat/chat-with-pdf/tests/azure_chat_with_pdf_test.py @@ -22,7 +22,7 @@ def setUp(self): self.pf = azure.PFClient.from_config(credential=credential) self.runtime = "chat_with_pdf_runtime" - # self.runtime = None # serverless + # self.runtime = None # automatic runtime def tearDown(self) -> None: return super().tearDown() diff --git a/examples/flows/standard/flow-with-additional-includes/README.md b/examples/flows/standard/flow-with-additional-includes/README.md index bf162d722fb..e49ce95438b 100644 --- a/examples/flows/standard/flow-with-additional-includes/README.md +++ b/examples/flows/standard/flow-with-additional-includes/README.md @@ -63,12 +63,20 @@ pf run create --file run.yml --stream #### Submit run to cloud +Assume we already have a connection named `open_ai_connection` in workspace. + +```bash +# set default workspace +az account set -s +az configure --defaults group= workspace= +``` + ``` bash # create run -# pfazure run create --flow . --data ./data.jsonl --stream --runtime demo-mir --subscription -g -w -# pfazure run create --flow . --data ./data.jsonl --stream # serverless compute -# pfazure run create --file run.yml --runtime demo-mir -# pfazure run create --file run.yml --stream # serverless compute +pfazure run create --flow . --data ./data.jsonl --stream --runtime demo-mir +# pfazure run create --flow . --data ./data.jsonl --stream # automatic runtime +pfazure run create --file run.yml --runtime demo-mir +# pfazure run create --file run.yml --stream # automatic runtime ``` -Note: Click portal_url of the run to view the final snapshot. \ No newline at end of file +Note: Click portal_url of the run to view the final snapshot. diff --git a/examples/flows/standard/flow-with-symlinks/README.md b/examples/flows/standard/flow-with-symlinks/README.md index 3471ffdc5b8..187191e8798 100644 --- a/examples/flows/standard/flow-with-symlinks/README.md +++ b/examples/flows/standard/flow-with-symlinks/README.md @@ -76,12 +76,12 @@ pf run create --file run.yml --stream ``` bash # create run pfazure run create --flow . --data ./data.jsonl --stream --runtime demo-mir --subscription -g -w -# pfazure run create --flow . --data ./data.jsonl --stream # serverless compute +# pfazure run create --flow . --data ./data.jsonl --stream # automatic runtime # set default workspace az account set -s az configure --defaults group= workspace= pfazure run create --file run.yml --runtime demo-mir --stream -# pfazure run create --file run.yml --stream # serverless compute +# pfazure run create --file run.yml --stream # automatic runtime ``` diff --git a/examples/flows/standard/web-classification/README.md b/examples/flows/standard/web-classification/README.md index 203730a4e75..a19fed957c6 100644 --- a/examples/flows/standard/web-classification/README.md +++ b/examples/flows/standard/web-classification/README.md @@ -96,15 +96,15 @@ az account set -s az configure --defaults group= workspace= # create run -pfazure run create --flow . --data ./data.jsonl --stream --runtime demo-mir --subscription -g -w -# pfazure run create --flow . --data ./data.jsonl --stream # serverless compute +pfazure run create --flow . --data ./data.jsonl --stream --runtime demo-mir +# pfazure run create --flow . --data ./data.jsonl --stream # automatic runtime # (Optional) create a new random run name for further use run_name="web_classification_"$(openssl rand -hex 12) # create run using yaml file, --name is optional pfazure run create --file run.yml --runtime demo-mir --name $run_name -# pfazure run create --file run.yml --stream --name $run_name # serverless compute +# pfazure run create --file run.yml --stream --name $run_name # automatic runtime pfazure run stream --name $run_name diff --git a/examples/tutorials/run-management/cloud-run-management.ipynb b/examples/tutorials/run-management/cloud-run-management.ipynb index 3b0d88057fe..bd21cbc2d13 100644 --- a/examples/tutorials/run-management/cloud-run-management.ipynb +++ b/examples/tutorials/run-management/cloud-run-management.ipynb @@ -18,7 +18,7 @@ "- create run which references another runs inputs\n", "- manage runs via run.yaml\n", "- create run with connection override\n", - "- serverless runtime\n", + "- automatic runtime\n", "\n", "\n", "**Motivations** - This guide will walk you through cloud run management abilities." @@ -310,6 +310,53 @@ "\n", "pf.runs.stream(base_run)" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 4 Create a flow run with uses automatic runtime\n", + "\n", + "If you don't want to create your own runtime, you can leave the `runtime` field empty to use system automatic created runtime.\n", + "To customize base image or python packages, you can add the following config in your `flow.dag.yaml`:\n", + "\n", + "```yml\n", + "environment:\n", + " image: python:3.8-slim\n", + " python_requirements_txt: requirements.txt\n", + "```\n", + "\n", + "You can also change instance type or idle time of the automatic runtime or reset the automatic runtime to clean state.\n", + "The following code cell shows how to do so." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# create run\n", + "run = Run(\n", + " # local flow file\n", + " flow=\"../../flows/standard/web-classification\",\n", + " # remote data\n", + " data=data_id,\n", + " # to customize automatic runtime instance type and idle time, you can provide them in resources\n", + " # resources={\n", + " # \"instance_type\": \"STANDARD_DS11_V2\",\n", + " # \"idle_time_before_shutdown_minutes\": 10\n", + " # }\n", + ")\n", + "\n", + "base_run = pf.runs.create_or_update(\n", + " run=run,\n", + " # leave runtime None to use automatic runtime\n", + " runtime=None,\n", + " # to reset automatic runtime to clean state, set reset_runtime to True\n", + " # reset_runtime=True,\n", + ")" + ] } ], "metadata": {