예제 #1
0
def test_main():
    tb_json_names = glob.glob(os.path.join(_this_dir, '*/testbench_manifest.json'))
    tb_jsons = [(tb_json_name, open(tb_json_name, 'r').read()) for tb_json_name in tb_json_names]
    try:
        for input_filename in glob.glob(_this_dir + '/mdao_config*json'):
            output_filename = input_filename + '.output.csv'
            with run_regression(output_filename):
                run_mdao.run(input_filename)

        with run_regression(os.path.join(_this_dir, 'single_run.csv')):
            run_mdao.run_one('mdao_config_constant.json', (('designVariable.Naca_Code', 4040), ))

        with run_regression(os.path.join(_this_dir, 'run_failure.csv')):
            run_mdao.run_one('mdao_config_basic_CyPhy.json', (('designVariable.y', 0), ('designVariable.x', 'Ia')))

    finally:
        for tb_json_name, contents in tb_jsons:
            with open(tb_json_name, 'w') as tb_json:
                tb_json.write(contents)
예제 #2
0
def run_one(self, zipkey, *args):
    try:
        if len(_zip_cache) > 10:
            _zip_cache.clear()
        wdir = tempfile.mkdtemp(prefix='mdao-')
        os.chdir(wdir)
        print('Executing {} in {}'.format(zipkey, wdir))
        input_zip = _zip_cache.get(zipkey)
        if input_zip is None:
            _zip_cache[zipkey] = input_zip = redis_conn.get(zipkey)
        with zipfile.ZipFile(StringIO.StringIO(input_zip), 'r') as zf:
            zf.extractall()
        try:
            run_mdao.run_one('mdao_config.json', *args)
        except Exception as exc:
            self.retry(exc=exc)
        os.chdir('/')
        shutil.rmtree(wdir)
    except WindowsError as e:
        raise OSError(e.errno, traceback.traceback.format_exc())
예제 #3
0
def run_one(self, zipkey, *args):
    try:
        if len(_zip_cache) > 10:
            _zip_cache.clear()
        wdir = tempfile.mkdtemp(prefix='mdao-')
        os.chdir(wdir)
        print('Executing {} in {}'.format(zipkey, wdir))
        input_zip = _zip_cache.get(zipkey)
        if input_zip is None:
            _zip_cache[zipkey] = input_zip = redis_conn.get(zipkey)
        with zipfile.ZipFile(StringIO.StringIO(input_zip), 'r') as zf:
            zf.extractall()
        try:
            run_mdao.run_one('mdao_config.json', *args)
        except Exception as exc:
            self.retry(exc=exc)
        os.chdir('/')
        shutil.rmtree(wdir)
    except WindowsError as e:
        raise OSError(e.errno, traceback.traceback.format_exc())
예제 #4
0
 def test_run_failure(self):
     with run_regression(os.path.join(_this_dir, 'run_failure.csv')):
         run_mdao.run_one('mdao_config_basic_CyPhy.json',
                          (('designVariable.y', 0),
                           ('designVariable.x', 'Ia')))
예제 #5
0
 def test_single_run(self):
     with run_regression(os.path.join(_this_dir, 'single_run.csv')):
         run_mdao.run_one('mdao_config_constant.json',
                          (('designVariable.Naca_Code', 4040), ))