mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Support optimized surface export from grid model layers
* #7885 Update opm-common with optimized coordinate import * #7885 Allow null as default result from a script method * #7885 Propagate default parameter values to generated Python code * #7885 Add CommandRouter as hub for worker methods * #7885 Add support for use of CommadRouter from Python
This commit is contained in:
@@ -3,11 +3,13 @@ syntax = "proto3";
|
||||
package rips;
|
||||
|
||||
import "Definitions.proto";
|
||||
import "PdmObject.proto";
|
||||
|
||||
service App {
|
||||
rpc GetVersion(Empty) returns (Version) {}
|
||||
rpc Exit(Empty) returns (Empty) {}
|
||||
rpc GetRuntimeInfo(Empty) returns (RuntimeInfo) {}
|
||||
rpc GetPdmObject(Empty) returns (PdmObject) {}
|
||||
}
|
||||
|
||||
message Version {
|
||||
|
@@ -13,6 +13,7 @@ home_dir = expanduser("~")
|
||||
export_folder = tempfile.mkdtemp()
|
||||
|
||||
directory_path = "resprojects/webviz-subsurface-testdata/reek_history_match/"
|
||||
# directory_path = "e:/gitroot/webviz-subsurface-testdata/reek_history_match"
|
||||
|
||||
|
||||
case_file_paths = []
|
||||
|
@@ -0,0 +1,41 @@
|
||||
# Load ResInsight Processing Server Client Library
|
||||
import rips
|
||||
import tempfile
|
||||
from os.path import expanduser
|
||||
from pathlib import Path
|
||||
|
||||
# Connect to ResInsight instance
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
|
||||
home_dir = expanduser("~")
|
||||
|
||||
export_folder = tempfile.mkdtemp()
|
||||
|
||||
directory_path = "resprojects/webviz-subsurface-testdata/reek_history_match/"
|
||||
# directory_path = "e:/gitroot/webviz-subsurface-testdata/reek_history_match"
|
||||
|
||||
|
||||
case_file_paths = []
|
||||
num_realizations = 9
|
||||
num_iterations = 4
|
||||
|
||||
|
||||
for realization in range(0, num_realizations):
|
||||
for iteration in range(0, num_iterations):
|
||||
realization_dir = "realization-" + str(realization)
|
||||
iteration_dir = "iter-" + str(iteration)
|
||||
egrid_name = "eclipse/model/5_R001_REEK-" + str(realization) + ".EGRID"
|
||||
path = Path(
|
||||
home_dir, directory_path, realization_dir, iteration_dir, egrid_name
|
||||
)
|
||||
case_file_paths.append(path)
|
||||
|
||||
k_indexes = [4, 10]
|
||||
|
||||
command_router = resinsight.command_router
|
||||
|
||||
for path in case_file_paths:
|
||||
path_name = path.as_posix()
|
||||
|
||||
command_router.extract_surfaces(path_name, k_indexes)
|
@@ -23,6 +23,7 @@ import RiaVersionInfo
|
||||
from .project import Project
|
||||
from .retry_policy import ExponentialBackoffRetryPolicy
|
||||
from .grpc_retry_interceptor import RetryOnRpcErrorClientInterceptor
|
||||
from .generated.generated_classes import CommandRouter
|
||||
|
||||
|
||||
class Instance:
|
||||
@@ -202,12 +203,17 @@ class Instance:
|
||||
|
||||
intercepted_channel = grpc.intercept_channel(self.channel, *interceptors)
|
||||
|
||||
# Recreate ommand stubs with the retry policy
|
||||
# Recreate command stubs with the retry policy
|
||||
self.commands = Commands_pb2_grpc.CommandsStub(intercepted_channel)
|
||||
|
||||
# Service packages
|
||||
self.project = Project.create(intercepted_channel)
|
||||
|
||||
# Command Router object used as entry point for independent processing functions
|
||||
self.command_router = CommandRouter(
|
||||
self.app.GetPdmObject(Empty()), intercepted_channel
|
||||
)
|
||||
|
||||
path = os.getcwd()
|
||||
self.set_start_dir(path=path)
|
||||
|
||||
|
@@ -22,6 +22,8 @@
|
||||
#include "RiaGrpcServer.h"
|
||||
#include "RiaVersionInfo.h"
|
||||
|
||||
#include "ProjectDataModelCommands/CommandRouter/RimCommandRouter.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -51,7 +53,7 @@ grpc::Status
|
||||
RiaGrpcAppService::GetRuntimeInfo( grpc::ServerContext* context, const rips::Empty* request, rips::RuntimeInfo* reply )
|
||||
{
|
||||
rips::ApplicationTypeEnum appType = rips::CONSOLE_APPLICATION;
|
||||
if ( dynamic_cast<QApplication*>(RiaApplication::instance()))
|
||||
if ( dynamic_cast<QApplication*>( RiaApplication::instance() ) )
|
||||
{
|
||||
appType = rips::GUI_APPLICATION;
|
||||
}
|
||||
@@ -70,7 +72,24 @@ std::vector<RiaGrpcCallbackInterface*> RiaGrpcAppService::createCallbacks()
|
||||
new RiaGrpcUnaryCallback<Self, rips::Empty, rips::Empty>( this, &Self::Exit, &Self::RequestExit ),
|
||||
new RiaGrpcUnaryCallback<Self, rips::Empty, rips::RuntimeInfo>( this,
|
||||
&Self::GetRuntimeInfo,
|
||||
&Self::RequestGetRuntimeInfo ) };
|
||||
&Self::RequestGetRuntimeInfo ),
|
||||
new RiaGrpcUnaryCallback<Self, rips::Empty, rips::PdmObject>( this,
|
||||
&Self::GetPdmObject,
|
||||
&Self::RequestGetPdmObject ) };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
grpc::Status
|
||||
RiaGrpcAppService::GetPdmObject( grpc::ServerContext* context, const rips::Empty* request, rips::PdmObject* reply )
|
||||
{
|
||||
auto* commandRouter = RiaApplication::instance()->commandRouter();
|
||||
if ( commandRouter )
|
||||
{
|
||||
copyPdmObjectFromCafToRips( commandRouter, reply );
|
||||
}
|
||||
return grpc::Status::OK;
|
||||
}
|
||||
|
||||
static bool RiaGrpcAppInfoService_init =
|
||||
|
@@ -46,4 +46,5 @@ public:
|
||||
grpc::Status Exit( grpc::ServerContext* context, const rips::Empty* request, rips::Empty* reply ) override;
|
||||
grpc::Status GetRuntimeInfo( grpc::ServerContext* context, const rips::Empty* request, rips::RuntimeInfo* reply ) override;
|
||||
std::vector<RiaGrpcCallbackInterface*> createCallbacks() override;
|
||||
grpc::Status GetPdmObject( grpc::ServerContext* context, const rips::Empty* request, rips::PdmObject* reply ) override;
|
||||
};
|
||||
|
@@ -17,7 +17,10 @@
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RiaGrpcPdmObjectService.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaGrpcCallbacks.h"
|
||||
|
||||
#include "ProjectDataModelCommands/CommandRouter/RimCommandRouter.h"
|
||||
#include "Rim3dView.h"
|
||||
#include "RimEclipseResultDefinition.h"
|
||||
#include "RimProject.h"
|
||||
@@ -613,11 +616,13 @@ caf::PdmObject* RiaGrpcPdmObjectService::findCafObjectFromRipsObject( const rips
|
||||
caf::PdmObject* RiaGrpcPdmObjectService::findCafObjectFromScriptNameAndAddress( const QString& scriptClassName,
|
||||
uint64_t address )
|
||||
{
|
||||
QString classKeyword = caf::PdmObjectScriptingCapabilityRegister::classKeywordFromScriptClassName( scriptClassName );
|
||||
|
||||
if ( classKeyword == RimCommandRouter::classKeywordStatic() ) return RiaApplication::instance()->commandRouter();
|
||||
|
||||
RimProject* project = RimProject::current();
|
||||
std::vector<caf::PdmObject*> objectsOfCurrentClass;
|
||||
|
||||
QString classKeyword = caf::PdmObjectScriptingCapabilityRegister::classKeywordFromScriptClassName( scriptClassName );
|
||||
|
||||
project->descendantsIncludingThisFromClassKeyword( classKeyword, objectsOfCurrentClass );
|
||||
|
||||
caf::PdmObject* matchingObject = nullptr;
|
||||
|
@@ -34,7 +34,9 @@
|
||||
#include <grpcpp/grpcpp.h>
|
||||
|
||||
#include <PdmObject.pb.h>
|
||||
#include <QDebug>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -137,6 +139,16 @@ void RiaGrpcServiceInterface::copyPdmObjectFromRipsToCaf( const rips::PdmObject*
|
||||
destination->fields( fields );
|
||||
|
||||
auto parametersMap = source->parameters();
|
||||
|
||||
bool printContent = false; // Flag to control debug output to debugger
|
||||
if ( printContent )
|
||||
{
|
||||
for ( const auto& p : parametersMap )
|
||||
{
|
||||
qDebug() << QString::fromStdString( p.first ) << " : " << QString::fromStdString( p.second );
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto field : fields )
|
||||
{
|
||||
auto scriptability = field->template capability<caf::PdmAbstractFieldScriptingCapability>();
|
||||
|
Reference in New Issue
Block a user