def test_postprocessing(allTests=False): install_postprocessing() if allTests: try: # run example experiment to have a recent data set to postprocess: build_python() python('code-experiments/build/python/', ['-c', ''' try: import example_experiment as ee except Exception as e: print(e) ee.SOLVER = ee.random_search # which is default anyway ee.suite_name = "bbob-biobj" ee.observer_options['result_folder'] = "RS-bi" # use a short path for Jenkins ee.main() # doctest: +ELLIPSIS ee.suite_name = "bbob" ee.observer_options['result_folder'] = "RS-bb" ee.main() # doctest: +ELLIPSIS '''], verbose=verbosity) # now run all tests python('code-postprocessing/cocopp', ['__main__.py', 'all'], verbose=verbosity) except subprocess.CalledProcessError: sys.exit(-1) finally: # always remove folder of previously run experiments: shutil.rmtree('code-experiments/build/python/exdata/') else: python('code-postprocessing/cocopp', ['__main__.py'], verbose=verbosity) # also run the doctests in aRTAplots/generate_aRTA_plot.py: python('code-postprocessing/aRTAplots', ['generate_aRTA_plot.py'], verbose=verbosity) # python('code-postprocessing', ['-m', 'cocopp']) if 11 < 3: # provisorial test fo biobj data run_c() python('code-experiments/build/c', ['-m', 'cocopp', 'RS_on_bbob-biobj'], verbose=verbosity)
def build_python(): _prep_python() ## Force distutils to use Cython # os.environ['USE_CYTHON'] = 'true' # python('code-experiments/build/python', ['setup.py', 'sdist']) # python(join('code-experiments', 'build', 'python'), ['setup.py', 'install', '--user']) python(join('code-experiments', 'build', 'python'), ['setup.py', 'install', '--user'])
def build_python(): _prep_python() ## Force distutils to use Cython os.environ['USE_CYTHON'] = 'true' # python('build/python', ['setup.py', 'sdist']) python('build/python', ['setup.py', 'install', '--user']) os.environ.pop('USE_CYTHON')
def install_postprocessing(): global release expand_file(join('code-postprocessing', 'setup.py.in'), join('code-postprocessing', 'setup.py'), {'COCO_VERSION': git_version(pep440=True)}) # copy_tree('code-postprocessing/latex-templates', 'code-postprocessing/bbob_pproc/latex-templates') python('code-postprocessing', ['setup.py', 'install', '--user'])
def install_postprocessing(): global release expand_file(join('code-postprocessing', 'setup.py.in'), join('code-postprocessing', 'setup.py'), {'COCO_VERSION': git_version(pep440=True)}) # copy_tree('code-postprocessing/latex-templates', 'code-postprocessing/cocopp/latex-templates') python('code-postprocessing', ['setup.py', 'install', '--user'], verbose=verbosity)
def test_postprocessing(): install_postprocessing() python('code-postprocessing/bbob_pproc', ['__main__.py']) # python('code-postprocessing', ['-m', 'bbob_pproc']) if 11 < 3: # provisorial test fo biobj data run_c() python('code-experiments/build/c', ['-m', 'bbob_pproc', 'RS_on_bbob-biobj'])
def build_python(package_install_option=[]): _prep_python() ## Force distutils to use Cython # os.environ['USE_CYTHON'] = 'true' # python('code-experiments/build/python', ['setup.py', 'sdist']) # python(join('code-experiments', 'build', 'python'), # ['setup.py', 'install', '--user']) python(join('code-experiments', 'build', 'python'), ['setup.py', 'install'] + package_install_option, custom_exception_handler=install_error)
def install_postprocessing(): ''' Installs the COCO postprocessing as python module. ''' global RELEASE expand_file(join('code-postprocessing', 'setup.py.in'), join('code-postprocessing', 'setup.py'), {'COCO_VERSION': git_version(pep440=True)}) # copy_tree('code-postprocessing/latex-templates', 'code-postprocessing/cocopp/latex-templates') python('code-postprocessing', ['setup.py', 'install', '--user'], verbose=_verbosity)
def run_python_example(): """ Builds and installs the Python module `IOHprofiler_python` and runs the `example_experiment.py` as a simple test case. """ build_python() try: python(os.path.join('code-experiments', 'build', 'python'), ['example_experiment.py']) except subprocess.CalledProcessError: sys.exit(-1)
def install_postprocessing(package_install_option = []): ''' Installs the COCO postprocessing as python module. ''' global RELEASE expand_file(join('code-postprocessing', 'setup.py.in'), join('code-postprocessing', 'setup.py'), {'COCO_VERSION': git_version(pep440=True)}) # copy_tree('code-postprocessing/latex-templates', 'code-postprocessing/cocopp/latex-templates') python('code-postprocessing', ['setup.py', 'install'] + package_install_option, verbose=_verbosity, custom_exception_handler=install_error)
def run_python(test=False, package_install_option = []): """ Builds and installs the Python module `cocoex` and runs the `example_experiment.py` as a simple test case. If `test` is True, it runs, in addition, the tests in `coco_test.py`.""" build_python(package_install_option=package_install_option) try: if test: python(os.path.join('code-experiments', 'build', 'python'), ['coco_test.py']) python(os.path.join('code-experiments', 'build', 'python'), ['example_experiment.py', 'bbob']) except subprocess.CalledProcessError: sys.exit(-1)
def install_preprocessing(): global release expand_file(join('code-preprocessing/archive-update', 'setup.py.in'), join('code-preprocessing/archive-update', 'setup.py'), {'COCO_VERSION': git_version(pep440=True)}) build_python() amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], 'code-preprocessing/archive-update/interface/coco.c', release, {"COCO_VERSION": git_version(pep440=True)}) expand_file('code-experiments/src/coco.h', 'code-preprocessing/archive-update/interface/coco.h', {'COCO_VERSION': git_version(pep440=True)}) python('code-preprocessing/archive-update', ['setup.py', 'install', '--user'], verbose=verbosity)
def test_python(): _prep_python() python('code-experiments/build/python', ['setup.py', 'check', '--metadata', '--strict'], verbose=verbosity) ## Now install into a temporary location, run test and cleanup python_temp_home = tempfile.mkdtemp(prefix="coco") python_temp_lib = os.path.join(python_temp_home, "lib", "python") try: ## We setup a custom "homedir" here into which we install our ## coco extension and then use that temporary installation for ## the tests. Otherwise we would run the risk of contaminating ## the Python installation of the build/test machine. os.makedirs(python_temp_lib) os.environ['PYTHONPATH'] = python_temp_lib os.environ['USE_CYTHON'] = 'true' python('code-experiments/build/python', ['setup.py', 'install', '--home', python_temp_home], verbose=verbosity) python('code-experiments/build/python', ['coco_test.py', 'bbob2009_testcases.txt'], verbose=verbosity) python('code-experiments/build/python', ['coco_test.py', 'bbob2009_testcases2.txt'], verbose=verbosity) os.environ.pop('USE_CYTHON') os.environ.pop('PYTHONPATH') except subprocess.CalledProcessError: sys.exit(-1) finally: shutil.rmtree(python_temp_home)
def install_preprocessing(package_install_option = []): global RELEASE expand_file(join('code-preprocessing/archive-update', 'setup.py.in'), join('code-preprocessing/archive-update', 'setup.py'), {'COCO_VERSION': git_version(pep440=True)}) build_python(package_install_option = package_install_option) amalgamate(CORE_FILES + ['code-experiments/src/coco_runtime_c.c'], 'code-preprocessing/archive-update/interface/coco.c', RELEASE, {"COCO_VERSION": git_version(pep440=True)}) expand_file('code-experiments/src/coco.h', 'code-preprocessing/archive-update/interface/coco.h', {'COCO_VERSION': git_version(pep440=True)}) python('code-preprocessing/archive-update', ['setup.py', 'install'] + package_install_option, verbose=_verbosity, custom_exception_handler=install_error)
def build_c(): """ Builds the C source code """ global release amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], 'code-experiments/build/c/coco.c', release) copy_file('code-experiments/src/coco.h', 'code-experiments/build/c/coco.h') copy_file('code-experiments/build/c/coco.c', 'code-experiments/examples/bbob2009-c-cmaes/coco.c') copy_file('code-experiments/build/c/coco.h', 'code-experiments/examples/bbob2009-c-cmaes/coco.h') write_file(git_revision(), "code-experiments/build/c/REVISION") write_file(git_version(), "code-experiments/build/c/VERSION") if 11 < 3: python('code-experiments/build/c', ['make.py', 'clean']) python('code-experiments/build/c', ['make.py', 'all']) else: make("code-experiments/build/c", "clean") make("code-experiments/build/c", "all")
def build_c(): """ Builds the C source code """ global RELEASE amalgamate(CORE_FILES + ['code-experiments/src/profiler/IOHprofiler_runtime_c.c'], 'code-experiments/build/c/IOHprofiler.c', RELEASE, {"IOHprofiler_VERSION": git_version(pep440=True)}) expand_file('code-experiments/src/profiler/IOHprofiler.h', 'code-experiments/build/c/profiler/IOHprofiler.h', {"IOHprofiler_VERSION": git_version(pep440=True)}) write_file(git_revision(), "code-experiments/build/c/REVISION") write_file(git_version(), "code-experiments/build/c/VERSION") if 11 < 3: python('code-experiments/build/c', ['make.py', 'clean'], verbose=_verbosity) python('code-experiments/build/c', ['make.py', 'all'], verbose=_verbosity) else: make("code-experiments/build/c", "clean", verbose=_verbosity) make("code-experiments/build/c", "all", verbose=_verbosity)
def build_c(): """ Builds the C source code """ global release amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], 'code-experiments/build/c/coco.c', release, {"COCO_VERSION": git_version(pep440=True)}) expand_file('code-experiments/src/coco.h', 'code-experiments/build/c/coco.h', {"COCO_VERSION": git_version(pep440=True)}) copy_file('code-experiments/build/c/coco.c', 'code-experiments/examples/bbob2009-c-cmaes/coco.c') expand_file('code-experiments/build/c/coco.h', 'code-experiments/examples/bbob2009-c-cmaes/coco.h', {'COCO_VERSION': git_version(pep440=True)}) write_file(git_revision(), "code-experiments/build/c/REVISION") write_file(git_version(), "code-experiments/build/c/VERSION") if 11 < 3: python('code-experiments/build/c', ['make.py', 'clean'], verbose=verbosity) python('code-experiments/build/c', ['make.py', 'all'], verbose=verbosity) else: make("code-experiments/build/c", "clean", verbose=verbosity) make("code-experiments/build/c", "all", verbose=verbosity)
def run_sandbox_python(directory, script_filename= os.path.join('code-experiments', 'build', 'python', 'example_experiment.py')): """run a python script after building and installing `cocoex` in a new environment.""" _prep_python() python('code-experiments/build/python', ['setup.py', 'check', '--metadata', '--strict'], verbose=_verbosity) ## Now install into a temporary location, run test and cleanup python_temp_home = tempfile.mkdtemp(prefix="coco") python_temp_lib = os.path.join(python_temp_home, "lib", "python") try: ## We setup a custom "homedir" here into which we install our ## coco extension and then use that temporary installation for ## the tests. Otherwise we would run the risk of contaminating ## the Python installation of the build/test machine. os.makedirs(python_temp_lib) os.environ['PYTHONPATH'] = python_temp_lib os.environ['USE_CYTHON'] = 'true' python('code-experiments/build/python', ['setup.py', 'install', '--home', python_temp_home], verbose=_verbosity, custom_exception_handler=install_error) python(directory, [script_filename]) os.environ.pop('USE_CYTHON') os.environ.pop('PYTHONPATH') except subprocess.CalledProcessError: sys.exit(-1) finally: shutil.rmtree(python_temp_home)
def run_sandbox_python(directory, script_filename= os.path.join('code-experiments', 'build', 'python', 'example_experiment.py')): """run a python script after building and installing `cocoex` in a new environment.""" _prep_python() python('code-experiments/build/python', ['setup.py', 'check', '--metadata', '--strict']) ## Now install into a temporary location, run test and cleanup python_temp_home = tempfile.mkdtemp(prefix="coco") python_temp_lib = os.path.join(python_temp_home, "lib", "python") try: ## We setup a custom "homedir" here into which we install our ## coco extension and then use that temporary installation for ## the tests. Otherwise we would run the risk of contaminating ## the Python installation of the build/test machine. os.makedirs(python_temp_lib) os.environ['PYTHONPATH'] = python_temp_lib os.environ['USE_CYTHON'] = 'true' python('code-experiments/build/python', ['setup.py', 'install', '--home', python_temp_home]) python(directory, [script_filename]) os.environ.pop('USE_CYTHON') os.environ.pop('PYTHONPATH') except subprocess.CalledProcessError: sys.exit(-1) finally: shutil.rmtree(python_temp_home)
def test_postprocessing(all_tests=False, package_install_option=[]): install_postprocessing(package_install_option=package_install_option) try: if all_tests: # run example experiment to have a recent data set to postprocess: build_python(package_install_option=package_install_option) python('code-experiments/build/python/', [ '-c', ''' from __future__ import print_function try: import example_experiment as ee except Exception as e: print(e) ee.SOLVER = ee.random_search # which is default anyway for ee.suite_name, ee.observer_options['result_folder'] in [ ["bbob-biobj", "RS-bi"], # use a short path for Jenkins ["bbob", "RS-bb"], ["bbob-constrained", "RS-co"], ["bbob-largescale", "RS-la"], ["bbob-mixint", "RS-mi"], ["bbob-biobj-mixint", "RS-bi-mi"] ]: print(" suite %s" % ee.suite_name, end=' ') # these prints are swallowed if ee.suite_name in ee.cocoex.known_suite_names: print("testing into folder %s" % ee.observer_options['result_folder']) ee.main() else: print("is not known") ''' ], verbose=_verbosity) # now run all tests python('code-postprocessing/cocopp', ['test.py', 'all', sys.executable], verbose=_verbosity) else: python('code-postprocessing/cocopp', ['test.py', sys.executable], verbose=_verbosity) # also run the doctests in aRTAplots/generate_aRTA_plot.py: python('code-postprocessing/aRTAplots', ['generate_aRTA_plot.py'], verbose=_verbosity) except subprocess.CalledProcessError: sys.exit(-1) finally: # always remove folder of previously run experiments: for s in ['bi', 'bb', 'co', 'la', 'mi', 'bi-mi']: shutil.rmtree('code-experiments/build/python/exdata/RS-' + s, ignore_errors=True)
def test_postprocessing(allTests=False): install_postprocessing() if allTests: python('code-postprocessing/bbob_pproc', ['__main__.py', 'all'], verbose=verbosity) else: python('code-postprocessing/bbob_pproc', ['__main__.py'], verbose=verbosity) # python('code-postprocessing', ['-m', 'bbob_pproc']) if 11 < 3: # provisorial test fo biobj data run_c() python('code-experiments/build/c', ['-m', 'bbob_pproc', 'RS_on_bbob-biobj'], verbose=verbosity)
def test_python(): _prep_python() python('code-experiments/build/python', ['setup.py', 'check', '--metadata', '--strict']) ## Now install into a temporary location, run test and cleanup python_temp_home = tempfile.mkdtemp(prefix="coco") python_temp_lib = os.path.join(python_temp_home, "lib", "python") try: ## We setup a custom "homedir" here into which we install our ## coco extension and then use that temporary installation for ## the tests. Otherwise we would run the risk of contaminating ## the Python installation of the build/test machine. os.makedirs(python_temp_lib) os.environ['PYTHONPATH'] = python_temp_lib os.environ['USE_CYTHON'] = 'true' python('code-experiments/build/python', ['setup.py', 'install', '--home', python_temp_home]) python('code-experiments/build/python', ['coco_test.py', 'bbob2009_testcases.txt']) python('code-experiments/build/python', ['coco_test.py', 'bbob2009_testcases2.txt']) os.environ.pop('USE_CYTHON') os.environ.pop('PYTHONPATH') except subprocess.CalledProcessError: sys.exit(-1) finally: shutil.rmtree(python_temp_home)
def run_preprocessing(): install_preprocessing() python('code-preprocessing/archive-update', ['archive_update.py'])
def install_preprocessing(): amalgamate(core_files + ['code-experiments/src/coco_runtime_c.c'], 'code-preprocessing/archive-update/interface/coco.c', release) copy_file('code-experiments/src/coco.h', 'code-preprocessing/archive-update/interface/coco.h') python('code-preprocessing/archive-update', ['setup.py', 'install', '--user'])
def verify_postprocessing(): install_postprocessing() python('code-postprocessing/bbob_pproc', ['preparehtml.py', '-v'])
def test_preprocessing(): install_preprocessing() python('code-preprocessing/archive-update', ['-m', 'pytest'], verbose=verbosity) python('code-preprocessing/log-reconstruction', ['-m', 'pytest'], verbose=verbosity)
def verify_postprocessing(): install_postprocessing() # This is not affected by the verbosity value. Verbose should always be True. python('code-postprocessing/bbob_pproc', ['preparehtml.py', '-v'], verbose=True)
def build_python(): _prep_python() ## Force distutils to use Cython # os.environ['USE_CYTHON'] = 'true' # python('code-experiments/build/python', ['setup.py', 'sdist']) python('code-experiments/build/python', ['setup.py', 'install', '--user'])
def test_post_processing(): python('code-postprocessing/bbob_pproc', ['__main__.py'])
def test_preprocessing(package_install_option = []): install_preprocessing(package_install_option = package_install_option) python('code-preprocessing/archive-update', ['-m', 'pytest'], verbose=_verbosity) python('code-preprocessing/log-reconstruction', ['-m', 'pytest'], verbose=_verbosity)
def verify_postprocessing(package_install_option = []): install_postprocessing(package_install_option = package_install_option) # This is not affected by the _verbosity value. Verbose should always be True. python('code-postprocessing/cocopp', ['preparehtml.py', '-v'], verbose=True)