Commit Graph
237 Commits
Author SHA1 Message Date
kriben cdcc22cc42 Python code linting changes detected by ruff 2026-03-26 11:20:41 +01:00
Magne Sjaastad ba9e3c7e26 Add example on creation of regions based on existing polygons 2026-03-26 11:20:41 +01:00
Kristian Bendiksen 6bf4498776 Python: Fix ruff E402 lint errors in __init__.py
Move typing import to top of file and add noqa: E402 comments
to imports that must follow the sys.path.insert call.
2026-03-26 11:20:41 +01:00
Kristian Bendiksen 3286a15310 #12452 Python: Replace logger.error with raise RipsError in instance.py
Error conditions in launch() and find() now raise RipsError instead of
logging and returning None, making failures explicit. Updated test to
expect the exception.
2026-03-26 11:20:41 +01:00
Kristian Bendiksen f2cf8e8830 #12452 Python: Replace print() with logging API in rips module 2026-03-26 11:20:41 +01:00
Magne Sjaastad fab00a3fc4 Add test case for completion data for dual porosity models
Dual porosity models reads data for completion calculations from the Fracture part of the grid model. The generated completion data contains references to IJK cells in the fracture section of the grid.
2026-02-24 14:24:15 +01:00
Kristian Bendiksen f52af2c5d0 Fix implicit int-to-bool conversion in gRPC WELSEGS export
Remove stale timeStep parameter that was silently converted to false
for exportCompletionsAfterMainBoreSegments after the function signature
was refactored. Use correct defaults instead.
2026-02-20 13:43:58 +01:00
Kristian Bendiksen 1ec53cc3f2 #13425 Fix ICD/AICD valve output in schedule generation
ICD valves now produce WSEGVALV and AICD valves now produce WSEGAICD
in the generated schedule. Three root causes were fixed:

- Create per-event valve templates with proper parameters instead of
  reusing default templates that lack orifice diameter and AICD fields
- Use perforation interval range for ICD/AICD valve positioning so
  valveLocations() returns non-empty results for the accumulator
- Add 5 AICD parameter fields to the Python API and event classes
2026-02-12 08:15:22 +01:00
Kristian Bendiksen 82e2dbc434 #13425 Fix WELSEGS date scoping: tubing events only appear at their event dates
Tubing event diameter/roughness values were leaking into earlier date
sections in the generated schedule. The WELSEGS collection functions
did not filter intervals by export date, unlike COMPSEGS and other
keywords which already received the exportDate parameter.

Thread exportDate through collectWelsegsData, collectWelsegsDataRecursively,
and collectWelsegsSegment. Add date-aware overloads of getDiameterAtMD and
getRoughnessAtMD that use isActiveOnDate to filter intervals. Update test
to verify tubing values only appear at their scheduled dates.
2026-02-12 08:15:22 +01:00
Kristian Bendiksen a4dad97024 #13425 Add time-dependent well events and schedule data generation
Implement timeline-based event system for managing temporal changes in
well completions, perforations, valves, and production controls.

Features:
- Event timeline container with date-based querying
- Six event types: PERF, VALVE, TUBING, WSTATE, WTYPE, WCONTROL
- Schedule keyword generation (DATES, COMPDAT, WELSEGS, WCONPROD, WCONINJE)
- Multi-well schedule generation support
- Python GRPC API for event management
- YAML configuration file support
- Comprehensive test suite

Implementation:
- New directory: ApplicationLibCode/ProjectDataModel/WellEvents/
- Event classes inherit from RimWellEvent base class
- RimWellEventTimeline integrated into RimWellPath
- RicScheduleDataGenerator for multi-well schedule export
- Python API: event_timeline(), add_perf_event(), add_valve_event(), etc.
- Tests verify all event types and YAML config parsing

#13425 Add date tracking to valves and diameter/roughness intervals

Add creation date fields to RimWellPathValve and RimDiameterRoughnessInterval
to support filtering objects by date during completion data export.

- Add m_useCustomStartDate and m_startDate fields
- Add enableCustomStartDate(), setCustomStartDate(), isActiveOnDate() methods
- Set creation dates when applying valve and tubing events in RimWellEventTimeline

#13425 Add date-based filtering for schedule data export

Add optional export date parameter to MSW data collection functions to filter
valves and perforations based on their creation dates during schedule export.

- Add exportDate parameter to collectWsegvalvData, collectWsegAicdData,
  collectWsegSicdData, and collectCompsegData functions
- Filter valves by checking isActiveOnDate() on the associated RimWellPathValve
- Add RimPerforationInterval reference to RicMswPerforation for date filtering
- Pass export date from RicScheduleDataGenerator through the extraction chain

This ensures segment numbers reflect the full model while only including
objects active on the export date in output keywords.

Add test to prove compsegs changes over time.

#13425 Fix mypy type checking errors in well_events.py

- Add type annotations to all function parameters
- Fix generic type hints (dict -> Dict[str, Any])
- Import Any type for proper type safety
- Add type: ignore for method reassignment
- All 31 tests pass

#13425 Add schedule-level keyword events for non-well-specific keywords

Add a new event type called "Keyword Event" for schedule-level Eclipse
keywords (RPTRST, GRUPTREE, RPTSCHED, etc.) that are NOT tied to a
specific well path. This complements the existing RimWellEventKeyword
which operates at the well level.

- Add RimKeywordEvent class inheriting from RimWellEvent with null wellPath
- Add SCHEDULE_KEYWORD enum value to EventType
- Add addKeywordEvent() method to RimWellEventTimeline
- Add AddKeywordEvent Python API method to RimcWellEventTimeline
- Update RicScheduleDataGenerator to output global keywords after well sections
- Add Python wrapper add_keyword_event() with type inference
- Add tests and examples for RPTRST, GRUPTREE keywords
2026-02-12 08:15:22 +01:00
Kristian Bendiksen f4dd29f70f Python: Fix ruff linting warnings
- Remove unused imports in test files
- Fix bare except clause to use except Exception
- Fix None comparisons to use 'is not None' / 'is None'
- Remove unused variable assignments
- Add noqa comments for intentional patterns (star imports, method
  redefinition for different classes, import after sys.path modification)
- Apply ruff formatting
2026-02-09 08:27:23 +01:00
Kristian Bendiksen 83eda0adcf Python: Replace os.spawnv with subprocess.Popen in Instance.launch
Use subprocess.Popen instead of os.spawnv to launch ResInsight, avoiding
fork() deprecation warnings in multi-threaded contexts with gRPC.
2026-02-09 08:27:23 +01:00
Kristian Bendiksen c09e09007b Python: Use spawn instead of fork for multiprocessing in tests
Set multiprocessing start method to "spawn" in conftest.py to avoid
fork() deprecation warnings when gRPC threads are present.
2026-02-09 08:27:23 +01:00
JJ 49147019a7 Python: Return names of imported properties (#13576)
* Python: Return names of imported properties
2026-02-06 19:34:34 +01:00
Kristian Bendiksen 0dfbcd34f6 #13562 Add python api for getting parent well path
Fixes #13562.
2026-02-06 13:32:22 +01:00
Kristian Bendiksen 9ad2a76f1d #13571 Python: Fix issubclass check for PDM method return types
- Use issubclass() instead of exact class name matching
- Instantiate using child class to preserve subclass type
- Enables polymorphic return types in Python API

Fixes #13571.
2026-02-06 13:32:22 +01:00
Kristian Bendiksen ed995d1891 #10749 Python: Unify TypeVars and add bound for mypy compatibility
- Unify class-level TypeVars D and X into single module-level PdmObjectT
- Add bound="PdmObjectBase" for better type safety

Fixes #10749.
2026-02-06 13:32:22 +01:00
Kristian Bendiksen 71eb461f13 #13528 Add .w extension support for RMSWell files
Files with .w extension are now interpreted as RMSWell format instead of
falling back to ASCII parsing. Added file dialog filter and Python test.
2026-02-04 18:07:10 +01:00
Kristian Bendiksen da923b5731 #10751 Fix os.kill() on Windows by using SIGTERM instead of CTRL_C_EVENT
Fixes #10751.
2026-02-04 15:00:02 +01:00
Magne Sjaastad 5356f078a5 #13435 Improve string list parsing for backslashes and quotes
Enhanced parsing in PdmFieldScriptingCapabilityIOHandler to correctly handle backslashes and escape sequences in both quoted and unquoted strings. Unquoted Windows paths now preserve backslashes, while quoted strings process escape sequences as expected. Added unit tests to verify correct handling of both cases.

Add tests for Windows-style path handling in rips API

Introduce test_windows_paths.py with two pytest tests to verify correct handling of Windows-style file paths (backslashes) in the rips Python API.
2026-02-02 16:35:53 +01:00
JJ 94c3059fd8 Add support for SICD valves (#13496)
* Add SICD parameters
* Add wsegsicd valves to completion export
* Add python method to read template info from valve
* Update tests
2026-01-29 11:16:05 +01:00
Magne Sjaastad c98777e9bb Lower log level for config and service init messages
Changed logging from info to debug for config imports, CAF logging, socket server, and gRPC server startup. OpenTelemetry initialization now only runs if enabled, with results logged at debug level.
2026-01-22 12:49:34 +01:00
Kristian Bendiksen 8b13dbcef1 #12940 Fix empty vector parsing and ReadPastEnd handling for Python GRPC
- Handle empty arrays [] in std::vector<cvf::Vec3d> parser
- Only treat ReadCorruptData as error in generic template (ReadPastEnd
  is expected for types like caf::FilePath that consume all input)
- Use strict mode (allowExtraCharacters=false) for Python GRPC parsing
2026-01-21 08:41:09 +01:00
Kristian Bendiksen 6a1c74bdfc #12940 Add option to only parse in strict mode used from python 2026-01-21 08:41:09 +01:00
Kristian Bendiksen 4ea32ba563 #12940 Add automatic rollback on validation failure for Python GRPC
Implements automatic state restoration when field validation fails during
update(). The Python object now maintains consistency with the server state
by rolling back to the last known valid values.

- Store protobuf snapshot before update attempt
- Restore both protobuf object and Python attributes on validation failure
- Add test_validation_rollback() to verify rollback behavior
- Update bool validation test to assert automatic rollback
- Provides transaction-like semantics for field updates
2026-01-21 08:41:09 +01:00
Kristian Bendiksen d06280cca8 #12940 Strict type validation and improved Enum error handling for Python GRPC
- Implemented strict parsing in 'writeToField' handlers to reject values with trailing garbage (e.g. '100.5test' for double, '0.99' for int/enum).
- Improved 'AppEnum' validation error message to list all valid options when an invalid value is provided.
- Added new test file 'test_validation_types_issue_12940.py' verifying strict type validation for double, int, and enum fields.
2026-01-21 08:41:09 +01:00
Kristian Bendiksen 71fa7d2c26 #12940 Add validation for Python GRPC field updates with atomic rollback
Implements comprehensive type and range validation to prevent invalid data
from being set via Python GRPC interface. Invalid values are rejected with
clear error messages. Uses two-phase commit pattern to ensure atomic updates
where either all fields update or none do.

Validation Features:
- Type validation: Ensures field value types match (parsing errors caught)
- Range validation: Checks values against min/max constraints defined with
  setRange(), setMinValue(), setMaxValue()
- Object validation: Validates cross-field constraints via validate() override
- Atomic updates: Two-phase commit ensures all-or-nothing semantics
- Rollback on error: Failed validation leaves ALL fields at previous values
- Clear error messages: Aggregates and returns all validation failures

Implementation:
- Use std::expected<void, QString> for type-safe error handling (C++23)
- assignFieldValue(): Validates after parsing, rolls back individual field on error
- copyPdmObjectFromRipsToCaf(): Two-phase commit pattern
  - Phase 1: Validate all fields and collect changes (defer UI notifications)
  - Phase 2: If any validation fails, rollback all fields; otherwise commit all
- UpdateExistingPdmObject(): Returns grpc::INVALID_ARGUMENT with validation details

Testing:
- Comprehensive Python tests demonstrating validation behavior
- Test atomic rollback: multiple fields rolled back when one fails
- No regression in existing functionality

Documentation:
- Added validation documentation to CLAUDE.md with examples
- Explains how to set field ranges and handle validation errors in Python

Built on validation infrastructure from commit f342ca77 (PdmFieldHandle and
PdmObjectHandle validation support).
2026-01-21 08:41:09 +01:00
Magne Sjaastad 4b9f94efb8 Refactor depth property handling for regular surfaces
- Introduce RimRegularFileSurface::propertyName() as canonical property key for file-based surfaces.
- Change RimRegularSurface::setPropertyAsDepth() to void and remove existence check; error handling is now in updateSurfaceData().
- Update all usages to match new setPropertyAsDepth() behavior.
- Log and handle missing depth property in updateSurfaceData().
- Update tests to reflect new error handling approach.
- Minor includes and logging improvements.
2026-01-20 18:21:56 +01:00
JJ b87579961b Add support for using alias names for result names (#13453)
* Add alias editing to UI
* Enable result aliases for both eclipse and roff results
* Update python script to work on Windows
* Add Python interface for result aliases
* Add python test
2026-01-20 14:12:27 +01:00
Magne Sjaastad 303c781341 Remove cell result data API from RimEclipseView
Deleted m_cellResultData field and related methods from RimEclipseView, including UI handling and scriptable access. Also removed cell_result_data.py, eliminating direct scripting access to cell result data.

These functions are supported on a case in functions set_grid_property() and grid_property()
2026-01-20 13:50:27 +01:00
Magne Sjaastad ed759bf39a Adds telemetry for gRPC command and PDM calls
Improves observability by adding telemetry events for gRPC command executions and PDM object method calls.

These events include details such as command names, status, errors,
warnings, and the class of PDM objects involved. This enhances the ability
to monitor and diagnose issues within the gRPC services.
2026-01-20 13:44:06 +01:00
magnesj 5ea1a34c53 Python code linting changes detected by black 2026-01-18 21:46:02 +01:00
Kristian Bendiksen a71fb9ad19 #13398 Python: Add API for custom well path segments
Add Python GRPC interface support for creating and managing custom segment
intervals for multi-segment wells. This provides API parity with the existing
GUI functionality.

Changes:
- Add createInterval() method to RimCustomSegmentIntervalCollection
- Add GRPC method addCustomSegmentInterval to RimcWellPathCompletionSettings
- Add validation to prevent creating intervals with start_md >= end_md
- Add Python test test_custom_segment_intervals.py with validation test
- Add usage example to modeled_well_path.py

Follows the pattern established by diameter roughness intervals.

Fixes #13398.
2026-01-13 10:44:55 +01:00
Magne Sjaastad 88c17224a0 Add Python example 2026-01-12 09:32:42 +01:00
Kristian Bendiksen 633edd8bba #13313 Python: Add support for setting geometry on an existing case 2026-01-05 12:45:32 +01:00
Kristian Bendiksen a879452563 #12199 Python: Add validation error messages for set_summary_values()
The set_summary_values() Python API method now provides clear error
messages when validation fails instead of failing silently.

Changes:
- Add keyword length validation (8-character SMSPEC format limit)
- Add value vector size validation with informative messages
- Add test cases for both validation scenarios
- Update existing test to expect exceptions for invalid inputs

Fixes #12199.
2026-01-05 08:20:30 +01:00
JJ 225d034327 Fault distance from point (#13367)
* Add python interface for distance to closest fault
* Split up some older code into multiple files.
* Add python test
2025-12-20 09:50:51 +01:00
Magne Sjaastad c16a5de656 Add test and improve example
- improve test project so the first intersected cell is unique for all grids
- add test on intersection IJ for WELSEGS
- improve example
2025-12-08 15:22:00 +01:00
Magne Sjaastad 4f53c2692e #13295 Always use grid local IJ for WELSPECS/WELSPECL 2025-12-08 15:22:00 +01:00
JJ 9f17dd81ff Add support for COMPLUMP keyword (#13273)
* Add support for COMPLUMP keyword, both in python interface, file export and opm flow jobs
* Add support for WPIMULT kw in opm flow jobs
* Always provide per connection dFactors in COMPDAT kw (negative value)
* Include LGR support in COMPLUMP file export
2025-12-04 19:25:41 +01:00
Magne Sjaastad 88b0094dc8 Add LGR support to MSW tables
Add grid_name to relevant tables
Add support for WPIMULT
2025-12-03 09:48:50 +01:00
Magne Sjaastad e47a52b3d4 Remove obsolete combination_mode 2025-12-03 09:48:50 +01:00
Magne Sjaastad a23599cb5d Completion export cleanup
Use MSW as postfix to base name
Drop "Unified" for individual well export
Remove export option Individually/Combined
Remove SPLIT_ON_WELL_AND_COMPLETION_TYPE
2025-12-02 16:03:56 +01:00
Kristian Bendiksen 3c653b5880 #13081 Python: add grid_property_for_positions for RoffCase too.
Fixes #13081.
2025-11-24 15:44:26 +01:00
Magne Sjaastad 8c473b8a63 Fix typo in welspecs proto file 2025-11-20 13:52:58 +01:00
magnesj 926377be96 Python code linting changes detected by black 2025-11-20 12:39:22 +01:00
Magne Sjaastad e45dc88973 Improve the documentation for completion data 2025-11-20 12:39:22 +01:00
Magne Sjaastad 544e9eedd9 Improve spell checker using codespell
* Configures automated spell checking with codespell
Adds GitHub workflows and configuration files for automated spell checking using `codespell`.

This includes:
- A workflow for checking pull requests and preventing new typos
- A workflow for automatically fixing typos in the main codebase
- Configuration files for `codespell` to ignore specific terms and file types
- Documentation on how to use and configure the spell checking workflows.

* Corrects minor spelling and grammar errors.
2025-11-19 10:25:32 +01:00
Magne Sjaastad 489a1e5bfe Adds cross-reference to table data object
Adds a cross-reference to the simulatortabledata object to improve function description.
2025-11-18 08:49:04 +01:00
Magne Sjaastad 7e299c4841 Add support for more MSW tables in Python
* Use caf::VecIjk0
* Adds MSW tables to the gRPC interface
* Adds unified completion data retrieval
* Add unite tests for MSW data
2025-11-17 11:54:02 +01:00