Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 30 additions & 28 deletions .ci/scripts/aml_attach_blob.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python

import azureml.core
from azureml.core import Workspace
from azureml.core import Workspace, Datastore
from dotenv import set_key, get_key, find_dotenv
from pathlib import Path
from AIHelpers.utilities import get_auth
Expand All @@ -13,11 +13,11 @@ def main(argv):
opts, args = getopt.getopt(argv,"hs:rg:wn:wr:dsn:cn:an:ak:drg:",
["subscription_id=","resource_group=","workspace_name=", "workspace_region=","blob_datastore_name=","container_name=","account_name=","account_key=","datastore_rg="])
except getopt.GetoptError:
print 'aml_creation.py -s <subscription_id> -rg <resource_group> -wn <workspace_name> -wr <workspace_region>'
print 'aml_attach_blob.py -s <subscription_id> -rg <resource_group> -wn <workspace_name> -wr <workspace_region> -dsn <blob_datastore_name> -cn <container_name> -an <account_name> -ak <account_key> -drg <datastore_rg>'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'aml_creation.py -s <subscription_id> -rg <resource_group> -wn <workspace_name> -wr <workspace_region>'
print 'aml_attach_blob.py -s <subscription_id> -rg <resource_group> -wn <workspace_name> -wr <workspace_region> -dsn <blob_datastore_name> -cn <container_name> -an <account_name> -ak <account_key> -drg <datastore_rg>'
sys.exit()
elif opt in ("-s", "--subscription_id"):
subscription_id = arg
Expand All @@ -28,36 +28,38 @@ def main(argv):
elif opt in ("-wr", "--workspace_region"):
workspace_region = arg
elif opt in ("-dsn", "--blob_datastore_name"):
workspace_region = arg
blob_datastore_name = arg
elif opt in ("-cn", "--container_name"):
workspace_region = arg
container_name = arg
elif opt in ("-an", "--account_name"):
workspace_region = arg
account_name = arg
elif opt in ("-ak", "--account_key"):
workspace_region = arg
account_key = arg
elif opt in ("-drg", "--datastore_rg"):
workspace_region = arg
env_path = find_dotenv()
if env_path == "":
Path(".env").touch()
env_path = find_dotenv()
datastore_rg = arg

env_path = find_dotenv()
if env_path == "":
Path(".env").touch()
env_path = find_dotenv()

ws = Workspace.create(
name=workspace_name,
subscription_id=subscription_id,
resource_group=resource_group,
location=workspace_region,
create_resource_group=True,
auth=get_auth(env_path),
exist_ok=True,
)
blob_datastore = Datastore.register_azure_blob_container(workspace=ws,
datastore_name=blob_datastore_name,
container_name=container_name,
account_name=account_name,
account_key=account_key,
resource_group=datastore_rg)
ws = Workspace.create(
name=workspace_name,
subscription_id=subscription_id,
resource_group=resource_group,
location=workspace_region,
create_resource_group=True,
auth=get_auth(env_path),
exist_ok=True,
)
blob_datastore = Datastore.register_azure_blob_container(
workspace=ws,
datastore_name=blob_datastore_name,
container_name=container_name,
account_name=account_name,
account_key=account_key,
resource_group=datastore_rg,
)

if __name__ == "__main__":
print("AML SDK Version:", azureml.core.VERSION)
Expand Down
34 changes: 14 additions & 20 deletions .ci/scripts/aml_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,22 @@ def main(argv):
workspace_name = arg
elif opt in ("-wr", "--workspace_region"):
workspace_region = arg

env_path = find_dotenv()
if env_path == "":
Path(".env").touch()
env_path = find_dotenv()

ws = Workspace.create(
name=workspace_name,
subscription_id=subscription_id,
resource_group=resource_group,
location=workspace_region,
create_resource_group=True,
auth=get_auth(env_path),
exist_ok=True,
)
env_path = find_dotenv()
if env_path == "":
Path(".env").touch()
env_path = find_dotenv()

ws = Workspace.create(
name=workspace_name,
subscription_id=subscription_id,
resource_group=resource_group,
location=workspace_region,
create_resource_group=True,
auth=get_auth(env_path),
exist_ok=True,
)

if __name__ == "__main__":
print("AML SDK Version:", azureml.core.VERSION)
main(sys.argv[1:])

# Azure resources
subscription_id = "{{cookiecutter.subscription_id}}"
resource_group = "{{cookiecutter.resource_group}}"
workspace_name = "{{cookiecutter.workspace_name}}"
workspace_region = "{{cookiecutter.workspace_region}}"