def main():
    print('Running train.py')
    parser = argparse.ArgumentParser('train')
    parser.add_argument('--build_id', type=str, help='The build ID of the build triggering this pipeline run')
    parser.add_argument('--model_name', type=str, help='Name of the Model', default='sklearn_regression_model.pkl')
    parser.add_argument('--step_output', type=str, help='output for passing data to next step')
    args = parser.parse_args()
    print(('Argument [build_id]: %s' % args.build_id))
    print(('Argument [model_name]: %s' % args.model_name))
    print(('Argument [step_output]: %s' % args.step_output))
    model_name = args.model_name
    build_id = args.build_id
    step_output_path = args.step_output
    print('Getting training parameters')
    alpha = 0.5
    print(('Parameter alpha: %s' % alpha))
    run = Run.get_context()
    dataset = run.input_datasets['training_data']
    if dataset:
        df = dataset.to_pandas_dataframe()
        X = df.values
        y = df.Y
    else:
        e = 'No dataset provided'
        print(e)
        raise Exception(e)
    (X_train, X_test, y_train, y_test) = train_test_split(X, y, test_size=0.2, random_state=0)
    data = {'train': {'X': X_train, 'y': y_train}, 'test': {'X': X_test, 'y': y_test}}
    reg = train_model(run, data, alpha)
    os.makedirs(step_output_path, exist_ok=True)
    model_output_path = os.path.join(step_output_path, model_name)
    joblib.dump(value=reg, filename=model_output_path)
    os.makedirs('outputs', exist_ok=True)
    output_path = os.path.join('outputs', model_name)
    joblib.dump(value=reg, filename=output_path)
    run.parent.tag('BuildId', value=build_id)
    run.tag('BuildId', value=build_id)
    run.tag('run_type', value='train')
    builduri_base = os.environ.get('BUILDURI_BASE')
    if (builduri_base is not None):
        build_uri = (builduri_base + build_id)
        run.tag('BuildUri', value=build_uri)
        run.parent.tag('BuildUri', value=build_uri)
    print(f'tags now present for run: {run.tags}')
    run.complete()
def main():
    print('Running train.py')
    parser = argparse.ArgumentParser('train')
    parser.add_argument('--build_id', type=str, help='The build ID of the build triggering this pipeline run')
    parser.add_argument('--model_name', type=str, help='Name of the Model', default='sklearn_regression_model.pkl')
    parser.add_argument('--step_output', type=str, help='output for passing data to next step')
    args = parser.parse_args()
    print(('Argument [build_id]: %s' % args.build_id))
    print(('Argument [model_name]: %s' % args.model_name))
    print(('Argument [step_output]: %s' % args.step_output))
    model_name = args.model_name
    build_id = args.build_id
    step_output_path = args.step_output
    print('Getting training parameters')
    alpha = 0.5
    print(('Parameter alpha: %s' % alpha))
    run = Run.get_context()
    dataset = run.input_datasets['training_data']
    if dataset:
        df = dataset.to_pandas_dataframe()
        X = df.values
        y = df.Y
    else:
        e = 'No dataset provided'
        print(e)
        raise Exception(e)
    (X_train, X_test, y_train, y_test) = train_test_split(X, y, test_size=0.2, random_state=0)
    data = {'train': {'X': X_train, 'y': y_train}, 'test': {'X': X_test, 'y': y_test}}
    reg = train_model(run, data, alpha)
    os.makedirs(step_output_path, exist_ok=True)
    model_output_path = os.path.join(step_output_path, model_name)
    joblib.dump(value=reg, filename=model_output_path)
    os.makedirs('outputs', exist_ok=True)
    output_path = os.path.join('outputs', model_name)
    joblib.dump(value=reg, filename=output_path)
    run.parent.tag('BuildId', value=build_id)
    run.tag('BuildId', value=build_id)
    run.tag('run_type', value='train')
    builduri_base = os.environ.get('BUILDURI_BASE')
    if (builduri_base is not None):
        build_uri = (builduri_base + build_id)
        run.tag('BuildUri', value=build_uri)
        run.parent.tag('BuildUri', value=build_uri)
    print(f'tags now present for run: {run.tags}')
    run.complete()