Skip to content

Commit c62349a

Browse files
authored
Match wildcards for missing RFT response property warnings
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 7a78cd8 commit c62349a

6 files changed

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

316325
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
@@ -38,7 +38,7 @@ def _warn_about_missing_summary_responses(
3838
keys_missing_responses = [
3939
key for key in self.keys if not fnmatch.filter(response_keys, key)
4040
]
41-
_warn_about_missing_responses(keys_missing_responses, "key(s)", filename)
41+
_warn_about_missing_responses(keys_missing_responses, "summary", filename)
4242

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

0 commit comments

Comments
 (0)