Skip to content

Commit 6ca9162

Browse files
committed
Updated python API for 2024.03
1 parent 1e73b05 commit 6ca9162

File tree

10 files changed

+90
-8
lines changed

10 files changed

+90
-8
lines changed

docs/rips/contour_map.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
ResInsight 3d contour map module
33
"""
4+
45
import Commands_pb2
56

67
from .pdmobject import add_method

docs/rips/generated/PdmObject_pb2.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/rips/generated/PdmObject_pb2_grpc.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ def __init__(self, channel):
5555
request_serializer=PdmObject__pb2.PdmObjectMethodRequest.SerializeToString,
5656
response_deserializer=PdmObject__pb2.PdmObject.FromString,
5757
)
58+
self.DeleteExistingPdmObject = channel.unary_unary(
59+
'/rips.PdmObjectService/DeleteExistingPdmObject',
60+
request_serializer=PdmObject__pb2.PdmObject.SerializeToString,
61+
response_deserializer=Definitions__pb2.Empty.FromString,
62+
)
5863

5964

6065
class PdmObjectServiceServicer(object):
@@ -108,6 +113,12 @@ def CallPdmObjectMethod(self, request, context):
108113
context.set_details('Method not implemented!')
109114
raise NotImplementedError('Method not implemented!')
110115

116+
def DeleteExistingPdmObject(self, request, context):
117+
"""Missing associated documentation comment in .proto file."""
118+
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
119+
context.set_details('Method not implemented!')
120+
raise NotImplementedError('Method not implemented!')
121+
111122

112123
def add_PdmObjectServiceServicer_to_server(servicer, server):
113124
rpc_method_handlers = {
@@ -151,6 +162,11 @@ def add_PdmObjectServiceServicer_to_server(servicer, server):
151162
request_deserializer=PdmObject__pb2.PdmObjectMethodRequest.FromString,
152163
response_serializer=PdmObject__pb2.PdmObject.SerializeToString,
153164
),
165+
'DeleteExistingPdmObject': grpc.unary_unary_rpc_method_handler(
166+
servicer.DeleteExistingPdmObject,
167+
request_deserializer=PdmObject__pb2.PdmObject.FromString,
168+
response_serializer=Definitions__pb2.Empty.SerializeToString,
169+
),
154170
}
155171
generic_handler = grpc.method_handlers_generic_handler(
156172
'rips.PdmObjectService', rpc_method_handlers)
@@ -296,3 +312,20 @@ def CallPdmObjectMethod(request,
296312
PdmObject__pb2.PdmObject.FromString,
297313
options, channel_credentials,
298314
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
315+
316+
@staticmethod
317+
def DeleteExistingPdmObject(request,
318+
target,
319+
options=(),
320+
channel_credentials=None,
321+
call_credentials=None,
322+
insecure=False,
323+
compression=None,
324+
wait_for_ready=None,
325+
timeout=None,
326+
metadata=None):
327+
return grpc.experimental.unary_unary(request, target, '/rips.PdmObjectService/DeleteExistingPdmObject',
328+
PdmObject__pb2.PdmObject.SerializeToString,
329+
Definitions__pb2.Empty.FromString,
330+
options, channel_credentials,
331+
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

docs/rips/generated/RiaVersionInfo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
# Python version of RiaVersionInfo.h
1717
# Just sets version constants
1818

19-
RESINSIGHT_MAJOR_VERSION : str = "2023"
20-
RESINSIGHT_MINOR_VERSION : str = "12"
19+
RESINSIGHT_MAJOR_VERSION : str = "2024"
20+
RESINSIGHT_MINOR_VERSION : str = "03"
2121
RESINSIGHT_PATCH_VERSION : str = "0"
2222

2323
PYTHON_GRPC_PROTOC_VERSION : str = "libprotoc 23.4"

docs/rips/generated/generated_classes.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CurveIntersection(PdmObjectBase):
3131
name (str): Name
3232
points (List[List[float]]): Points
3333
simulation_well (Optional[SimulationWell]): Simulation Well
34-
type (str): One of [CS_WELL_PATH, CS_SIMULATION_WELL, CS_POLYLINE, CS_AZIMUTHLINE]
34+
type (str): One of [CS_WELL_PATH, CS_SIMULATION_WELL, CS_POLYLINE, CS_AZIMUTHLINE, CS_POLYGON]
3535
well_path (Optional[WellPath]): Well Path
3636
"""
3737
__custom_init__ = None #: Assign a custom init routine to be run at __init__
@@ -461,7 +461,7 @@ def __init__(self, pb2_object: Optional[PdmObject_pb2.PdmObject]=None, channel:
461461
self.id: int = -1
462462
self.name_setting: str = "FULL_CASE_NAME"
463463
self.short_name: str = ""
464-
self.show_sub_nodes_in_tree: bool = False
464+
self.show_sub_nodes_in_tree: bool = True
465465
self.summary_header_filename: Optional[str] = None
466466
PdmObjectBase.__init__(self, pb2_object, channel)
467467
if SummaryCase.__custom_init__ is not None:
@@ -1133,6 +1133,14 @@ def __init__(self, pb2_object: Optional[PdmObject_pb2.PdmObject]=None, channel:
11331133
if EclipseContourMap.__custom_init__ is not None:
11341134
EclipseContourMap.__custom_init__(self, pb2_object=pb2_object, channel=channel)
11351135

1136+
class RimEmCase(Reservoir):
1137+
__custom_init__ = None #: Assign a custom init routine to be run at __init__
1138+
1139+
def __init__(self, pb2_object: Optional[PdmObject_pb2.PdmObject]=None, channel: Optional[grpc.Channel]=None) -> None:
1140+
Reservoir.__init__(self, pb2_object, channel)
1141+
if RimEmCase.__custom_init__ is not None:
1142+
RimEmCase.__custom_init__(self, pb2_object=pb2_object, channel=channel)
1143+
11361144
class GeoMechContourMap(GeoMechView):
11371145
"""
11381146
A contour map for GeoMech cases
@@ -2308,6 +2316,7 @@ def class_dict() -> Dict[str, Type[PdmObjectBase]]:
23082316
classes['Project'] = Project
23092317
classes['ResampleData'] = ResampleData
23102318
classes['Reservoir'] = Reservoir
2319+
classes['RimEmCase'] = RimEmCase
23112320
classes['RimRoffCase'] = RimRoffCase
23122321
classes['RimStatisticalCalculation'] = RimStatisticalCalculation
23132322
classes['RimTextAnnotation'] = RimTextAnnotation

docs/rips/instance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ def _check_connection_and_version(
285285
raise Exception(
286286
"Error: Wrong Version of ResInsight at ",
287287
location,
288-
self.version_string(),
288+
"Executable : " + self.version_string(),
289289
" ",
290-
self.client_version_string(),
290+
"rips : " + self.client_version_string(),
291291
)
292292

293293
def __version_message(self) -> App_pb2.Version:

docs/rips/pdmobject.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,3 +511,13 @@ def update(self) -> None:
511511
raise Exception(
512512
"Object is not connected to GRPC service so cannot update ResInsight"
513513
)
514+
515+
def delete(self) -> None:
516+
"""Delete object in ResInsight"""
517+
self.__copy_to_pb2()
518+
if self._pdm_object_stub is not None:
519+
self._pdm_object_stub.DeleteExistingPdmObject(self._pb2_object)
520+
else:
521+
raise Exception(
522+
"Object is not connected to GRPC service so cannot update ResInsight"
523+
)

docs/rips/plot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
ResInsight 2d plot module
33
"""
4+
45
import Commands_pb2
56

67
from .pdmobject import add_method

docs/rips/simulation_well.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
ResInsight SimulationWell
33
"""
4+
45
import grpc
56

67
import SimulationWell_pb2
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import sys
2+
import os
3+
4+
sys.path.insert(1, os.path.join(sys.path[0], "../../"))
5+
import rips
6+
7+
8+
def test_well_path(rips_instance, initialize_test):
9+
well_path_coll = rips_instance.project.descendants(rips.WellPathCollection)[0]
10+
assert len(well_path_coll.well_paths()) is 0
11+
12+
well_path = well_path_coll.add_new_object(rips.ModeledWellPath)
13+
well_path2 = well_path_coll.add_new_object(rips.ModeledWellPath)
14+
assert len(well_path_coll.well_paths()) is 2
15+
16+
well_path.delete()
17+
assert len(well_path_coll.well_paths()) is 1
18+
19+
try:
20+
# Delete again should throw exception
21+
well_path.delete()
22+
assert False
23+
except Exception:
24+
assert True
25+
26+
well_path2.delete()
27+
assert len(well_path_coll.well_paths()) is 0

0 commit comments

Comments
 (0)