Skip to content

Commit

Permalink
Demonstrate that batch works with apply
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Dec 20, 2019
1 parent e7e5aa5 commit c85d679
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/fmu/ensemble/realization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
16 changes: 16 additions & 0 deletions tests/test_realization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c85d679

Please sign in to comment.