Convert python code for Auptimizer automatically

See Create and run a new experiment for how to convert a job to a Auptimizer Experiment.

Basic Usage

python convert.py origin.py experiment.json demo_func

Additional arguments

2021-03-03 01:50:00.237624: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory
2021-03-03 01:50:00.237685: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Usage: convert.py [OPTIONS] SCRIPT EXP_JSON FUNC_NAME

  Convert script for Auptimizer 

  Copyright (C) 2018  LG Electronics Inc. 

  GPL-3.0 License. This program comes with ABSOLUTELY NO WARRANTY; 

  Arguments:     script {str} -- Script name to train an ML model and return
  result     exp_json {str} -- JSON file name contrains experiment
  configuration (e.g. hyperparameter)     func_name {str} -- Name of the
  main function in the script for the training



  Raises:     Exception: If the script is not self-executable.

Options:
  -o, --output TEXT  output file name
  -h, --help         Show this message and exit.
/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/scipy/__init__.py:137: UserWarning: NumPy 1.16.5 or above is required for this version of SciPy (detected version 1.16.4)
  UserWarning)
/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at  /pytorch/c10/cuda/CUDAFunctions.cpp:100.)
  return torch._C._cuda_getDeviceCount() > 0

Example

See Examples/demo:

APIs

add_func(script, func_name, variables)[source]

Adds wrapper function to the python script.

add_main(script)[source]

Adds a main function to the executable Python file.

add_shenbang(script)[source]

Makes the Python script executable.

get_output_name(experiment_file)[source]

Retrieves the Python script to be executed from the experiment json file

get_param(experiment_file)[source]

Parse experiment file to retrieve hyperparameter names

Parameters

experiment_file – JSON file of the experiment

Returns

list of variable names

Return type

[String]