From 6ca9162a0e66ca62d251648a7bcaed51226e9a0c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 25 Mar 2024 11:30:30 +0100 Subject: [PATCH] Updated python API for 2024.03 --- docs/rips/contour_map.py | 1 + docs/rips/generated/PdmObject_pb2.py | 4 +-- docs/rips/generated/PdmObject_pb2_grpc.py | 33 +++++++++++++++++++++++ docs/rips/generated/RiaVersionInfo.py | 4 +-- docs/rips/generated/generated_classes.py | 13 +++++++-- docs/rips/instance.py | 4 +-- docs/rips/pdmobject.py | 10 +++++++ docs/rips/plot.py | 1 + docs/rips/simulation_well.py | 1 + docs/rips/tests/test_object_lifetime.py | 27 +++++++++++++++++++ 10 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 docs/rips/tests/test_object_lifetime.py diff --git a/docs/rips/contour_map.py b/docs/rips/contour_map.py index 6d4e9d3db..9aeb6bb5a 100644 --- a/docs/rips/contour_map.py +++ b/docs/rips/contour_map.py @@ -1,6 +1,7 @@ """ ResInsight 3d contour map module """ + import Commands_pb2 from .pdmobject import add_method diff --git a/docs/rips/generated/PdmObject_pb2.py b/docs/rips/generated/PdmObject_pb2.py index 0189c8399..283710a38 100644 --- a/docs/rips/generated/PdmObject_pb2.py +++ b/docs/rips/generated/PdmObject_pb2.py @@ -14,7 +14,7 @@ import Definitions_pb2 as Definitions__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fPdmObject.proto\x12\x04rips\x1a\x11\x44\x65\x66initions.proto\"T\n\x1aPdmDescendantObjectRequest\x12\x1f\n\x06object\x18\x01 \x01(\x0b\x32\x0f.rips.PdmObject\x12\x15\n\rchild_keyword\x18\x02 \x01(\t\"M\n\x15PdmChildObjectRequest\x12\x1f\n\x06object\x18\x01 \x01(\x0b\x32\x0f.rips.PdmObject\x12\x13\n\x0b\x63hild_field\x18\x02 \x01(\t\"j\n\x1b\x43reatePdmChildObjectRequest\x12\x1f\n\x06object\x18\x01 \x01(\x0b\x32\x0f.rips.PdmObject\x12\x13\n\x0b\x63hild_field\x18\x02 \x01(\t\x12\x15\n\rclass_keyword\x18\x03 \x01(\t\"Q\n\x16PdmParentObjectRequest\x12\x1f\n\x06object\x18\x01 \x01(\x0b\x32\x0f.rips.PdmObject\x12\x16\n\x0eparent_keyword\x18\x02 \x01(\t\"\xc0\x01\n\tPdmObject\x12\x15\n\rclass_keyword\x18\x01 \x01(\t\x12\x0f\n\x07\x61\x64\x64ress\x18\x02 \x01(\x04\x12\x33\n\nparameters\x18\x03 \x03(\x0b\x32\x1f.rips.PdmObject.ParametersEntry\x12\x0f\n\x07visible\x18\x04 \x01(\x08\x12\x12\n\npersistent\x18\x05 \x01(\x08\x1a\x31\n\x0fParametersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"2\n\x0ePdmObjectArray\x12 \n\x07objects\x18\x01 \x03(\x0b\x32\x0f.rips.PdmObject\"I\n\x16PdmObjectGetterRequest\x12\x1f\n\x06object\x18\x01 \x01(\x0b\x32\x0f.rips.PdmObject\x12\x0e\n\x06method\x18\x02 \x01(\t\"[\n\x16PdmObjectSetterRequest\x12-\n\x07request\x18\x01 \x01(\x0b\x32\x1c.rips.PdmObjectGetterRequest\x12\x12\n\ndata_count\x18\x02 \x01(\x05\"\xbf\x01\n\x14PdmObjectSetterChunk\x12\x33\n\x0bset_request\x18\x01 \x01(\x0b\x32\x1c.rips.PdmObjectSetterRequestH\x00\x12$\n\x07\x64oubles\x18\x02 \x01(\x0b\x32\x11.rips.DoubleArrayH\x00\x12\x1e\n\x04ints\x18\x03 \x01(\x0b\x32\x0e.rips.IntArrayH\x00\x12$\n\x07strings\x18\x04 \x01(\x0b\x32\x11.rips.StringArrayH\x00\x42\x06\n\x04\x64\x61ta\"\x1b\n\x0b\x44oubleArray\x12\x0c\n\x04\x64\x61ta\x18\x01 \x03(\x01\"\x18\n\x08IntArray\x12\x0c\n\x04\x64\x61ta\x18\x01 \x03(\x05\"\x1b\n\x0bStringArray\x12\x0c\n\x04\x64\x61ta\x18\x01 \x03(\t\"\x8a\x01\n\x14PdmObjectGetterReply\x12$\n\x07\x64oubles\x18\x01 \x01(\x0b\x32\x11.rips.DoubleArrayH\x00\x12\x1e\n\x04ints\x18\x02 \x01(\x0b\x32\x0e.rips.IntArrayH\x00\x12$\n\x07strings\x18\x03 \x01(\x0b\x32\x11.rips.StringArrayH\x00\x42\x06\n\x04\x64\x61ta\"j\n\x16PdmObjectMethodRequest\x12\x1f\n\x06object\x18\x01 \x01(\x0b\x32\x0f.rips.PdmObject\x12\x0e\n\x06method\x18\x02 \x01(\t\x12\x1f\n\x06params\x18\x03 \x01(\x0b\x32\x0f.rips.PdmObject2\xf9\x04\n\x10PdmObjectService\x12S\n\x17GetDescendantPdmObjects\x12 .rips.PdmDescendantObjectRequest\x1a\x14.rips.PdmObjectArray\"\x00\x12I\n\x12GetChildPdmObjects\x12\x1b.rips.PdmChildObjectRequest\x1a\x14.rips.PdmObjectArray\"\x00\x12G\n\x14GetAncestorPdmObject\x12\x1c.rips.PdmParentObjectRequest\x1a\x0f.rips.PdmObject\"\x00\x12L\n\x14\x43reateChildPdmObject\x12!.rips.CreatePdmChildObjectRequest\x1a\x0f.rips.PdmObject\"\x00\x12\x39\n\x17UpdateExistingPdmObject\x12\x0f.rips.PdmObject\x1a\x0b.rips.Empty\"\x00\x12S\n\x13\x43\x61llPdmObjectGetter\x12\x1c.rips.PdmObjectGetterRequest\x1a\x1a.rips.PdmObjectGetterReply\"\x00\x30\x01\x12V\n\x13\x43\x61llPdmObjectSetter\x12\x1a.rips.PdmObjectSetterChunk\x1a\x1f.rips.ClientToServerStreamReply\"\x00(\x01\x12\x46\n\x13\x43\x61llPdmObjectMethod\x12\x1c.rips.PdmObjectMethodRequest\x1a\x0f.rips.PdmObject\"\x00\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fPdmObject.proto\x12\x04rips\x1a\x11\x44\x65\x66initions.proto\"T\n\x1aPdmDescendantObjectRequest\x12\x1f\n\x06object\x18\x01 \x01(\x0b\x32\x0f.rips.PdmObject\x12\x15\n\rchild_keyword\x18\x02 \x01(\t\"M\n\x15PdmChildObjectRequest\x12\x1f\n\x06object\x18\x01 \x01(\x0b\x32\x0f.rips.PdmObject\x12\x13\n\x0b\x63hild_field\x18\x02 \x01(\t\"j\n\x1b\x43reatePdmChildObjectRequest\x12\x1f\n\x06object\x18\x01 \x01(\x0b\x32\x0f.rips.PdmObject\x12\x13\n\x0b\x63hild_field\x18\x02 \x01(\t\x12\x15\n\rclass_keyword\x18\x03 \x01(\t\"Q\n\x16PdmParentObjectRequest\x12\x1f\n\x06object\x18\x01 \x01(\x0b\x32\x0f.rips.PdmObject\x12\x16\n\x0eparent_keyword\x18\x02 \x01(\t\"\xc0\x01\n\tPdmObject\x12\x15\n\rclass_keyword\x18\x01 \x01(\t\x12\x0f\n\x07\x61\x64\x64ress\x18\x02 \x01(\x04\x12\x33\n\nparameters\x18\x03 \x03(\x0b\x32\x1f.rips.PdmObject.ParametersEntry\x12\x0f\n\x07visible\x18\x04 \x01(\x08\x12\x12\n\npersistent\x18\x05 \x01(\x08\x1a\x31\n\x0fParametersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"2\n\x0ePdmObjectArray\x12 \n\x07objects\x18\x01 \x03(\x0b\x32\x0f.rips.PdmObject\"I\n\x16PdmObjectGetterRequest\x12\x1f\n\x06object\x18\x01 \x01(\x0b\x32\x0f.rips.PdmObject\x12\x0e\n\x06method\x18\x02 \x01(\t\"[\n\x16PdmObjectSetterRequest\x12-\n\x07request\x18\x01 \x01(\x0b\x32\x1c.rips.PdmObjectGetterRequest\x12\x12\n\ndata_count\x18\x02 \x01(\x05\"\xbf\x01\n\x14PdmObjectSetterChunk\x12\x33\n\x0bset_request\x18\x01 \x01(\x0b\x32\x1c.rips.PdmObjectSetterRequestH\x00\x12$\n\x07\x64oubles\x18\x02 \x01(\x0b\x32\x11.rips.DoubleArrayH\x00\x12\x1e\n\x04ints\x18\x03 \x01(\x0b\x32\x0e.rips.IntArrayH\x00\x12$\n\x07strings\x18\x04 \x01(\x0b\x32\x11.rips.StringArrayH\x00\x42\x06\n\x04\x64\x61ta\"\x1b\n\x0b\x44oubleArray\x12\x0c\n\x04\x64\x61ta\x18\x01 \x03(\x01\"\x18\n\x08IntArray\x12\x0c\n\x04\x64\x61ta\x18\x01 \x03(\x05\"\x1b\n\x0bStringArray\x12\x0c\n\x04\x64\x61ta\x18\x01 \x03(\t\"\x8a\x01\n\x14PdmObjectGetterReply\x12$\n\x07\x64oubles\x18\x01 \x01(\x0b\x32\x11.rips.DoubleArrayH\x00\x12\x1e\n\x04ints\x18\x02 \x01(\x0b\x32\x0e.rips.IntArrayH\x00\x12$\n\x07strings\x18\x03 \x01(\x0b\x32\x11.rips.StringArrayH\x00\x42\x06\n\x04\x64\x61ta\"j\n\x16PdmObjectMethodRequest\x12\x1f\n\x06object\x18\x01 \x01(\x0b\x32\x0f.rips.PdmObject\x12\x0e\n\x06method\x18\x02 \x01(\t\x12\x1f\n\x06params\x18\x03 \x01(\x0b\x32\x0f.rips.PdmObject2\xb4\x05\n\x10PdmObjectService\x12S\n\x17GetDescendantPdmObjects\x12 .rips.PdmDescendantObjectRequest\x1a\x14.rips.PdmObjectArray\"\x00\x12I\n\x12GetChildPdmObjects\x12\x1b.rips.PdmChildObjectRequest\x1a\x14.rips.PdmObjectArray\"\x00\x12G\n\x14GetAncestorPdmObject\x12\x1c.rips.PdmParentObjectRequest\x1a\x0f.rips.PdmObject\"\x00\x12L\n\x14\x43reateChildPdmObject\x12!.rips.CreatePdmChildObjectRequest\x1a\x0f.rips.PdmObject\"\x00\x12\x39\n\x17UpdateExistingPdmObject\x12\x0f.rips.PdmObject\x1a\x0b.rips.Empty\"\x00\x12S\n\x13\x43\x61llPdmObjectGetter\x12\x1c.rips.PdmObjectGetterRequest\x1a\x1a.rips.PdmObjectGetterReply\"\x00\x30\x01\x12V\n\x13\x43\x61llPdmObjectSetter\x12\x1a.rips.PdmObjectSetterChunk\x1a\x1f.rips.ClientToServerStreamReply\"\x00(\x01\x12\x46\n\x13\x43\x61llPdmObjectMethod\x12\x1c.rips.PdmObjectMethodRequest\x1a\x0f.rips.PdmObject\"\x00\x12\x39\n\x17\x44\x65leteExistingPdmObject\x12\x0f.rips.PdmObject\x1a\x0b.rips.Empty\"\x00\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -55,5 +55,5 @@ _globals['_PDMOBJECTMETHODREQUEST']._serialized_start=1234 _globals['_PDMOBJECTMETHODREQUEST']._serialized_end=1340 _globals['_PDMOBJECTSERVICE']._serialized_start=1343 - _globals['_PDMOBJECTSERVICE']._serialized_end=1976 + _globals['_PDMOBJECTSERVICE']._serialized_end=2035 # @@protoc_insertion_point(module_scope) diff --git a/docs/rips/generated/PdmObject_pb2_grpc.py b/docs/rips/generated/PdmObject_pb2_grpc.py index c4a6c7fb1..aa0483a94 100644 --- a/docs/rips/generated/PdmObject_pb2_grpc.py +++ b/docs/rips/generated/PdmObject_pb2_grpc.py @@ -55,6 +55,11 @@ def __init__(self, channel): request_serializer=PdmObject__pb2.PdmObjectMethodRequest.SerializeToString, response_deserializer=PdmObject__pb2.PdmObject.FromString, ) + self.DeleteExistingPdmObject = channel.unary_unary( + '/rips.PdmObjectService/DeleteExistingPdmObject', + request_serializer=PdmObject__pb2.PdmObject.SerializeToString, + response_deserializer=Definitions__pb2.Empty.FromString, + ) class PdmObjectServiceServicer(object): @@ -108,6 +113,12 @@ def CallPdmObjectMethod(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def DeleteExistingPdmObject(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def add_PdmObjectServiceServicer_to_server(servicer, server): rpc_method_handlers = { @@ -151,6 +162,11 @@ def add_PdmObjectServiceServicer_to_server(servicer, server): request_deserializer=PdmObject__pb2.PdmObjectMethodRequest.FromString, response_serializer=PdmObject__pb2.PdmObject.SerializeToString, ), + 'DeleteExistingPdmObject': grpc.unary_unary_rpc_method_handler( + servicer.DeleteExistingPdmObject, + request_deserializer=PdmObject__pb2.PdmObject.FromString, + response_serializer=Definitions__pb2.Empty.SerializeToString, + ), } generic_handler = grpc.method_handlers_generic_handler( 'rips.PdmObjectService', rpc_method_handlers) @@ -296,3 +312,20 @@ def CallPdmObjectMethod(request, PdmObject__pb2.PdmObject.FromString, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def DeleteExistingPdmObject(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/rips.PdmObjectService/DeleteExistingPdmObject', + PdmObject__pb2.PdmObject.SerializeToString, + Definitions__pb2.Empty.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/docs/rips/generated/RiaVersionInfo.py b/docs/rips/generated/RiaVersionInfo.py index 6d10b6f12..72f0d8584 100644 --- a/docs/rips/generated/RiaVersionInfo.py +++ b/docs/rips/generated/RiaVersionInfo.py @@ -16,8 +16,8 @@ # Python version of RiaVersionInfo.h # Just sets version constants -RESINSIGHT_MAJOR_VERSION : str = "2023" -RESINSIGHT_MINOR_VERSION : str = "12" +RESINSIGHT_MAJOR_VERSION : str = "2024" +RESINSIGHT_MINOR_VERSION : str = "03" RESINSIGHT_PATCH_VERSION : str = "0" PYTHON_GRPC_PROTOC_VERSION : str = "libprotoc 23.4" diff --git a/docs/rips/generated/generated_classes.py b/docs/rips/generated/generated_classes.py index 31f51f9cf..de35b9322 100644 --- a/docs/rips/generated/generated_classes.py +++ b/docs/rips/generated/generated_classes.py @@ -31,7 +31,7 @@ class CurveIntersection(PdmObjectBase): name (str): Name points (List[List[float]]): Points simulation_well (Optional[SimulationWell]): Simulation Well - type (str): One of [CS_WELL_PATH, CS_SIMULATION_WELL, CS_POLYLINE, CS_AZIMUTHLINE] + type (str): One of [CS_WELL_PATH, CS_SIMULATION_WELL, CS_POLYLINE, CS_AZIMUTHLINE, CS_POLYGON] well_path (Optional[WellPath]): Well Path """ __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: self.id: int = -1 self.name_setting: str = "FULL_CASE_NAME" self.short_name: str = "" - self.show_sub_nodes_in_tree: bool = False + self.show_sub_nodes_in_tree: bool = True self.summary_header_filename: Optional[str] = None PdmObjectBase.__init__(self, pb2_object, channel) if SummaryCase.__custom_init__ is not None: @@ -1133,6 +1133,14 @@ def __init__(self, pb2_object: Optional[PdmObject_pb2.PdmObject]=None, channel: if EclipseContourMap.__custom_init__ is not None: EclipseContourMap.__custom_init__(self, pb2_object=pb2_object, channel=channel) +class RimEmCase(Reservoir): + __custom_init__ = None #: Assign a custom init routine to be run at __init__ + + def __init__(self, pb2_object: Optional[PdmObject_pb2.PdmObject]=None, channel: Optional[grpc.Channel]=None) -> None: + Reservoir.__init__(self, pb2_object, channel) + if RimEmCase.__custom_init__ is not None: + RimEmCase.__custom_init__(self, pb2_object=pb2_object, channel=channel) + class GeoMechContourMap(GeoMechView): """ A contour map for GeoMech cases @@ -2308,6 +2316,7 @@ def class_dict() -> Dict[str, Type[PdmObjectBase]]: classes['Project'] = Project classes['ResampleData'] = ResampleData classes['Reservoir'] = Reservoir + classes['RimEmCase'] = RimEmCase classes['RimRoffCase'] = RimRoffCase classes['RimStatisticalCalculation'] = RimStatisticalCalculation classes['RimTextAnnotation'] = RimTextAnnotation diff --git a/docs/rips/instance.py b/docs/rips/instance.py index 225e1ec9b..1f6f7b0f7 100644 --- a/docs/rips/instance.py +++ b/docs/rips/instance.py @@ -285,9 +285,9 @@ def _check_connection_and_version( raise Exception( "Error: Wrong Version of ResInsight at ", location, - self.version_string(), + "Executable : " + self.version_string(), " ", - self.client_version_string(), + "rips : " + self.client_version_string(), ) def __version_message(self) -> App_pb2.Version: diff --git a/docs/rips/pdmobject.py b/docs/rips/pdmobject.py index 877a2ccb4..73b2724b0 100644 --- a/docs/rips/pdmobject.py +++ b/docs/rips/pdmobject.py @@ -511,3 +511,13 @@ def update(self) -> None: raise Exception( "Object is not connected to GRPC service so cannot update ResInsight" ) + + def delete(self) -> None: + """Delete object in ResInsight""" + self.__copy_to_pb2() + if self._pdm_object_stub is not None: + self._pdm_object_stub.DeleteExistingPdmObject(self._pb2_object) + else: + raise Exception( + "Object is not connected to GRPC service so cannot update ResInsight" + ) diff --git a/docs/rips/plot.py b/docs/rips/plot.py index da41c5ebd..4b464420d 100644 --- a/docs/rips/plot.py +++ b/docs/rips/plot.py @@ -1,6 +1,7 @@ """ ResInsight 2d plot module """ + import Commands_pb2 from .pdmobject import add_method diff --git a/docs/rips/simulation_well.py b/docs/rips/simulation_well.py index abe100d70..7c29d1c4e 100644 --- a/docs/rips/simulation_well.py +++ b/docs/rips/simulation_well.py @@ -1,6 +1,7 @@ """ ResInsight SimulationWell """ + import grpc import SimulationWell_pb2 diff --git a/docs/rips/tests/test_object_lifetime.py b/docs/rips/tests/test_object_lifetime.py new file mode 100644 index 000000000..1175a002b --- /dev/null +++ b/docs/rips/tests/test_object_lifetime.py @@ -0,0 +1,27 @@ +import sys +import os + +sys.path.insert(1, os.path.join(sys.path[0], "../../")) +import rips + + +def test_well_path(rips_instance, initialize_test): + well_path_coll = rips_instance.project.descendants(rips.WellPathCollection)[0] + assert len(well_path_coll.well_paths()) is 0 + + well_path = well_path_coll.add_new_object(rips.ModeledWellPath) + well_path2 = well_path_coll.add_new_object(rips.ModeledWellPath) + assert len(well_path_coll.well_paths()) is 2 + + well_path.delete() + assert len(well_path_coll.well_paths()) is 1 + + try: + # Delete again should throw exception + well_path.delete() + assert False + except Exception: + assert True + + well_path2.delete() + assert len(well_path_coll.well_paths()) is 0