diff --git a/.ci/scripts/aml_attach_blob.py b/.ci/scripts/aml_attach_blob.py index 2bd2b0c..5ce388f 100644 --- a/.ci/scripts/aml_attach_blob.py +++ b/.ci/scripts/aml_attach_blob.py @@ -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 @@ -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 -rg -wn -wr ' + print 'aml_attach_blob.py -s -rg -wn -wr -dsn -cn -an -ak -drg ' sys.exit(2) for opt, arg in opts: if opt == '-h': - print 'aml_creation.py -s -rg -wn -wr ' + print 'aml_attach_blob.py -s -rg -wn -wr -dsn -cn -an -ak -drg ' sys.exit() elif opt in ("-s", "--subscription_id"): subscription_id = arg @@ -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) diff --git a/.ci/scripts/aml_creation.py b/.ci/scripts/aml_creation.py index c5bfc46..e3fbed3 100644 --- a/.ci/scripts/aml_creation.py +++ b/.ci/scripts/aml_creation.py @@ -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}}"