Exemplo n.º 1
0
def test_set_stderr_level():

    stderr_level = libE_logger.get_stderr_level()
    assert stderr_level == 35, "Default stderr copying level is 35, found " + \
        str(stderr_level)

    libE_logger.set_stderr_level('DEBUG')
    stderr_level = libE_logger.get_stderr_level()
    assert stderr_level == 10, "Log level should be 10. Found: " + str(
        stderr_level)

    libE_logger.set_stderr_level('INFO')
    stderr_level = libE_logger.get_stderr_level()
    assert stderr_level == 20, "Log level should be 20. Found: " + str(
        stderr_level)

    libE_logger.set_stderr_level('WARNING')
    stderr_level = libE_logger.get_stderr_level()
    assert stderr_level == 30, "Log level should be 30. Found: " + str(
        stderr_level)

    libE_logger.set_stderr_level('MANAGER_WARNING')
    stderr_level = libE_logger.get_stderr_level()
    assert stderr_level == 35, "Log level should be 35. Found: " + str(
        stderr_level)

    libE_logger.set_stderr_level('ERROR')
    stderr_level = libE_logger.get_stderr_level()
    assert stderr_level == 40, "Log level should be 40. Found: " + str(
        stderr_level)

    libE_logger.set_level('ERROR')
    logger = logging.getLogger('libensemble')
    logger.manager_warning('This test message should not log')
Exemplo n.º 2
0
def test_set_log_level():
    # Default
    level = libE_logger.get_level()
    assert level == 20, "Log level should be 20. Found: " + str(level)

    libE_logger.set_level('DEBUG')
    level = libE_logger.get_level()
    assert level == 10, "Log level should be 10. Found: " + str(level)

    libE_logger.set_level('WARNING')
    level = libE_logger.get_level()
    assert level == 30, "Log level should be 30. Found: " + str(level)

    libE_logger.set_level('MANAGER_WARNING')
    level = libE_logger.get_level()
    assert level == 35, "Log level should be 35. Found: " + str(level)

    libE_logger.set_level('ERROR')
    level = libE_logger.get_level()
    assert level == 40, "Log level should be 40. Found: " + str(level)

    libE_logger.set_level('INFO')
    level = libE_logger.get_level()
    assert level == 20, "Log level should be 20. Found: " + str(level)
Exemplo n.º 3
0
#    python3 test_mpi_runners.py --nworkers 3 --comms tcp
#
# The number of concurrent evaluations of the objective function will be 4-1=3.
# """

import os
import numpy as np
from libensemble.message_numbers import WORKER_DONE
from libensemble.libE import libE
from libensemble.gen_funcs.sampling import uniform_random_sample as gen_f
from libensemble.tools import parse_args, add_unique_random_streams
from libensemble.executors.mpi_executor import MPIExecutor
from libensemble import libE_logger

# libE_logger.set_level('DEBUG')  # For testing the test
libE_logger.set_level('INFO')

# Do not change these lines - they are parsed by run-tests.sh
# TESTSUITE_COMMS: mpi local
# TESTSUITE_NPROCS: 2 4

nodes_per_worker = 2


def exp_nodelist_for_worker(exp_list, workerID):
    """Modify expected node-lists based on workerID"""
    comps = exp_list.split()
    new_line = []
    for comp in comps:
        if comp.startswith('node-'):
            new_node_list = []
Exemplo n.º 4
0
{% if fail_on_submit is defined %}
FAIL_ON_SUBMIT = {{ fail_on_submit }}
{% else %}
FAIL_ON_SUBMIT = False
{% endif %}

if PERSIS_GEN:
    from libensemble.gen_funcs.persistent_uniform_sampling import persistent_uniform as gen_f
    from libensemble.alloc_funcs.start_only_persistent import only_persistent_gens as alloc_f
else:
    from libensemble.gen_funcs.sampling import uniform_random_sample as gen_f
    from libensemble.alloc_funcs.give_sim_work_first import give_sim_work_first as alloc_f


libE_logger.set_level('DEBUG')  # INFO is now default

nworkers, is_master, libE_specs, _ = parse_args()

if is_master:
    print('\nRunning with {} workers\n'.format(nworkers))

if not os.path.isfile('./forces.x'):
    if os.path.isfile('./build_forces.sh'):
        import subprocess
        subprocess.check_call(['./build_forces.sh'])
sim_app = os.path.abspath('./forces.x')

# Create executor and register sim to it.
if USE_BALSAM:
    from libensemble.executors.balsam_executor import BalsamMPIExecutor
else:
    print("you shouldn' hit that")
    sys.exit()

from libensemble.tools import parse_args, save_libE_output, \
    add_unique_random_streams
from libensemble import libE_logger

if USE_BALSAM:
    from libensemble.executors.balsam_executor import BalsamMPIExecutor
    exctr = BalsamMPIExecutor(central_mode=True{% if zero_resource_workers is defined %}, zero_resource_workers=[{{ zero_resource_workers }}]{% endif %})
else:
    from libensemble.executors.mpi_executor import MPIExecutor
    exctr = MPIExecutor(central_mode=True{% if zero_resource_workers is defined %}, zero_resource_workers=[{{ zero_resource_workers }}]{% endif %})

libE_logger.set_level('DEBUG')

nworkers, is_master, libE_specs, _ = parse_args()

# Set to full path of warp executable
sim_app = os.path.abspath({{ sim_app }})

# Problem dimension. This is the number of input parameters exposed,
# that LibEnsemble will vary in order to minimize a single output parameter.
n = 4

exctr.register_calc(full_path=sim_app, calc_type='sim')

# State the objective function, its arguments, output, and necessary parameters
# (and their sizes). Here, the 'user' field is for the user's (in this case,
# the simulation) convenience. Feel free to use it to pass number of nodes,
Exemplo n.º 6
0
from libensemble.libE_manager import ManagerException
from libensemble.tools import parse_args, save_libE_output, add_unique_random_streams
from libensemble import libE_logger
from forces_support import test_libe_stats, test_ensemble_dir, check_log_exception

USE_BALSAM = False
PERSIS_GEN = False

if PERSIS_GEN:
    from libensemble.gen_funcs.persistent_uniform_sampling import persistent_uniform as gen_f
    from libensemble.alloc_funcs.start_only_persistent import only_persistent_gens as alloc_f
else:
    from libensemble.gen_funcs.sampling import uniform_random_sample as gen_f
    from libensemble.alloc_funcs.give_sim_work_first import give_sim_work_first as alloc_f

libE_logger.set_level('INFO')  # INFO is now default

nworkers, is_master, libE_specs, _ = parse_args()

if is_master:
    print('\nRunning with {} workers\n'.format(nworkers))

sim_app = os.path.join(os.getcwd(), 'forces.x')

# Normally would be pre-compiled
if not os.path.isfile('forces.x'):
    if os.path.isfile('build_forces.sh'):
        import subprocess
        subprocess.check_call(['./build_forces.sh'])

# Create executor and register sim to it.