Beispiel #1
0
def create_arg_test(env=None):
    hutch = 'temp_create'
    test_dir = CFG_PATH.parent.parent.parent / hutch
    if test_dir.exists():
        shutil.rmtree(test_dir)

    with cli_args(['hutch_python', '--create', hutch]):
        with restore_logging():
            setup_cli_env()

    assert test_dir.exists()

    # Make sure conf.yml is valid
    load(str(test_dir / 'conf.yml'))

    # Make sure we picked the correct env
    if env is not None:
        with (test_dir / 'temp_createversion').open() as f:
            lines = f.readlines()
        has_env = False
        for line in lines:
            if 'CONDA_ENVNAME' in line:
                has_env = True
                assert env == line.split("'")[-2]
                break
        assert has_env

    shutil.rmtree(test_dir)
Beispiel #2
0
def test_exp_override():
    logger.debug('test_exp_override')
    set_sim_mode(True)
    # Should work with or without hutch name
    objs = load(os.path.join(os.path.dirname(__file__), 'conf.yaml'),
                SimpleNamespace(exp='x011'))
    assert hasattr(objs['x'], 'cats')
    objs = load(os.path.join(os.path.dirname(__file__), 'conf.yaml'),
                SimpleNamespace(exp='tstx011'))
    assert hasattr(objs['x'], 'cats')
Beispiel #3
0
def test_create_arg():
    logger.debug('test_create_arg_dev')
    hutch = 'temp_create'
    test_dir = CFG_PATH.parent.parent.parent / hutch
    if test_dir.exists():
        shutil.rmtree(test_dir)

    with cli_args(['hutch_python', '--create', hutch]):
        with restore_logging():
            main()

    assert test_dir.exists()

    # Make sure conf.yml is valid
    load(str(test_dir / 'conf.yml'))
    shutil.rmtree(test_dir)
Beispiel #4
0
def test_file_load():
    logger.debug('test_file_load')
    set_sim_mode(True)
    objs = load(os.path.join(os.path.dirname(__file__), 'conf.yaml'))
    should_have = ('x', 'unique_device', 'calc_thing', 'daq', 'tst_beampath')
    err = '{} was overriden by a namespace'
    for elem in should_have:
        assert not isinstance(objs[elem], SimpleNamespace), err.format(elem)
    assert 'tst' in objs
    assert len(Presets._paths) == 2
Beispiel #5
0
def test_no_file():
    logger.debug('test_no_file')
    objs = load()
    assert len(objs) > 1
Beispiel #6
0
import os.path
import sys

from hutch_python.load_conf import load
from hutch_python.log_setup import setup_logging
from pcdsdaq.sim import set_sim_mode

sys.path.insert(0, "/reg/g/pcds/pyps/apps/hutch-python/tst")

# Do the normal hutch-python loading
set_sim_mode(True)
cfg = '/cds/group/pcds/pyps/apps/hutch-python/tst/conf.yml'
setup_logging(dir_logs=os.path.join(os.path.dirname(cfg), 'logs'))
objs = load(cfg=cfg)

# Make some post-adjustments for queue-server
# Disable the bec plots for the server process (keep the table)
objs['bec'].disable_plots()
# Make all objects available to queue-server
globals().update(objs)
# Additionally expand the plan namespace so that the queue-server sees it
globals().update(vars(objs['bp']))
# Additionally expand the experiment object so that the queue-server sees it
try:
    globals().update(vars(objs['user']))
except KeyError:
    pass