def build_notebook()

in playbooks/roles/ood-applications/files/bc_amlsdk/template/nbbuilder.py [0:0]


def build_notebook(subscription, location, resourcegroup, workspace,
                   amlenv, machinetype, maxinstances, jobfile, jobinputs):

    nb = nbf.v4.new_notebook()

    msg_welcome = """\
# AZHOP AzureML SDK (python) Entry point
Use this self-created template to run your parallel job in AzureML."""

    code_import = """\
import amlwrapperfunctions as aml"""

    code_login = """\
aml.login()"""

    code_setup_tmp = """\
aml.setupenv(subscription_id='{subscription}',
             location='{location}',
             resource_group='{resourcegroup}',
             workspace_name='{workspace}',
             amlenv='{amlenv}',
             machine_type='{machinetype}',
             max_instances={maxinstances})"""

    code_setup = code_setup_tmp.format(subscription=subscription,
                                       location=location,
                                       resourcegroup=resourcegroup,
                                       workspace=workspace,
                                       amlenv=amlenv,
                                       machinetype=machinetype,
                                       maxinstances=maxinstances)

    code_jobrun_tmp = """\
job_handler, aml_client = aml.runjob("{jobfile}", "{jobinputs}")"""

    code_jobrun = code_jobrun_tmp.format(jobfile=jobfile, jobinputs=jobinputs)

    code_jobstream = """\
aml_client.jobs.stream(job_handler.name)"""

    nb['cells'] = [nbf.v4.new_markdown_cell(msg_welcome),
                   nbf.v4.new_code_cell(code_import),
                   nbf.v4.new_code_cell(code_login),
                   nbf.v4.new_code_cell(code_setup),
                   nbf.v4.new_code_cell(code_jobrun),
                   nbf.v4.new_code_cell(code_jobstream)]

    nbf.write(nb, OUTPUT)