コード例 #1
0
ファイル: conftest.py プロジェクト: JiayangY/sirepo
def _job_supervisor_setup(request, cfg=None):
    """setup the supervisor"""
    import os
    from pykern.pkcollections import PKDict
    sbatch_module = 'sbatch' in request.module.__name__
    env = PKDict()
    for k, v in os.environ.items():
        if ('PYENV' in k or 'PYTHON' in k):
            continue
        if k in ('PATH', 'LD_LIBRARY_PATH'):
            v2 = []
            for x in v.split(':'):
                if x and 'py2' not in x:
                    v2.append(x)
            v = ':'.join(v2)
        env[k] = v
    if not cfg:
        cfg = PKDict()
    cfg.pkupdate(
        PYKERN_PKDEBUG_WANT_PID_TIME='1',
        SIREPO_FEATURE_CONFIG_JOB='1',
    )
    if sbatch_module:
        cfg.pkupdate(SIREPO_SIMULATION_DB_SBATCH_DISPLAY='testing@123')
    env.pkupdate(PYENV_VERSION='py3', PYTHONUNBUFFERED='1', **cfg)

    import sirepo.srunit
    fc = sirepo.srunit.flask_client(
        cfg=cfg,
        job_run_mode='sbatch' if sbatch_module else None,
    )

    if sbatch_module:
        # must be performed after fc initialized so work_dir is configured
        _config_sbatch_supervisor_env(env)

    import sirepo.srdb
    env.SIREPO_SRDB_ROOT = str(sirepo.srdb.root())

    _job_supervisor_check(env)
    return (env, fc)
コード例 #2
0
def _job_supervisor_setup(request, cfg=None):
    """setup the supervisor"""
    import os
    from pykern.pkcollections import PKDict
    sbatch_module = 'sbatch' in request.module.__name__
    env = PKDict(os.environ)
    if not cfg:
        cfg = PKDict()
    i = '127.0.0.1'
    # different port than default so can run tests when supervisor running
    p = '8002'
    cfg.pkupdate(
        PYKERN_PKDEBUG_WANT_PID_TIME='1',
        SIREPO_FEATURE_CONFIG_JOB='1',
        SIREPO_PKCLI_JOB_SUPERVISOR_IP=i,
        SIREPO_PKCLI_JOB_SUPERVISOR_PORT=p,
    )
    for x in 'DRIVER_LOCAL', 'DRIVER_DOCKER', 'API', 'DRIVER_SBATCH':
        cfg['SIREPO_JOB_{}_SUPERVISOR_URI'.format(x)] = 'http://{}:{}'.format(
            i, p)
    if sbatch_module:
        cfg.pkupdate(SIREPO_SIMULATION_DB_SBATCH_DISPLAY='testing@123')
    env.pkupdate(**cfg)

    import sirepo.srunit
    fc = sirepo.srunit.flask_client(
        cfg=cfg,
        job_run_mode='sbatch' if sbatch_module else None,
    )

    if sbatch_module:
        # must be performed after fc initialized so work_dir is configured
        _config_sbatch_supervisor_env(env)

    import sirepo.srdb
    env.SIREPO_SRDB_ROOT = str(sirepo.srdb.root())

    _job_supervisor_check(env)
    return (env, fc)