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)
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())
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)
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)
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)
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)
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'
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)
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)
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)
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)
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)
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)
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())
def test_local_runtime_hyper(): spec = tag_test(base_spec, 'test_local_runtime_hyper') spec.with_hyper_params({'p1': [1, 5, 3]}, selector='max.accuracy') result = new_function(command='{}/training.py'.format( examples_path)).run(spec) verify_state(result)