Example #1
0
def test_train():
    spec = tag_test(base_spec, 'test_run_local_train')
    result = run_local(spec,
                       command='../notebooks/functions/train.py',
                       workdir='./',
                       artifact_path='./faces/artifacts')
    verify_state(result)
Example #2
0
def test_handler_empty_hyper():
    run_spec = tag_test(basespec2, 'test_handler_empty_hyper')
    result = run_start(run_spec,
                       handler=my_func,
                       rundb=rundb_path,
                       hyperparams={'p1': [2, 4]})
    verify_state(result)
Example #3
0
def test_handler_hyper():
    run_spec = tag_test(base_spec, 'test_handler_hyper')
    run_spec.with_hyper_params({'p1': [1, 2, 3]})
    result = run_start(run_spec, handler=my_func, rundb=rundb_path)
    print(result)
    assert len(result.status.iterations) == 3+1, 'hyper parameters test failed'
    verify_state(result)
Example #4
0
def test_handler_hyperlist():
    run_spec = tag_test(base_spec, 'test_handler_hyperlist')
    run_spec.spec.param_file = 'param_file.csv'
    result = run_start(run_spec, handler=my_func, rundb=rundb_path)
    print(result)
    assert len(result.status.iterations) == 3+1, 'hyper parameters test failed'
    verify_state(result)
Example #5
0
def test_handler_hyperlist():
    run_spec = tag_test(base_spec, 'test_handler_hyperlist')
    run_spec.spec.param_file = '{}/param_file.csv'.format(here)
    result = new_function().run(run_spec, handler=my_func)
    print(result)
    assert len(result.status.iterations) == 3+1, 'hyper parameters test failed'
    verify_state(result)
Example #6
0
def test_local_no_context():
    spec = tag_test(basespec, 'test_local_no_context')
    result = run_start(spec,
                       command=f'{here}/no_ctx.py',
                       rundb=rundb_path,
                       mode='noctx')
    verify_state(result)
Example #7
0
def test_dask_local_hyper():
    task = NewRun().with_hyper_params({'p1': [5, 2, 3]}, 'max.accuracy')
    spec = tag_test(task, 'test_dask_local_hyper')
    run = new_function(command='dask://').run(spec, handler=my_func)
    verify_state(run)
    assert len(run.status.iterations) == 3 + 1, 'hyper parameters test failed'
    pprint(run.to_dict())
Example #8
0
def test_simple_function():
    Thread(target=create_function, args=(myfunction, 4444)).start()
    time.sleep(2)

    spec = tag_test(base_spec, 'simple_function')
    result = run_start(spec, command='http://localhost:4444', rundb=rundb_path)
    print(result)
    verify_state(result)
Example #9
0
def test_simple_function():
    _thread.start_new_thread(create_function, (myfunction, 4444))
    time.sleep(2)

    spec = tag_test(basespec, 'simple_function')
    result = run_start(spec, command='http://localhost:4444', rundb=rundb_path)
    print(result)
    verify_state(result)
Example #10
0
def test_handler_hyper():
    run_spec = tag_test(basespec2, 'test_handler_hyper')
    run_spec['spec']['hyperparams'] = {'p1': [1, 2, 3]}
    result = run_start(run_spec, handler=my_func, rundb=rundb_path)
    print(result)
    assert len(result['status']
               ['iterations']) == 3 + 1, 'hyper parameters test failed'
    verify_state(result)
Example #11
0
def test_handler_project():
    spec = tag_test(base_spec, 'test_handler_project')
    spec.metadata.project = 'myproj'
    spec.metadata.labels = {'owner': 'yaronh'}
    result = new_function().run(spec, handler=my_func)
    print(result)
    assert result.output('accuracy') == 16, 'failed to run'
    verify_state(result)
Example #12
0
def test_handler_hyper():
    run_spec = tag_test(base_spec, 'test_handler_hyper')
    run_spec.with_hyper_params({'p1': [1, 5, 3]}, selector='max.accuracy')
    result = new_function().run(run_spec, handler=my_func)
    print(result)
    assert len(result.status.iterations) == 3+1, 'hyper parameters test failed'
    assert result.status.results['best_iteration'] == 2, 'failed to select best iteration'
    verify_state(result)
Example #13
0
def test_with_params():
    environ['MLRUN_META_DBPATH'] = rundb_path
    spec = tag_test(basespec, 'test_with_params')

    result = my_func(spec).to_dict()
    assert result['status']['outputs'].get('accuracy') == 16, 'failed to run'
    assert result['status'][run_keys.output_artifacts][0].get(
        'key') == 'chart', 'failed to run'
Example #14
0
def test_handler_hyperlist():
    run_spec = tag_test(basespec2, 'test_handler_hyperlist')
    run_spec['spec']['param_file'] = 'param_file.csv'
    result = run_start(run_spec, handler=my_func, rundb=rundb_path)
    print(result)
    assert len(result['status']
               ['iterations']) == 3 + 1, 'hyper parameters test failed'
    verify_state(result)
Example #15
0
def test_hyper_function():
    Thread(target=create_function, args=(myfunction, 4444))
    time.sleep(2)

    spec = tag_test(base_spec, 'hyper_function')
    spec.spec.hyperparams = {'p1': [1, 2, 3]}
    result = run_start(spec, command='http://localhost:4444', rundb=rundb_path)
    print(result)
    verify_state(result)
Example #16
0
def test_simple_function():
    #Thread(target=create_function, args=(myfunction, 4444)).start()
    _thread.start_new_thread(create_function, (myfunction, 4444))
    time.sleep(2)

    spec = tag_test(base_spec, 'simple_function')
    result = new_function(command='http://localhost:4444').run(spec)
    print(result)
    verify_state(result)
Example #17
0
def test_hyper_function():
    _thread.start_new_thread(create_function, (myfunction, 4444))
    time.sleep(2)

    spec = tag_test(basespec, 'hyper_function')
    spec['spec']['hyperparams'] = {'p1': [1, 2, 3]}
    result = run_start(spec, command='http://localhost:4444', rundb=rundb_path)
    print(result)
    verify_state(result)
Example #18
0
def test_run_local_obj():
    spec = tag_test(base_spec, 'test_run_local_handler')
    spec.spec.handler = 'training'
    nbpath = '{}/mlrun_jobs.ipynb'.format(examples_path)
    ymlpath = path.join(out_path, 'nbyaml.yaml')
    print('out path:', out_path, ymlpath)
    fn = code_to_function(filename=nbpath, kind='job').export(ymlpath)
    result = run_local(spec, command=fn, workdir=out_path)
    verify_state(result)
Example #19
0
def test_hyper_function():
    #Thread(target=create_function, args=(myfunction, 4444))
    _thread.start_new_thread(create_function, (myfunction, 4444))
    time.sleep(2)

    spec = tag_test(base_spec, 'hyper_function')
    spec.spec.hyperparams = {'p1': [1, 2, 3]}
    result = new_function(command='http://localhost:4444').run(spec)
    print(result)
    verify_state(result)
Example #20
0
def test_local_no_context():
    spec = tag_test(base_spec, 'test_local_no_context')
    spec.spec.parameters = {'xyz': '789'}
    result = new_function(command='{}/no_ctx.py'.format(here),
                        mode='noctx').run(spec)
    verify_state(result)

    db = get_run_db().connect()
    log = str(db.get_log(result.metadata.uid))
    print(log)
    assert log.find(", '--xyz', '789']") != -1, 'params not detected in noctx'
Example #21
0
def test_local_runtime():
    spec = tag_test(basespec, 'test_local_runtime')
    result = run_start(spec, command='example1.py', rundb=rundb_path)
    verify_state(result)
Example #22
0
def test_run_local_handler():
    spec = tag_test(base_spec, 'test_run_local_handler')
    spec.spec.handler = 'my_func'
    result = run_local(spec, command='{}/handler.py'.format(
        examples_path), workdir=examples_path)
    verify_state(result)
Example #23
0
def test_dask_local():
    spec = tag_test(NewTask(params={'p1': 3, 'p2': 'vv'}), 'test_dask_local')
    run = new_function(kind='dask').run(spec, handler=my_func)
    verify_state(run)
Example #24
0
def test_run_local_nb():
    spec = tag_test(base_spec, 'test_run_local_handler')
    spec.spec.handler = 'training'
    result = run_local(spec, command='{}/mlrun_jobs.ipynb'.format(
        examples_path), workdir=examples_path)
    verify_state(result)
Example #25
0
def test_local_handler():
    spec = tag_test(base_spec, 'test_local_runtime')
    result = new_function(command='{}/handler.py'.format(examples_path)).run(
        spec, handler='my_func')
    verify_state(result)
Example #26
0
def test_handler_project():
    run_spec_project = tag_test(basespec_project, 'test_handler_project')
    result = run_start(run_spec_project, handler=my_func, rundb=rundb_path)
    print(result)
    assert result['status']['outputs'].get('accuracy') == 10, 'failed to run'
    verify_state(result)
Example #27
0
def test_with_params_s3():
    spec = tag_test(s3_spec, 'test_with_params')
    result = new_function().run(spec, handler=my_func)

    assert result.output('accuracy') == 16, 'failed to run'
    assert result.status.artifacts[0].get('key') == 'chart', 'failed to run'
Example #28
0
def test_dask_local():
    spec = tag_test(NewRun(params={'p1': 3, 'p2': 'vv'}), 'test_dask_local')
    run = new_function(command='dask://',
                       rundb=rundb_path).run(spec, handler=my_func)
    verify_state(run)
    pprint(run.to_dict())
Example #29
0
def test_local_runtime():
    spec = tag_test(base_spec, 'test_local_runtime')
    result = new_function(
        command='{}/training.py'.format(examples_path)).run(spec)
    verify_state(result)
Example #30
0
def test_run_local():
    spec = tag_test(base_spec, 'test_run_local')
    result = run_local(spec, command='{}/training.py'.format(
        examples_path), workdir=examples_path)
    verify_state(result)