Esempio n. 1
0
def get_project(workspace, parent_folder, project_folder, run_history_name):

    # parent folder must already exists
    if not os.path.isdir(parent_folder):
        raise OSError(
            "project parent folder {} doesn't exist".format(parent_folder))

    project_full_path = os.path.join(parent_folder, project_folder)

    # create project folder if it doesn't already exist
    if not os.path.isdir(project_full_path):
        os.mkdir(project_full_path)

    try:
        # try loading the project folder it is already initialized (with a valid aml_config folder etc.)
        proj = Project(directory=project_full_path)
        print('Existing project loaded from:', project_full_path)
    except:
        # create a new project and attach it to a run history container
        proj = Project.attach(workspace_object=workspace,
                              run_history_name=run_history_name,
                              directory=project_full_path)

        print('new project created in:', project_full_path)
    return proj
Esempio n. 2
0
project_folder = '/tmp/e2e-test/05'
train_script = 'train-spark.py'
run_history_name = 'e2e-05'

ws = Workspace.from_config()

print('Workspace details:')
print(ws.resource_group, ws.name, ws.location)

if os.path.isdir(project_folder):
    print('{} already exists, remove it.'.format(project_folder))
    shutil.rmtree(project_folder)

project = Project.attach(workspace_object = ws,
                         history_name = run_history_name,
                         directory = project_folder)

print(project.project_directory, project.history.name, sep = '\n')

print('copy {} and iris.csv to the project folder.'.format(train_script))
shutil.copy(train_script, os.path.join(project_folder, train_script))
shutil.copy('iris.csv', os.path.join(project_folder, 'iris.csv'))

print('create an ACI run config.')

# create a new runconfig object
run_config = RunConfiguration(project_object = project, run_config_name = 'my-aci-run-config')

# signal that you want to use ACI to execute script.
run_config.target = "containerinstance"