From 687959c0945dc698d8c55a005af6ac0f50de101d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Berland?= Date: Fri, 13 Dec 2019 13:06:22 +0100 Subject: [PATCH] Demonstrate that batch works with apply --- src/fmu/ensemble/realization.py | 2 +- tests/test_realization.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/fmu/ensemble/realization.py b/src/fmu/ensemble/realization.py index 2d176024..d6bd0599 100644 --- a/src/fmu/ensemble/realization.py +++ b/src/fmu/ensemble/realization.py @@ -214,7 +214,7 @@ def process_batch(self, batch): str(cmd[fn_name]), ) if fn_name not in allowed_functions: - logger.warning("process_batch skips illegal function: " + fn_name) + logger.warning("process_batch skips illegal function: %s", fn_name) continue assert isinstance(cmd[fn_name], dict) getattr(self, fn_name)(**cmd[fn_name]) diff --git a/tests/test_realization.py b/tests/test_realization.py index d0b67460..cf228934 100644 --- a/tests/test_realization.py +++ b/tests/test_realization.py @@ -175,6 +175,7 @@ def test_batch(): {"load_scalar": {"localpath": "npv.txt"}}, {"load_smry": {"column_keys": "FOPT", "time_index": "yearly"}}, {"load_smry": {"column_keys": "*", "time_index": "daily"}}, + {"illegal-ignoreme": {}}, ], ) assert real.get_df("npv.txt") == 3444 @@ -819,6 +820,21 @@ def rms_vol2df(kwargs): ) assert real.get_df("geogrid--oil")["STOIIP_OIL"].sum() > 0 + # Run rms_vol2df in batch when initializing: + real = ensemble.ScratchRealization( + realdir, + batch=[ + { + "apply": { + "callback": rms_vol2df, + "filename": "share/results/volumes/" + "geogrid_vol_oil_1.txt", + "localpath": "share/results/volumes/geogrid--oil.csv", + } + } + ], + ) + assert real.get_df("geogrid--oil")["STOIIP_OIL"].sum() > 0 + def test_drop(): """Test the drop functionality, where can delete