Skip to content

Commit 87d7a72

Browse files
authored
Match wildcards for missing RFT response property warnings (#14178)
The old implementation assumed it was enough to look for responses matching RFT well and time, however, this leaves the user with little information of which property was not found given existing well and time.
1 parent c52a7f9 commit 87d7a72

6 files changed

Lines changed: 238 additions & 213 deletions

File tree

src/ert/config/response_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def _warn_about_missing_responses(
1717
missing_items: list[str],
18-
item_label: Literal["key(s)", "well(s) at time(s)"],
18+
response_type: Literal["summary", "RFT"],
1919
filename: str,
2020
) -> None:
2121
if not missing_items:
@@ -24,7 +24,7 @@ def _warn_about_missing_responses(
2424
num_excess = len(missing_items) - _RESPONSE_WARNING_LIMIT
2525

2626
warning = (
27-
f"Could not find responses for {item_label} in '{filename}':\n"
27+
f"Could not find responses for {response_type} key(s) in '{filename}':\n"
2828
+ "\n".join(missing_items[:_RESPONSE_WARNING_LIMIT])
2929
+ (f"\n... and {num_excess} other missing responses" if num_excess > 0 else "")
3030
)

src/ert/config/rft_config.py

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -289,27 +289,36 @@ def _warn_about_missing_rft_responses(
289289
rft_data: dict[tuple[WellName, datetime.date], RFTConfig.ValidRFTEntry],
290290
rft_filename: str,
291291
) -> None:
292-
well_times = {
293-
(well, time)
294-
for well, time_dict in self.data_to_read.items()
295-
for time in time_dict
296-
}
297-
well_times_with_response = {
298-
f"{well}:{time.isoformat()}" for well, time in rft_data
299-
}
300-
well_times_to_warn: set[tuple[str, str]] = {
301-
(well, time)
302-
for well, time in well_times
303-
if not fnmatch.filter(
304-
well_times_with_response,
305-
f"{well}:{time}",
306-
)
307-
}
308-
formatted_items = [
309-
f"{well=} : {time=}" for well, time in sorted(well_times_to_warn)
292+
missing_response_properties = defaultdict(list)
293+
for well, time_dict in self.data_to_read.items():
294+
for time in time_dict:
295+
expected_properties = set(time_dict[time])
296+
# Find all well-time tuples matching expected well-time pattern
297+
well_time_tuple_matches = [
298+
t
299+
for t in rft_data
300+
if fnmatch.fnmatch(t[0], well)
301+
and fnmatch.fnmatch(t[1].isoformat(), time)
302+
]
303+
# Find all properties matching expected property patterns
304+
property_matches = set()
305+
for well_time in well_time_tuple_matches:
306+
properties_in_response = rft_data[well_time].property_values.keys()
307+
property_matches |= {
308+
exp_prop
309+
for exp_prop in expected_properties
310+
if fnmatch.filter(properties_in_response, exp_prop)
311+
}
312+
313+
for missing_property in expected_properties - property_matches:
314+
missing_response_properties[well, time].append(missing_property)
315+
316+
formatted_missing_rft_responses = [
317+
f"well='{well}' : time='{time}' : properties={sorted(properties)}"
318+
for (well, time), properties in missing_response_properties.items()
310319
]
311320
_warn_about_missing_responses(
312-
formatted_items, "well(s) at time(s)", rft_filename
321+
sorted(formatted_missing_rft_responses), "RFT", rft_filename
313322
)
314323

315324
def read_from_file(self, run_path: str, iens: int, iter_: int) -> pl.DataFrame:

src/ert/config/summary_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _warn_about_missing_summary_responses(
3737
keys_missing_responses = [
3838
key for key in self.keys if not fnmatch.filter(response_keys, key)
3939
]
40-
_warn_about_missing_responses(keys_missing_responses, "key(s)", filename)
40+
_warn_about_missing_responses(keys_missing_responses, "summary", filename)
4141

4242
def read_from_file(self, run_path: str, iens: int, iter_: int) -> pl.DataFrame:
4343
filename = substitute_runpath_name(self.input_files[0], iens, iter_)

0 commit comments

Comments
 (0)