Skip to content

Commit bbc4878

Browse files
committed
Building MloPS + Data Science Scripts
1 parent 7180721 commit bbc4878

File tree

9 files changed

+55
-54
lines changed

9 files changed

+55
-54
lines changed

.github/workflows/taskDatabricks.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ jobs:
220220
name: Set Up DBX Environment Variables
221221
run: |
222222
DATABRICKS_TOKEN=$(az keyvault secret show --name "dbkstoken" --vault-name $AZ_KEYVAULT_NAME --query "value" -o tsv)
223-
echo $DATABRICKS_TOKEN
223+
#echo $DATABRICKS_TOKEN
224224
echo "DATABRICKS_TOKEN=$DATABRICKS_TOKEN" >> $GITHUB_ENV
225225
226226
@@ -235,8 +235,8 @@ jobs:
235235
# not the Databricks AAD Token.
236236
pip3 install dbx
237237
238-
echo $DATABRICKS_TOKEN
239-
echo $DATABRICKS_HOST
238+
#echo $DATABRICKS_TOKEN
239+
#echo $DATABRICKS_HOST
240240
241241
databricks -h
242242
databricks fs ls

infrastructure/databricks/databricks_utils/bash/utilsCreateDatabricksToken.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if [ $SECRET_EXISTS == true ]; then
2121
--query "value" \
2222
-o tsv )
2323

24-
echo "Secret Value: $DATABRICKS_TOKEN"
24+
#echo "Secret Value: $DATABRICKS_TOKEN"
2525

2626
# if [[ $DevOps_Agent == "GitHub" ]]; then
2727
# echo "DATABRICKS_TOKEN=$DATABRICKS_TOKEN" >> $GITHUB_ENV

infrastructure/databricks/databricks_utils/bash/utilsCreateRoleBasedAccess.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33

4-
echo "Resource Group Name: $RESOURCE_GROUP_NAME"
4+
#echo "Resource Group Name: $RESOURCE_GROUP_NAME"
55
echo "ENVIRONMENT: $ENVIRONMENT"
66
RESOURCE_GROUP_ID=$( az group show -n $RESOURCE_GROUP_NAME --query id -o tsv )
77

@@ -14,7 +14,7 @@ for row in $(echo "${JSON}" | jq -r '.RBAC_Assignments[] | @base64'); do
1414
echo ${row} | base64 --decode | jq -r ${1}
1515
}
1616
ROLES_ARRAY="$(_jq '.roles')"
17-
echo $ROLES_ARRAY
17+
#echo $ROLES_ARRAY
1818

1919
# Before: [ "Contributor", "DBX_Custom_Role", "Key Vault Administrator" ]
2020
# xargs trims whitespace on either side. -n removes newline characters.
@@ -30,7 +30,8 @@ for row in $(echo "${JSON}" | jq -r '.RBAC_Assignments[] | @base64'); do
3030
--role "$ROLE" \
3131
--assignee-object-id $(_jq '.roleBeneficiaryObjID') \
3232
--assignee-principal-type "$(_jq '.principalType')" \
33-
--scope "$RESOURCE_GROUP_ID"
33+
--scope "$RESOURCE_GROUP_ID" \
34+
-o none
3435
#--scope "$(_jq '.scope')"
3536

3637
done

infrastructure/databricks/databricks_utils/bash/utilsSetEnvVariables.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ DATABRICKS_INSTANCE="$(az databricks workspace list -g $RESOURCE_GROUP_NAME --qu
1717
WORKSPACE_ID=$(az databricks workspace list -g $RESOURCE_GROUP_NAME --query "[].id" -o tsv)
1818
AZ_KEYVAULT_NAME=$(az keyvault list -g $RESOURCE_GROUP_NAME --query "[].name" -o tsv)
1919
SUBSCRIPTION_ID=$( az account show --query id -o tsv )
20-
echo $SUBSCRIPTION_ID
21-
echo $DATABRICKS_ORDGID
22-
echo $WORKSPACE_ID
23-
echo $AZ_KEYVAULT_NAME
24-
echo $SUBSCRIPTION_ID
25-
echo $AML_WS_NAME
26-
echo $DATABRICKS_WS_NAME
20+
#echo $SUBSCRIPTION_ID
21+
#echo $DATABRICKS_ORDGID
22+
#echo $WORKSPACE_ID
23+
#echo $AZ_KEYVAULT_NAME
24+
#echo $SUBSCRIPTION_ID
25+
#echo $AML_WS_NAME
26+
#echo $DATABRICKS_WS_NAME
2727
#DATABRICKS_TOKEN=$(az keyvault secret show --name "dbkstoken" --vault-name $AZ_KEYVAULT_NAME --query "value" -o tsv)
2828

2929

infrastructure/databricks/databricks_utils/python/utils_create_cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def create_clusters():
3333
cluster_param_file = _ingest_cluster_param_file('infrastructure/databricks/databricks_configs/' + ENVIRONMENT + '/clusters.json')
3434
existing_clusters, _ = _list_existing_clusters()
3535
existing_clusters_name_arr = _get_cluster_names(existing_clusters)
36-
print(existing_clusters_name_arr)
36+
#print(existing_clusters_name_arr)
3737
for cluster in cluster_param_file:
3838
if cluster['cluster_name'] not in existing_clusters_name_arr:
3939
print(f"Cluster {cluster} does not exist - Deploy.")
@@ -68,7 +68,7 @@ def _list_existing_clusters():
6868
status_code = response.status_code
6969

7070
response_content = response.json()
71-
print(response_content)
71+
#print(response_content)
7272

7373
if status_code != 200:
7474
raise Exception(status_code)

infrastructure/databricks/databricks_utils/python/utils_create_secret_scopes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ def run_cmd(cmd):
2929
#May Need To Rmove shell=True
3030
process = subprocess.run(cmd, stdout=subprocess.PIPE)
3131
output = process.stdout.decode().split('\n')
32-
print(output)
32+
#print(output)
3333
output = [line.strip('\n').strip('\r') for line in output]
3434

3535

36-
print(f"Return Code: {process.returncode}")
36+
#print(f"Return Code: {process.returncode}")
3737
if process.returncode != 0:
3838
raise RuntimeError('\n'.join(output))
3939
return output
@@ -63,11 +63,11 @@ def create_secret_scopes(scope_name=str, initial_manage_principal=str):
6363
'https://' + DATABRICKS_INSTANCE + '/api/2.0/secrets/scopes/create', headers=DBRKS_REQ_HEADERS, json=postjson
6464
)
6565

66-
print(response.status_code)
66+
#print(response.status_code)
6767
#if response.status_code != 200:
6868
# raise Exception(response.text)
6969

70-
print(response.json())
70+
#print(response.json())
7171

7272
def insert_secret(secret_value=str, scope_name=str, key=str):
7373
"""
@@ -82,18 +82,18 @@ def insert_secret(secret_value=str, scope_name=str, key=str):
8282
response = requests.post(
8383
'https://' + DATABRICKS_INSTANCE + '/api/2.0/secrets/put', headers=DBRKS_REQ_HEADERS, json=postjson
8484
)
85-
print(response.status_code)
85+
#print(response.status_code)
8686
if response.status_code != 200:
8787
raise Exception(response.text)
8888

89-
print(response.json())
89+
#print(response.json())
9090

9191

9292
if __name__ == '__main__':
9393
app_insight_name = get_app_insight_name()[0]
94-
print(app_insight_name)
94+
#print(app_insight_name)
9595
app_insight_key = get_app_insight_key(app_insight_name)[0]
96-
print(app_insight_key)
96+
#print(app_insight_key)
9797

9898

9999
# Create Secret Scopes

infrastructure/databricks/databricks_utils/python/utils_git_configuration.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ def configureGit(gitConfig, workspaceId, databricksInstance, bearerToken, manage
2323
}
2424

2525
gitConfig.update(newData)
26-
print(gitConfig)
27-
print(DBRKS_REQ_HEADERS)
26+
#print(gitConfig)
27+
#print(DBRKS_REQ_HEADERS)
2828

2929
response = requests.post('https://' + databricksInstance + '/api/2.0/git-credentials', headers=DBRKS_REQ_HEADERS, json=gitConfig)
30-
print(response)
30+
#print(response)
3131
#print(response.json())
3232

3333
if response.status_code != 200:
3434

3535
response = requests.get('https://' + databricksInstance + '/api/2.0/git-credentials', headers=DBRKS_REQ_HEADERS)
36-
print(response.json())
36+
#print(response.json())
3737
credential = response.json()["credentials"][0]["credential_id"]
38-
print(f"Credential is {credential}")
38+
#print(f"Credential is {credential}")
3939
response = requests.patch('https://' + databricksInstance + '/api/2.0/git-credentials/'+ str(credential), headers=DBRKS_REQ_HEADERS, json=gitConfig)
4040

4141
#print(response.json())
@@ -47,12 +47,12 @@ def configureGit(gitConfig, workspaceId, databricksInstance, bearerToken, manage
4747

4848
gitConfigs = json['Git_Configuration']
4949

50-
print(os.environ['WORKSPACE_ID'])
51-
print(os.environ['DATABRICKS_INSTANCE'])
52-
print(os.environ['DATABRICKS_AAD_TOKEN'])
53-
print(os.environ['DATABRICKS_MANAGEMENT_TOKEN'])
54-
print(os.environ['PAT_GITHUB'])
55-
print(os.environ['ENVIRONMENT'])
50+
#print(os.environ['WORKSPACE_ID'])
51+
#print(os.environ['DATABRICKS_INSTANCE'])
52+
#print(os.environ['DATABRICKS_AAD_TOKEN'])
53+
#print(os.environ['DATABRICKS_MANAGEMENT_TOKEN'])
54+
#print(os.environ['PAT_GITHUB'])
55+
#print(os.environ['ENVIRONMENT'])
5656
for gitConfig in gitConfigs:
5757
response = configureGit(gitConfig=gitConfig,
5858
workspaceId=os.environ['WORKSPACE_ID'],

infrastructure/databricks/databricks_utils/python/utils_repo_pull.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def update_repo(repo_id, update_branch):
8484
if response.status_code != 200:
8585
raise Exception(response.content)
8686
else:
87-
print(f"Status Code: {response.status_code}")
88-
print(response.json())
87+
#print(f"Status Code: {response.status_code}")
88+
#print(response.json())
8989
return response.status_code
9090

9191

mlOps/nyc_taxi/aml_pipelines/v1/nyc_pipeline.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@
3131
'Content-Type': 'application/json'
3232
}
3333

34-
print(DATABRICKS_COMPUTE_NAME)
35-
print(WORKSPACE_ID)
36-
print(RESOURCE_GROUP_NAME)
37-
print(DATABRICKS_AAD_TOKEN)
38-
print(DATABRICKS_MANAGEMENT_TOKEN)
39-
print(DATABRICKS_INSTANCE)
40-
print(SUBSCRIPTION_ID)
41-
print(ARM_CLIENT_SECRET)
42-
print(ARM_TENANT_ID)
43-
print(ARM_CLIENT_ID)
44-
print(AML_WS_NAME)
34+
#print(DATABRICKS_COMPUTE_NAME)
35+
#print(WORKSPACE_ID)
36+
#print(RESOURCE_GROUP_NAME)
37+
#print(DATABRICKS_AAD_TOKEN)
38+
#print(DATABRICKS_MANAGEMENT_TOKEN)
39+
#print(DATABRICKS_INSTANCE)
40+
#print(SUBSCRIPTION_ID)
41+
#print(ARM_CLIENT_SECRET)
42+
#print(ARM_TENANT_ID)
43+
#print(ARM_CLIENT_ID)
44+
#print(AML_WS_NAME)
4545

4646
class GetClusterID():
4747
def __init__(self, cluster_name):
@@ -103,17 +103,17 @@ def create_pipeline_structure(databricks_compute, ws, cluster_id):
103103
auth=svc_pr
104104
)
105105

106-
print(f" AML Workspace Properties: {ws} ")
106+
#print(f" AML Workspace Properties: {ws} ")
107107

108108
try:
109109
databricks_compute = DatabricksCompute(workspace=ws, name=DATABRICKS_COMPUTE_NAME)
110110
print('Compute target {} already exists'.format(DATABRICKS_COMPUTE_NAME))
111111
except ComputeTargetException:
112-
print('Compute not found, will use below parameters to attach new one')
113-
print('db_compute_name {}'.format(DATABRICKS_COMPUTE_NAME))
114-
print('db_resource_group {}'.format(RESOURCE_GROUP_NAME))
115-
print('db_workspace_name {}'.format(DATABRICKS_WS_NAME))
116-
print('db_access_token {}'.format(DATABRICKS_AAD_TOKEN))
112+
#print('Compute not found, will use below parameters to attach new one')
113+
#print('db_compute_name {}'.format(DATABRICKS_COMPUTE_NAME))
114+
#print('db_resource_group {}'.format(RESOURCE_GROUP_NAME))
115+
#print('db_workspace_name {}'.format(DATABRICKS_WS_NAME))
116+
#print('db_access_token {}'.format(DATABRICKS_AAD_TOKEN))
117117

118118
config = DatabricksCompute.attach_configuration(
119119
resource_group = RESOURCE_GROUP_NAME,

0 commit comments

Comments
 (0)