Skip to content

Commit

Permalink
Update resources name (#2521)
Browse files Browse the repository at this point in the history
* Update keyvault name

* Update attached compute name

* Fix if condition

* Update compute name
  • Loading branch information
fredms authored Aug 9, 2023
1 parent 7d3a90c commit 2c8e615
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
working-directory: cli
continue-on-error: true
run: |
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark.yml
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark.yml jobs/spark/attached-spark-pipeline-default-identity.yml
- name: run job
run: |
source "${{ github.workspace }}/infra/bootstrapping/sdk_helpers.sh";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
working-directory: cli
continue-on-error: true
run: |
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark-system-identity.yml
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark-system-identity.yml jobs/spark/attached-spark-pipeline-managed-identity.yml
- name: run job
run: |
source "${{ github.workspace }}/infra/bootstrapping/sdk_helpers.sh";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
working-directory: cli
continue-on-error: true
run: |
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark-user-identity.yml
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark-user-identity.yml jobs/spark/attached-spark-pipeline-user-identity.yml
- name: run job
run: |
source "${{ github.workspace }}/infra/bootstrapping/sdk_helpers.sh";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
working-directory: cli
continue-on-error: true
run: |
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark.yml
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark.yml jobs/spark/attached-spark-standalone-default-identity.yml
- name: run job
run: |
source "${{ github.workspace }}/infra/bootstrapping/sdk_helpers.sh";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
working-directory: cli
continue-on-error: true
run: |
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark-system-identity.yml
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark-system-identity.yml jobs/spark/attached-spark-standalone-managed-identity.yml
- name: run job
run: |
source "${{ github.workspace }}/infra/bootstrapping/sdk_helpers.sh";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
working-directory: cli
continue-on-error: true
run: |
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark-user-identity.yml
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark-user-identity.yml jobs/spark/attached-spark-standalone-user-identity.yml
- name: run job
run: |
source "${{ github.workspace }}/infra/bootstrapping/sdk_helpers.sh";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
path: azureml://datastores/workspaceblobstore/paths/data/wrangled/
mode: direct

compute: mysparkcompute
compute: <ATTACHED_SPARK_POOL_NAME>
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
identity:
type: managed

compute: mysparkcompute
compute: <ATTACHED_SPARK_POOL_NAME>
2 changes: 1 addition & 1 deletion cli/jobs/spark/attached-spark-pipeline-user-identity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
identity:
type: user_identity

compute: mysparkcompute
compute: <ATTACHED_SPARK_POOL_NAME>
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ args: >-
--titanic_data ${{inputs.titanic_data}}
--wrangled_data ${{outputs.wrangled_data}}
compute: mysparkcompute
compute: <ATTACHED_SPARK_POOL_NAME>
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ args: >-
identity:
type: managed

compute: mysparkcompute
compute: <ATTACHED_SPARK_POOL_NAME>
2 changes: 1 addition & 1 deletion cli/jobs/spark/attached-spark-standalone-user-identity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ args: >-
identity:
type: user_identity

compute: mysparkcompute
compute: <ATTACHED_SPARK_POOL_NAME>
17 changes: 13 additions & 4 deletions cli/jobs/spark/setup-attached-resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,24 @@ az role assignment create --role "Storage Blob Data Owner" --assignee $AML_USER_
az synapse spark pool create --name $SPARK_POOL_NAME --workspace-name $SYNAPSE_WORKSPACE_NAME --resource-group $RESOURCE_GROUP --spark-version 3.2 --node-count 3 --node-size Medium --min-node-count 3 --max-node-count 10 --enable-auto-scale true
az synapse workspace firewall-rule create --name allowAll --workspace-name $SYNAPSE_WORKSPACE_NAME --resource-group $RESOURCE_GROUP --start-ip-address 0.0.0.0 --end-ip-address 255.255.255.255

TEMP_COMPUTE_FILE="temp-compute-setup.yml"
cp $1 $TEMP_COMPUTE_FILE
if [[ "$2" == *"managed-identity"* ]]
then
ATTACHED_COMPUTE_NAME=${ATTACHED_COMPUTE_NAME}mi
elif [[ "$2" == *"user-identity"* ]]
then
ATTACHED_COMPUTE_NAME=${ATTACHED_COMPUTE_NAME}ui
fi

sed -i "s/<SUBSCRIPTION_ID>/$SUBSCRIPTION_ID/g;
s/<RESOURCE_GROUP>/$RESOURCE_GROUP/g;
s/<SYNAPSE_WORKSPACE_NAME>/$SYNAPSE_WORKSPACE_NAME/g;
s/<SPARK_POOL_NAME>/$SPARK_POOL_NAME/g;
s/<AML_USER_MANAGED_ID>/$AML_USER_MANAGED_ID/g;" $TEMP_COMPUTE_FILE
s/<AML_USER_MANAGED_ID>/$AML_USER_MANAGED_ID/g;
s/<ATTACHED_SPARK_POOL_NAME>/$ATTACHED_COMPUTE_NAME/g;" $1

sed -i "s/<ATTACHED_SPARK_POOL_NAME>/$ATTACHED_COMPUTE_NAME/g;" $2

az ml compute attach --file $TEMP_COMPUTE_FILE --subscription $SUBSCRIPTION_ID --resource-group $RESOURCE_GROUP --workspace-name $AML_WORKSPACE_NAME
az ml compute attach --file $1 --subscription $SUBSCRIPTION_ID --resource-group $RESOURCE_GROUP --workspace-name $AML_WORKSPACE_NAME
az synapse role assignment create --workspace-name $SYNAPSE_WORKSPACE_NAME --role $SPARK_POOL_ADMIN_ROLE_ID --assignee $AML_USER_MANAGED_ID_OID

COMPUTE_MANAGED_IDENTITY=$(az ml compute show --name $ATTACHED_COMPUTE_NAME --resource-group $RESOURCE_GROUP --workspace-name $AML_WORKSPACE_NAME --query identity.principal_id --out tsv)
Expand Down
12 changes: 6 additions & 6 deletions cli/readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def write_job_workflow(job):
working-directory: cli
continue-on-error: true\n"""
if is_spark_sample:
workflow_yaml += get_spark_setup_workflow(job)
workflow_yaml += get_spark_setup_workflow(job, posix_project_dir, filename)
workflow_yaml += f""" - name: run job
run: |
source "{GITHUB_WORKSPACE}/infra/bootstrapping/sdk_helpers.sh";
Expand Down Expand Up @@ -862,7 +862,7 @@ def get_endpoint_name(filename, hyphenated):
return endpoint_name


def get_spark_setup_workflow(job):
def get_spark_setup_workflow(job, posix_project_dir, filename):
is_attached = "attached-spark" in job
is_user_identity = "user-identity" in job
is_managed_identity = "managed-identity" in job
Expand All @@ -876,7 +876,7 @@ def get_spark_setup_workflow(job):
workflow += f""" - name: setup identities
run: |
bash -x setup-identities.sh
working-directory: cli/jobs/spark
working-directory: cli/{posix_project_dir}
continue-on-error: true\n"""
if is_attached:
workflow += f""" - name: setup attached spark
Expand All @@ -885,15 +885,15 @@ def get_spark_setup_workflow(job):
if is_attached and is_user_identity:
workflow += f"""
run: |
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark-user-identity.yml\n"""
bash -x {posix_project_dir}/setup-attached-resources.sh resources/compute/attached-spark-user-identity.yml {posix_project_dir}/{filename}.yml\n"""
if is_attached and is_managed_identity:
workflow += f"""
run: |
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark-system-identity.yml\n"""
bash -x {posix_project_dir}/setup-attached-resources.sh resources/compute/attached-spark-system-identity.yml {posix_project_dir}/{filename}.yml\n"""
if is_attached and is_default_identity:
workflow += f"""
run: |
bash -x jobs/spark/setup-attached-resources.sh resources/compute/attached-spark.yml\n"""
bash -x {posix_project_dir}/setup-attached-resources.sh resources/compute/attached-spark.yml {posix_project_dir}/{filename}.yml\n"""

return workflow

Expand Down
2 changes: 1 addition & 1 deletion cli/resources/compute/attached-spark-system-identity.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# attached-spark-system-identity.yaml
name: mysparkcompute
name: <ATTACHED_SPARK_POOL_NAME>

type: synapsespark

Expand Down
2 changes: 1 addition & 1 deletion cli/resources/compute/attached-spark-user-identity.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# attached-spark-user-identity.yml
name: mysparkcompute
name: <ATTACHED_SPARK_POOL_NAME>

type: synapsespark

Expand Down
2 changes: 1 addition & 1 deletion cli/resources/compute/attached-spark.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# attached-spark.yaml
name: mysparkcompute
name: <ATTACHED_SPARK_POOL_NAME>

type: synapsespark

Expand Down
2 changes: 1 addition & 1 deletion sdk/python/jobs/spark/setup_spark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ then
ACCOUNT_KEY=$(az storage account keys list --account-name $AZURE_STORAGE_ACCOUNT --query "[0].value" -o tsv)
ACCESS_KEY_SECRET_NAME="autotestaccountkey"

KEY_VAULT_NAME="autotestsparkkv"
KEY_VAULT_NAME=${RESOURCE_GROUP}-kv
az keyvault create -n $KEY_VAULT_NAME -g $RESOURCE_GROUP

NOTEBOOK_PY="./data-wrangling/interactive_data_wrangling.py"
Expand Down

0 comments on commit 2c8e615

Please sign in to comment.