def test_new_executable_op_without_ds(self): op = new_subprocess_op(OpMetaInfo('make_entropy', inputs={ 'num_steps': {'data_type': int}, 'period': {'data_type': float}, }, outputs={ 'return': {'data_type': int} }), MAKE_ENTROPY_EXE + " {num_steps} {period}") exit_code = op(num_steps=5, period=0.05) self.assertEqual(exit_code, 0)
def test_new_executable_op_with_ds_file(self): op = new_subprocess_op(OpMetaInfo('filter_ds', inputs={ 'ifile': {'data_type': FileLike}, 'ofile': {'data_type': FileLike}, 'var': {'data_type': VarName}, }, outputs={ 'return': {'data_type': int} }), FILTER_DS_EXE + " {ifile} {ofile} {var}") ofile = os.path.join(DIR, 'test_data', 'filter_ds.nc') if os.path.isfile(ofile): os.remove(ofile) exit_code = op(ifile=SOILMOISTURE_NC, ofile=ofile, var='sm') self.assertEqual(exit_code, 0) self.assertTrue(os.path.isfile(ofile)) os.remove(ofile)
def test_new_executable_op_with_ds_in_mem(self): op = new_subprocess_op( OpMetaInfo('filter_ds', inputs={ 'ds': { 'data_type': xr.Dataset, 'write_to': 'ifile' }, 'var': { 'data_type': VarName }, }, outputs={ 'return': { 'data_type': xr.Dataset, 'read_from': 'ofile' } }), FILTER_DS_EXE + " {ifile} {ofile} {var}") ds = xr.open_dataset(SOILMOISTURE_NC) ds_out = op(ds=ds, var='sm') self.assertIsNotNone(ds_out) self.assertIsNotNone('sm' in ds_out)
def test_new_executable_op_with_ds_in_mem(self): op = new_subprocess_op(OpMetaInfo('filter_ds', inputs={ 'ds': { 'data_type': xr.Dataset, 'write_to': 'ifile' }, 'var': { 'data_type': VarName }, }, outputs={ 'return': { 'data_type': xr.Dataset, 'read_from': 'ofile' } }), FILTER_DS_EXE + " {ifile} {ofile} {var}") ds = xr.open_dataset(SOILMOISTURE_NC) ds_out = op(ds=ds, var='sm') self.assertIsNotNone(ds_out) self.assertIsNotNone('sm' in ds_out)