mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6320 Rename generated/pdm_objects.py to generated/resinsight_classes.py
* This is to avoid confusion with pdmobject.py
This commit is contained in:
committed by
Kristian Bendiksen
parent
454e7f17a0
commit
30fa232c25
@@ -584,12 +584,12 @@ endforeach()
|
||||
if (RESINSIGHT_ENABLE_GRPC)
|
||||
set(RESINSIGHT_GRPC_PYTHON_EXECUTABLE "" CACHE FILEPATH "gRPC : Path to Python 3 executable, required to build the Python client library")
|
||||
if (RESINSIGHT_GRPC_PYTHON_EXECUTABLE)
|
||||
add_custom_command(OUTPUT ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py
|
||||
COMMAND ResInsight ARGS --console --generate ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py
|
||||
add_custom_command(OUTPUT ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/resinsight_classes.py
|
||||
COMMAND ResInsight ARGS --console --generate ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/resinsight_classes.py
|
||||
DEPENDS ResInsight
|
||||
COMMENT "Generating ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py"
|
||||
COMMENT "Generating ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/resinsight_classes.py"
|
||||
)
|
||||
list(APPEND GRPC_GENERATED_PYTHON_SOURCES ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py)
|
||||
list(APPEND GRPC_GENERATED_PYTHON_SOURCES ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/resinsight_classes.py)
|
||||
add_custom_target(GeneratedPythonSources ALL DEPENDS ${GRPC_GENERATED_PYTHON_SOURCES})
|
||||
add_dependencies(GeneratedPythonSources ResInsight)
|
||||
else()
|
||||
@@ -781,7 +781,7 @@ if (RESINSIGHT_PRIVATE_INSTALL)
|
||||
)
|
||||
endif()
|
||||
install(DIRECTORY ${GRPC_PYTHON_SOURCE_PATH}/ DESTINATION ${RESINSIGHT_INSTALL_FOLDER}/Python)
|
||||
install(FILES ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/pdm_objects.py DESTINATION ${RESINSIGHT_INSTALL_FOLDER}/Python/rips/generated)
|
||||
install(FILES ${GRPC_PYTHON_SOURCE_PATH}/rips/generated/resinsight_classes.py DESTINATION ${RESINSIGHT_INSTALL_FOLDER}/Python/rips/generated)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'generated'))
|
||||
|
||||
from pdm_objects import *
|
||||
from resinsight_classes import *
|
||||
|
||||
from .case import Case, EclipseCase, GeoMechCase
|
||||
from .grid import Grid
|
||||
|
||||
@@ -58,7 +58,7 @@ import Properties_pb2
|
||||
import Properties_pb2_grpc
|
||||
import NNCProperties_pb2
|
||||
import NNCProperties_pb2_grpc
|
||||
from pdm_objects import Case, EclipseCase, GeoMechCase, WellBoreStabilityPlot, WbsParameters
|
||||
from resinsight_classes import Case, EclipseCase, GeoMechCase, WellBoreStabilityPlot, WbsParameters
|
||||
|
||||
#import rips.project
|
||||
|
||||
@@ -68,6 +68,7 @@ from .view import View
|
||||
from .simulation_well import SimulationWell
|
||||
import rips.project
|
||||
|
||||
|
||||
@add_method(Case)
|
||||
def __custom_init__(self, pb2_object, channel):
|
||||
self.__case_stub = Case_pb2_grpc.CaseStub(self._channel)
|
||||
@@ -322,7 +323,7 @@ def view(self, view_id):
|
||||
view_id(int): view id
|
||||
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.View`
|
||||
:class:`rips.generated.resinsight_classes.View`
|
||||
"""
|
||||
views = self.views()
|
||||
for view_object in views:
|
||||
@@ -336,7 +337,7 @@ def create_view(self):
|
||||
"""Create a new view in the current case
|
||||
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.View`
|
||||
:class:`rips.generated.resinsight_classes.View`
|
||||
"""
|
||||
return self.view(
|
||||
self._execute_command(createView=Cmd.CreateViewRequest(
|
||||
@@ -925,7 +926,7 @@ def create_well_bore_stability_plot(self, well_path, time_step, parameters=None)
|
||||
time_step(int): time step
|
||||
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.WellBoreStabilityPlot`
|
||||
:class:`rips.generated.resinsight_classes.WellBoreStabilityPlot`
|
||||
"""
|
||||
pb2_parameters = None
|
||||
if parameters is not None:
|
||||
@@ -963,7 +964,7 @@ def simulation_wells(self):
|
||||
"""Get a list of all simulation wells for a case
|
||||
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.SimulationWell`
|
||||
:class:`rips.generated.resinsight_classes.SimulationWell`
|
||||
|
||||
"""
|
||||
wells = self.descendants(SimulationWell)
|
||||
|
||||
@@ -5,7 +5,7 @@ import Commands_pb2
|
||||
|
||||
from .pdmobject import add_method
|
||||
from .view import View
|
||||
from pdm_objects import EclipseContourMap, GeoMechContourMap
|
||||
from resinsight_classes import EclipseContourMap, GeoMechContourMap
|
||||
|
||||
|
||||
@add_method(EclipseContourMap)
|
||||
|
||||
@@ -7,7 +7,7 @@ from .pdmobject import add_method
|
||||
#from rips.case import Case
|
||||
|
||||
import Commands_pb2
|
||||
from pdm_objects import GridCaseGroup
|
||||
from resinsight_classes import GridCaseGroup
|
||||
|
||||
|
||||
@add_method(GridCaseGroup)
|
||||
@@ -15,7 +15,7 @@ def create_statistics_case(self):
|
||||
"""Create a Statistics case in the Grid Case Group
|
||||
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.EclipseCase`
|
||||
:class:`rips.generated.resinsight_classes.EclipseCase`
|
||||
"""
|
||||
command_reply = self._execute_command(
|
||||
createStatisticsCase=Commands_pb2.CreateStatisticsCaseRequest(
|
||||
@@ -29,7 +29,7 @@ def statistics_cases(self):
|
||||
"""Get a list of all statistics cases in the Grid Case Group
|
||||
|
||||
Returns:
|
||||
List of :class:`rips.generated.pdm_objects.EclipseCase`
|
||||
List of :class:`rips.generated.resinsight_classes.EclipseCase`
|
||||
|
||||
"""
|
||||
stat_case_collection = self.children("StatisticsCaseCollection")[0]
|
||||
@@ -41,12 +41,12 @@ def views(self):
|
||||
"""Get a list of views belonging to a grid case group
|
||||
|
||||
Returns:
|
||||
List of :class:`rips.generated.pdm_objects.EclipseView`
|
||||
List of :class:`rips.generated.resinsight_classes.EclipseView`
|
||||
|
||||
"""
|
||||
pdm_objects = self.descendants(EclipseView)
|
||||
resinsight_classes = self.descendants(EclipseView)
|
||||
view_list = []
|
||||
for pdm_object in pdm_objects:
|
||||
for pdm_object in resinsight_classes:
|
||||
view_list.append(pdm_object)
|
||||
return view_list
|
||||
|
||||
@@ -58,7 +58,7 @@ def view(self, view_id):
|
||||
id(int): view id
|
||||
|
||||
Returns:
|
||||
List of :class:`rips.generated.pdm_objects.EclipseView`
|
||||
List of :class:`rips.generated.resinsight_classes.EclipseView`
|
||||
|
||||
"""
|
||||
views = self.views()
|
||||
|
||||
@@ -15,7 +15,7 @@ import PdmObject_pb2
|
||||
import PdmObject_pb2_grpc
|
||||
import Commands_pb2
|
||||
import Commands_pb2_grpc
|
||||
import pdm_objects as ClassList
|
||||
import resinsight_classes as ClassList
|
||||
|
||||
|
||||
def camel_to_snake(name):
|
||||
@@ -44,13 +44,16 @@ def add_static_method(cls):
|
||||
return func # returning func means func can still be used normally
|
||||
return decorator
|
||||
|
||||
|
||||
class PdmObjectBase:
|
||||
"""
|
||||
The ResInsight base class for the Project Data Model
|
||||
"""
|
||||
|
||||
def _execute_command(self, **command_params):
|
||||
self.__warnings = []
|
||||
response, call = self._commands.Execute.with_call(Commands_pb2.CommandParams(**command_params))
|
||||
response, call = self._commands.Execute.with_call(
|
||||
Commands_pb2.CommandParams(**command_params))
|
||||
for key, value in call.trailing_metadata():
|
||||
value = value.replace(';;', '\n')
|
||||
if key == 'warning':
|
||||
@@ -143,7 +146,7 @@ class PdmObjectBase:
|
||||
if not snake_kw.startswith("_") and not callable(getattr(self, snake_kw)):
|
||||
camel_kw = snake_to_camel(snake_kw)
|
||||
print(" " + snake_kw + " [" + type(getattr(self, snake_kw)).__name__ +
|
||||
"]: " + str(getattr(self, snake_kw)))
|
||||
"]: " + str(getattr(self, snake_kw)))
|
||||
print("Object Methods:")
|
||||
for snake_kw in dir(self):
|
||||
if not snake_kw.startswith("_") and callable(getattr(self, snake_kw)):
|
||||
@@ -211,7 +214,7 @@ class PdmObjectBase:
|
||||
values.append(self.__convert_from_grpc_value(string))
|
||||
return values
|
||||
|
||||
def __from_pb2_to_pdm_objects(self, pb2_object_list, super_class_definition):
|
||||
def __from_pb2_to_resinsight_classes(self, pb2_object_list, super_class_definition):
|
||||
pdm_object_list = []
|
||||
for pb2_object in pb2_object_list:
|
||||
child_class_definition = ClassList.class_from_keyword(pb2_object.class_keyword)
|
||||
@@ -238,7 +241,7 @@ class PdmObjectBase:
|
||||
object=self._pb2_object, child_keyword=class_keyword)
|
||||
object_list = self._pdm_object_stub.GetDescendantPdmObjects(
|
||||
request).objects
|
||||
return self.__from_pb2_to_pdm_objects(object_list, class_definition)
|
||||
return self.__from_pb2_to_resinsight_classes(object_list, class_definition)
|
||||
except grpc.RpcError as e:
|
||||
if e.code() == grpc.StatusCode.NOT_FOUND:
|
||||
return [] # Valid empty result
|
||||
@@ -252,10 +255,10 @@ class PdmObjectBase:
|
||||
A list of PdmObjects inside the child_field
|
||||
"""
|
||||
request = PdmObject_pb2.PdmChildObjectRequest(object=self._pb2_object,
|
||||
child_field=child_field)
|
||||
child_field=child_field)
|
||||
try:
|
||||
object_list = self._pdm_object_stub.GetChildPdmObjects(request).objects
|
||||
return self.__from_pb2_to_pdm_objects(object_list, class_definition)
|
||||
return self.__from_pb2_to_resinsight_classes(object_list, class_definition)
|
||||
except grpc.RpcError as e:
|
||||
if e.code() == grpc.StatusCode.NOT_FOUND:
|
||||
return []
|
||||
@@ -318,7 +321,7 @@ class PdmObjectBase:
|
||||
elif isinstance(array[0], int):
|
||||
chunk.CopyFrom(
|
||||
PdmObject_pb2.PdmObjectSetterChunk(ints=PdmObject_pb2.IntArray(data=array[index:index +
|
||||
actual_chunk_size])))
|
||||
actual_chunk_size])))
|
||||
elif isinstance(array[0], str):
|
||||
chunk.CopyFrom(
|
||||
PdmObject_pb2.PdmObjectSetterChunk(strings=PdmObject_pb2.StringArray(data=array[index:index +
|
||||
|
||||
@@ -4,7 +4,7 @@ ResInsight 2d plot module
|
||||
import Commands_pb2
|
||||
|
||||
from .pdmobject import PdmObjectBase, add_method
|
||||
from pdm_objects import PlotWindow, Plot
|
||||
from resinsight_classes import PlotWindow, Plot
|
||||
|
||||
|
||||
@add_method(PlotWindow)
|
||||
@@ -19,7 +19,7 @@ def export_snapshot(self, export_folder='', file_prefix='', output_format='PNG')
|
||||
"""
|
||||
return self._execute_command(
|
||||
exportSnapshots=Commands_pb2.ExportSnapshotsRequest(type='PLOTS',
|
||||
prefix=file_prefix,
|
||||
viewId=self.id,
|
||||
exportFolder=export_folder,
|
||||
plotOutputFormat=output_format))
|
||||
prefix=file_prefix,
|
||||
viewId=self.id,
|
||||
exportFolder=export_folder,
|
||||
plotOutputFormat=output_format))
|
||||
|
||||
@@ -17,7 +17,7 @@ from Definitions_pb2 import Empty
|
||||
import Project_pb2_grpc
|
||||
import Project_pb2
|
||||
import PdmObject_pb2
|
||||
from pdm_objects import Project, PlotWindow, WellPath
|
||||
from resinsight_classes import Project, PlotWindow, WellPath
|
||||
|
||||
|
||||
@add_method(Project)
|
||||
@@ -68,7 +68,7 @@ def load_case(self, path):
|
||||
Arguments:
|
||||
path(str): file path to case
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.Case`
|
||||
:class:`rips.generated.resinsight_classes.Case`
|
||||
"""
|
||||
command_reply = self._execute_command(loadCase=Commands_pb2.FilePathRequest(
|
||||
path=path))
|
||||
@@ -80,7 +80,7 @@ def selected_cases(self):
|
||||
"""Get a list of all cases selected in the project tree
|
||||
|
||||
Returns:
|
||||
A list of :class:`rips.generated.pdm_objects.Case`
|
||||
A list of :class:`rips.generated.resinsight_classes.Case`
|
||||
"""
|
||||
case_infos = self._project_stub.GetSelectedCases(Empty())
|
||||
cases = []
|
||||
@@ -94,7 +94,7 @@ def cases(self):
|
||||
"""Get a list of all cases in the project
|
||||
|
||||
Returns:
|
||||
A list of :class:`rips.generated.pdm_objects.Case`
|
||||
A list of :class:`rips.generated.resinsight_classes.Case`
|
||||
"""
|
||||
return self.descendants(Case)
|
||||
|
||||
@@ -106,7 +106,7 @@ def case(self, case_id):
|
||||
Arguments:
|
||||
id(int): case id
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.Case`
|
||||
:class:`rips.generated.resinsight_classes.Case`
|
||||
"""
|
||||
allCases = self.cases()
|
||||
for case in allCases:
|
||||
@@ -135,7 +135,7 @@ def create_grid_case_group(self, case_paths):
|
||||
Arguments:
|
||||
case_paths (list): list of file path strings
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.GridCaseGroup`
|
||||
:class:`rips.generated.resinsight_classes.GridCaseGroup`
|
||||
"""
|
||||
command_reply = self._execute_command(
|
||||
createGridCaseGroup=Commands_pb2.CreateGridCaseGroupRequest(
|
||||
@@ -157,7 +157,7 @@ def view(self, view_id):
|
||||
Arguments:
|
||||
view_id(int): view id
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.View`
|
||||
:class:`rips.generated.resinsight_classes.View`
|
||||
"""
|
||||
views = self.views()
|
||||
for view_object in views:
|
||||
@@ -171,11 +171,11 @@ def plots(self):
|
||||
"""Get a list of all plots belonging to a project
|
||||
|
||||
Returns:
|
||||
List of :class:`rips.generated.pdm_objects.Plot`
|
||||
List of :class:`rips.generated.resinsight_classes.Plot`
|
||||
"""
|
||||
pdm_objects = self.descendants(PlotWindow)
|
||||
resinsight_classes = self.descendants(PlotWindow)
|
||||
plot_list = []
|
||||
for pdm_object in pdm_objects:
|
||||
for pdm_object in resinsight_classes:
|
||||
if pdm_object.id != -1:
|
||||
plot_list.append(pdm_object)
|
||||
return plot_list
|
||||
@@ -189,7 +189,7 @@ def plot(self, view_id):
|
||||
view_id(int): view id
|
||||
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.Plot`
|
||||
:class:`rips.generated.resinsight_classes.Plot`
|
||||
"""
|
||||
plots = self.plots()
|
||||
for plot_object in plots:
|
||||
@@ -203,7 +203,7 @@ def grid_case_groups(self):
|
||||
"""Get a list of all grid case groups in the project
|
||||
|
||||
Returns:
|
||||
List of :class:`rips.generated.pdm_objects.GridCaseGroup`
|
||||
List of :class:`rips.generated.resinsight_classes.GridCaseGroup`
|
||||
|
||||
"""
|
||||
case_groups = self.descendants(GridCaseGroup)
|
||||
@@ -218,7 +218,7 @@ def grid_case_group(self, group_id):
|
||||
groupId(int): group id
|
||||
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.GridCaseGroup`
|
||||
:class:`rips.generated.resinsight_classes.GridCaseGroup`
|
||||
"""
|
||||
case_groups = self.grid_case_groups()
|
||||
for case_group in case_groups:
|
||||
@@ -313,13 +313,13 @@ def import_well_paths(self, well_path_files=None, well_path_folder=''):
|
||||
well_path_folder(str): A folder path containing files to import
|
||||
|
||||
Returns:
|
||||
List of :class:`rips.generated.pdm_objects.WellPath`
|
||||
List of :class:`rips.generated.resinsight_classes.WellPath`
|
||||
"""
|
||||
if well_path_files is None:
|
||||
well_path_files = []
|
||||
|
||||
res = self._execute_command(importWellPaths=Commands_pb2.ImportWellPathsRequest(wellPathFolder=well_path_folder,
|
||||
wellPathFiles=well_path_files))
|
||||
wellPathFiles=well_path_files))
|
||||
well_paths = []
|
||||
for well_path_name in res.importWellPathsResult.wellPathNames:
|
||||
well_paths.append(self.well_path_by_name(well_path_name))
|
||||
@@ -331,7 +331,7 @@ def well_paths(self):
|
||||
"""Get a list of all well paths in the project
|
||||
|
||||
Returns:
|
||||
List of :class:`rips.generated.pdm_objects.WellPath`
|
||||
List of :class:`rips.generated.resinsight_classes.WellPath`
|
||||
"""
|
||||
return self.descendants(WellPath)
|
||||
|
||||
@@ -341,7 +341,7 @@ def well_path_by_name(self, well_path_name):
|
||||
"""Get a specific well path by name from the project
|
||||
|
||||
Returns:
|
||||
:class:`rips.generated.pdm_objects.WellPath`
|
||||
:class:`rips.generated.resinsight_classes.WellPath`
|
||||
"""
|
||||
all_well_paths = self.well_paths()
|
||||
for well_path in all_well_paths:
|
||||
@@ -365,7 +365,7 @@ def import_well_log_files(self, well_log_files=None, well_log_folder=''):
|
||||
if well_log_files is None:
|
||||
well_log_files = []
|
||||
res = self._execute_command(importWellLogFiles=Commands_pb2.ImportWellLogFilesRequest(wellLogFolder=well_log_folder,
|
||||
wellLogFiles=well_log_files))
|
||||
wellLogFiles=well_log_files))
|
||||
return res.importWellLogFilesResult.wellPathNames
|
||||
|
||||
|
||||
@@ -383,5 +383,4 @@ def import_formation_names(self, formation_files=None):
|
||||
formation_files = [formation_files]
|
||||
|
||||
self._execute_command(importFormationNames=Commands_pb2.ImportFormationNamesRequest(formationFiles=formation_files,
|
||||
applyToCaseId=-1))
|
||||
|
||||
applyToCaseId=-1))
|
||||
|
||||
@@ -9,12 +9,13 @@ import SimulationWell_pb2_grpc
|
||||
import Properties_pb2
|
||||
import Properties_pb2_grpc
|
||||
|
||||
from pdm_objects import SimulationWell
|
||||
from resinsight_classes import SimulationWell
|
||||
|
||||
from .pdmobject import PdmObjectBase, add_method
|
||||
|
||||
import rips.case
|
||||
|
||||
|
||||
@add_method(SimulationWell)
|
||||
def __custom_init__(self, pb2_object, channel):
|
||||
self._simulation_well_stub = SimulationWell_pb2_grpc.SimulationWellStub(channel)
|
||||
|
||||
@@ -7,7 +7,7 @@ import Commands_pb2 as Cmd
|
||||
|
||||
import rips.case # Circular import of Case, which already imports View. Use full name.
|
||||
from .pdmobject import add_method
|
||||
from pdm_objects import View, ViewWindow, EclipseView, GeoMechView
|
||||
from resinsight_classes import View, ViewWindow, EclipseView, GeoMechView
|
||||
|
||||
|
||||
@add_method(View)
|
||||
|
||||
@@ -6,7 +6,7 @@ import Commands_pb2
|
||||
|
||||
from .plot import Plot
|
||||
from .pdmobject import PdmObjectBase, add_method
|
||||
from pdm_objects import WellLogPlot
|
||||
from resinsight_classes import WellLogPlot
|
||||
|
||||
|
||||
@add_method(WellLogPlot)
|
||||
@@ -24,13 +24,13 @@ def export_data_as_las(self, export_folder, file_prefix='', export_tvdrkb=False,
|
||||
A list of files exported
|
||||
"""
|
||||
res = self._execute_command(exportWellLogPlotData=Commands_pb2.ExportWellLogPlotDataRequest(exportFormat='LAS',
|
||||
viewId=self.id,
|
||||
exportFolder=export_folder,
|
||||
filePrefix=file_prefix,
|
||||
exportTvdRkb=export_tvdrkb,
|
||||
capitalizeFileNames=capitalize_file_names,
|
||||
resampleInterval=resample_interval,
|
||||
convertCurveUnits=convert_to_standard_units))
|
||||
viewId=self.id,
|
||||
exportFolder=export_folder,
|
||||
filePrefix=file_prefix,
|
||||
exportTvdRkb=export_tvdrkb,
|
||||
capitalizeFileNames=capitalize_file_names,
|
||||
resampleInterval=resample_interval,
|
||||
convertCurveUnits=convert_to_standard_units))
|
||||
return res.exportWellLogPlotDataResult.exportedFiles
|
||||
|
||||
|
||||
@@ -47,10 +47,10 @@ def export_data_as_ascii(self, export_folder, file_prefix='', capitalize_file_na
|
||||
A list of files exported
|
||||
"""
|
||||
res = self._execute_command(exportWellLogPlotData=Commands_pb2.ExportWellLogPlotDataRequest(exportFormat='ASCII',
|
||||
viewId=self.id,
|
||||
exportFolder=export_folder,
|
||||
filePrefix=file_prefix,
|
||||
exportTvdRkb=False,
|
||||
capitalizeFileNames=capitalize_file_names,
|
||||
resampleInterval=0.0))
|
||||
viewId=self.id,
|
||||
exportFolder=export_folder,
|
||||
filePrefix=file_prefix,
|
||||
exportTvdRkb=False,
|
||||
capitalizeFileNames=capitalize_file_names,
|
||||
resampleInterval=0.0))
|
||||
return res.exportWellLogPlotDataResult.exportedFiles
|
||||
|
||||
Reference in New Issue
Block a user