diff --git a/.azure-pipelines/platform_ci_dev_pipeline.yml b/.azure-pipelines/platform_ci_dev_pipeline.yml index 715390cad..78d822308 100644 --- a/.azure-pipelines/platform_ci_dev_pipeline.yml +++ b/.azure-pipelines/platform_ci_dev_pipeline.yml @@ -154,7 +154,23 @@ stages: replace@youremail.com instructions: "$(run_id_from_submit_job)" onTimeout: 'reject' - + + #===================================== + # Publish the flow in promptflow blade + #===================================== + - job: publish_flow + dependsOn: + - ApproveDeployment + steps: + - template: templates/get_connection_details.yml + - template: templates/configure_azureml_agent.yml + - template: templates/publish_prompt_flow.yml + parameters: + SUBSCRIPTION_ID: $(SUBSCRIPTION_ID) + flow_to_execute: ${{ parameters.flow_to_execute }} + DEPLOY_ENVIRONMENT: ${{ parameters.exec_environment }} + BUILD_ID: $(Build.Buildid) + - job: deploy_flow dependsOn: - ApproveDeployment diff --git a/.azure-pipelines/templates/publish_prompt_flow.yml b/.azure-pipelines/templates/publish_prompt_flow.yml new file mode 100644 index 000000000..3871d3877 --- /dev/null +++ b/.azure-pipelines/templates/publish_prompt_flow.yml @@ -0,0 +1,39 @@ +parameters: +- name: SUBSCRIPTION_ID + type: string +- name: flow_to_execute + type: string +- name: DEPLOY_ENVIRONMENT + type: string +- name: BUILD_ID + type: string + +steps: +- task: AzureCLI@2 + displayName: Publish Prompt Flow + continueOnError: false + inputs: + azureSubscription: $(AZURE_RM_SVC_CONNECTION) + scriptType: bash + workingDirectory: $(System.DefaultWorkingDirectory) + scriptLocation: inlineScript + inlineScript: | + config_path="./${{ parameters.flow_to_execute }}/llmops_config.json" + env_name=${{ parameters.DEPLOY_ENVIRONMENT }} + selected_object=$(jq ".envs[] | select(.ENV_NAME == \"$env_name\")" "$config_path") + if [[ -n "$selected_object" ]]; then + echo "$selected_object" + RESOURCE_GROUP_NAME=$(echo "$selected_object" | jq -r '.RESOURCE_GROUP_NAME') + WORKSPACE_NAME=$(echo "$selected_object" | jq -r '.WORKSPACE_NAME') + STANDARD_FLOW_PATH=$(echo "$selected_object" | jq -r '.STANDARD_FLOW_PATH') + EVALUATION_FLOW_PATH=$(echo "$selected_object" | jq -r '.EVALUATION_FLOW_PATH') + FLOW_TYPE=chat + else + echo "Object in config file not found" + fi + echo "Publishing standard flow..." + pfazure flow create --flow ./${{ parameters.flow_to_execute }}/$STANDARD_FLOW_PATH --set display_name=${{ parameters.flow_to_execute }}_standard:${{ parameters.BUILD_ID }} --set type=chat --subscription ${{ parameters.SUBSCRIPTION_ID }} --resource-group $RESOURCE_GROUP_NAME --workspace-name $WORKSPACE_NAME + if [[ -n "$EVALUATION_FLOW_PATH" ]]; then + echo "Publishing evaluation flow..." + pfazure flow create --flow ./${{ parameters.flow_to_execute }}/$EVALUATION_FLOW_PATH --set display_name=${{ parameters.flow_to_execute }}_evaluation:${{ parameters.BUILD_ID }} --set type=evaluation --subscription ${{ parameters.SUBSCRIPTION_ID }} --resource-group $RESOURCE_GROUP_NAME --workspace-name $WORKSPACE_NAME + fi