-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup-environment.sh
63 lines (49 loc) · 2.62 KB
/
setup-environment.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
source ./scripts/functions.sh
# The usage function to display script usage
usage() {
echo "Usage: $0 [--deploymentName <deploymentName>] [--location <location>] [--skipInfrastructure]" >&2
echo "Options:" >&2
echo " --deploymentName <deploymentName> The name of the Bicep deployment." >&2
echo " --location <location> The location for the deployed resources." >&2
echo " --skipInfrastructure Skip the infrastructure deployment. Requires InfrastructureOutputs.json to exist in the infra directory." >&2
exit 1
}
# The script parameters to setup the environment
declare -A params=(
# The name of the Bicep deployment
[deploymentName]="doc-extract-eval-pf"
# The location for the deployed resources
[location]="swedencentral"
# Whether to skip the infrastructure deployment. Requires InfrastructureOutputs.json to exist in the infra directory.
[skipInfrastructure]=0
)
parse_args params $@
# Install required tools
install_jq
# Check if mandatory parameters are set
if [ -z "$deploymentName" ] || [ -z "$location" ]; then
usage
fi
echo "Starting environment setup..." >&2
if [ $skipInfrastructure -eq 0 ] || [ ! -f ./infra/InfrastructureOutputs.json ]; then
echo "Deploying infrastructure..." >&2
./infra/deploy.sh --deploymentName $deploymentName --location $location
else
echo "Skipping infrastructure deployment. Using existing outputs..." >&2
fi
infrastructureOutputs=$(cat ./infra/InfrastructureOutputs.json | jq '.')
promptFlowOutputs=$(./promptflow/deploy.sh \
--subscriptionId $(echo $infrastructureOutputs | jq -r '.subscriptionInfo.value.id') \
--resourceGroupName $(echo $infrastructureOutputs | jq -r '.resourceGroupInfo.value.name') \
--aiHubProjectName $(echo $infrastructureOutputs | jq -r '.aiHubProjectInfo.value.name') \
--storageAccountName $(echo $infrastructureOutputs | jq -r '.storageAccountInfo.value.name') \
--documentImageContainerName $(echo $infrastructureOutputs | jq -r '.storageAccountInfo.value.documentImageContainerName') \
--openAIServicesConnectionName $(echo $infrastructureOutputs | jq -r '.aiHubInfo.value.openAIServicesConnectionName') \
--modelDeploymentName $(echo $infrastructureOutputs | jq -r '.aiServicesInfo.value.modelDeploymentName') \
--documentDataExtractionPromptFlowName 'data-extraction' \
--documentDataExtractionEvalPromptFlowName 'data-extraction-eval')
outputs="{ \"infrastructureOutputs\": $infrastructureOutputs, \"promptFlowOutputs\": $promptFlowOutputs }"
echo "$outputs" | jq '.' >'./EnvironmentOutputs.json'
echo "Environment setup finished." >&2
echo "$outputs"