From 3932ac451958311335074f5230a98804bf4bf5c1 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 17 Aug 2026 11:07:29 +0200 Subject: [PATCH] #14535 Orion events: Parse boolean keyword values --- GrpcInterface/Python/rips/orion_events.py | 8 +++- .../Python/rips/tests/test_orion_events.py | 42 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/GrpcInterface/Python/rips/orion_events.py b/GrpcInterface/Python/rips/orion_events.py index 6400bd9a92..da11ba087a 100644 --- a/GrpcInterface/Python/rips/orion_events.py +++ b/GrpcInterface/Python/rips/orion_events.py @@ -821,7 +821,13 @@ def _parse_attributes(attr_str: str, loc: SourceLoc) -> Dict[str, AttrValue]: def _infer_value(raw: str) -> AttrScalar: - """Infer int, then float, otherwise keep the raw string.""" + """Infer bool, int, then float; otherwise keep the raw string.""" + upper = raw.upper() + if upper == "TRUE": + return True + if upper == "FALSE": + return False + try: return int(raw) except ValueError: diff --git a/GrpcInterface/Python/rips/tests/test_orion_events.py b/GrpcInterface/Python/rips/tests/test_orion_events.py index 98ccc85d95..96d358ae4d 100644 --- a/GrpcInterface/Python/rips/tests/test_orion_events.py +++ b/GrpcInterface/Python/rips/tests/test_orion_events.py @@ -393,6 +393,19 @@ class TestParsing: # WELL after SCHEDULE switches the sink back to the well block. assert [len(w.events) for w in doc.wells] == [1, 1] + def test_boolean_attributes_are_typed_unless_quoted(self): + text = ( + "ORIONEVENTS 2.0\n" + "SCHEDULE\n" + ' @2024-01-01 RPTRST DEN=True ROCKC=FALSE LABEL="True"\n' + ) + attributes = parse_orion_events(text).schedule_events[0].attributes + + assert attributes["DEN"].value is True + assert attributes["ROCKC"].value is False + assert attributes["LABEL"].value == "True" + assert isinstance(attributes["LABEL"].value, str) + def test_schedule_line_with_arguments_rejected(self): with pytest.raises(OrionParseError, match="SCHEDULE takes no arguments"): parse_orion_events("ORIONEVENTS 2.0\nSCHEDULE NOW\n") @@ -1116,6 +1129,35 @@ class TestOrionEventsIntegration: "DIR, PR" ) in error_msg + def test_rptrst_boolean_values_emit_bare_mnemonics( + self, project_with_case_and_wells + ): + project, case, timeline = project_with_case_and_wells + well = project.well_paths()[0] + document = parse_orion_events( + "ORIONEVENTS 2.0\n" + f'WELL "{well.name}"\n' + " @2024-01-01 WCONHIST STATUS=OPEN\n" + "SCHEDULE\n" + " @2024-01-01 RPTRST BASIC=2 DEN=True ROCKC=True RPORV=True " + "RFIP=True FLOWS=True FLORES=True NORST=False\n" + ) + + report = apply_orion_document(document, timeline, project) + assert report.events_applied == 2 + + schedule = timeline.generate_schedule_text( + eclipse_case=case, export_msw_for_wells=[] + ) + rptrst_block = schedule.split("RPTRST", 1)[1].split("/", 1)[0] + tokens = rptrst_block.split() + + assert "BASIC=2" in tokens + for flag in ("DEN", "ROCKC", "RPORV", "RFIP", "FLOWS", "FLORES"): + assert flag in tokens + assert f"{flag}=True" not in rptrst_block + assert "NORST" not in tokens + def test_apply_creates_perforations_and_schedule(self, project_with_case_and_wells): """End-to-end: parse -> apply -> set_timestamp -> generate schedule.""" project, case, timeline = project_with_case_and_wells