mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add Sumo connector and related cloud tools
* Add cloud data icon * Add Sumo connector and related helper tools * Reorganize preferences and remove ssihub * Use timeout defined for Sumo
This commit is contained in:
@@ -20,6 +20,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataCtxFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicOpenInTextEditorFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowMemoryReportFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSumoDataFeature.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -44,13 +45,16 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataCtxFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicOpenInTextEditorFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicShowMemoryReportFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSumoDataFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
||||
list(APPEND COMMAND_CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
|
||||
|
||||
set(COMMAND_QT_MOC_HEADERS ${COMMAND_QT_MOC_HEADERS})
|
||||
list(APPEND COMMAND_QT_MOC_HEADERS
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSumoDataFeature.h
|
||||
)
|
||||
|
||||
source_group(
|
||||
"CommandFeature\\Application"
|
||||
|
||||
@@ -64,7 +64,6 @@ void RicEditPreferencesFeature::onActionTriggered( bool isChecked )
|
||||
std::unique_ptr<RiaPreferences> oldPreferences = clonePreferences( app->preferences() );
|
||||
|
||||
RiuPropertyViewTabWidget propertyDialog( nullptr, app->preferences(), "Preferences", tabNames );
|
||||
propertyDialog.setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
|
||||
|
||||
auto pushButton = propertyDialog.dialogButtonBox()->addButton( "Help", QDialogButtonBox::HelpRole );
|
||||
connect( pushButton, &QPushButton::clicked, this, &RicEditPreferencesFeature::showHelp );
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2024 Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicSumoDataFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaPreferencesSystem.h"
|
||||
|
||||
#include "RifArrowTools.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QSettings>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicSumoDataFeature, "RicSumoDataFeature" );
|
||||
|
||||
SimpleDialog::SimpleDialog( QWidget* parent )
|
||||
: QDialog( parent )
|
||||
{
|
||||
setWindowTitle( "Simple Dialog" );
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout( this );
|
||||
|
||||
label = new QLabel( "This is a simple dialog.", this );
|
||||
layout->addWidget( label );
|
||||
|
||||
authButton = new QPushButton( "Authenticate", this );
|
||||
connect( authButton, &QPushButton::clicked, this, &SimpleDialog::onAuthClicked );
|
||||
layout->addWidget( authButton );
|
||||
|
||||
assetsButton = new QPushButton( "Asset Names", this );
|
||||
connect( assetsButton, &QPushButton::clicked, this, &SimpleDialog::onAssetsClicked );
|
||||
layout->addWidget( assetsButton );
|
||||
|
||||
casesButton = new QPushButton( "Cases", this );
|
||||
connect( casesButton, &QPushButton::clicked, this, &SimpleDialog::onCasesClicked );
|
||||
layout->addWidget( casesButton );
|
||||
|
||||
vectorNamesButton = new QPushButton( "Vector Names", this );
|
||||
connect( vectorNamesButton, &QPushButton::clicked, this, &SimpleDialog::onVectorNamesClicked );
|
||||
layout->addWidget( vectorNamesButton );
|
||||
|
||||
blobIdButton = new QPushButton( "Blob Id", this );
|
||||
connect( blobIdButton, &QPushButton::clicked, this, &SimpleDialog::onFindBlobIdClicked );
|
||||
layout->addWidget( blobIdButton );
|
||||
|
||||
parquetDownloadButton = new QPushButton( "Parquet", this );
|
||||
connect( parquetDownloadButton, &QPushButton::clicked, this, &SimpleDialog::onParquetClicked );
|
||||
layout->addWidget( parquetDownloadButton );
|
||||
|
||||
showContentParquetButton = new QPushButton( "Show Content Parquet", this );
|
||||
connect( showContentParquetButton, &QPushButton::clicked, this, &SimpleDialog::onShowContentParquetClicked );
|
||||
layout->addWidget( showContentParquetButton );
|
||||
|
||||
realizationIdsButton = new QPushButton( "Realizations", this );
|
||||
connect( realizationIdsButton, &QPushButton::clicked, this, &SimpleDialog::onRealizationsClicked );
|
||||
layout->addWidget( realizationIdsButton );
|
||||
|
||||
okButton = new QPushButton( "OK", this );
|
||||
connect( okButton, &QPushButton::clicked, this, &SimpleDialog::onOkClicked );
|
||||
layout->addWidget( okButton );
|
||||
|
||||
cancelButton = new QPushButton( "Cancel", this );
|
||||
connect( cancelButton, &QPushButton::clicked, this, &SimpleDialog::onCancelClicked );
|
||||
layout->addWidget( cancelButton );
|
||||
|
||||
setLayout( layout );
|
||||
|
||||
m_sumoConnector = RiaApplication::instance()->makeSumoConnector();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
SimpleDialog::~SimpleDialog()
|
||||
{
|
||||
if ( m_sumoConnector )
|
||||
{
|
||||
m_sumoConnector->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SimpleDialog::createConnection()
|
||||
{
|
||||
m_sumoConnector = RiaApplication::instance()->makeSumoConnector();
|
||||
connect( m_sumoConnector, &RiaSumoConnector::tokenReady, this, &SimpleDialog::onTokenReady );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SimpleDialog::onAuthClicked()
|
||||
{
|
||||
createConnection();
|
||||
m_sumoConnector->requestToken();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SimpleDialog::onAssetsClicked()
|
||||
{
|
||||
if ( !isTokenValid() ) return;
|
||||
|
||||
m_sumoConnector->requestAssets();
|
||||
m_sumoConnector->assets();
|
||||
|
||||
label->setText( "Requesting fields (see log for response" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SimpleDialog::onCasesClicked()
|
||||
{
|
||||
if ( !isTokenValid() ) return;
|
||||
|
||||
QString fieldName = "Drogon";
|
||||
m_sumoConnector->requestCasesForField( fieldName );
|
||||
|
||||
label->setText( "Requesting cases (see log for response" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SimpleDialog::onVectorNamesClicked()
|
||||
{
|
||||
if ( !isTokenValid() ) return;
|
||||
|
||||
SumoCaseId caseId( "5b783aab-ce10-4b78-b129-baf8d8ce4baa" );
|
||||
QString iteration = "iter-0";
|
||||
|
||||
m_sumoConnector->requestVectorNamesForEnsemble( caseId, iteration );
|
||||
|
||||
label->setText( "Requesting vector names (see log for response" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SimpleDialog::onFindBlobIdClicked()
|
||||
{
|
||||
if ( !isTokenValid() ) return;
|
||||
|
||||
SumoCaseId caseId( "5b783aab-ce10-4b78-b129-baf8d8ce4baa" );
|
||||
QString iteration = "iter-0";
|
||||
QString vectorName = "FOPT";
|
||||
|
||||
m_sumoConnector->requestBlobIdForEnsemble( caseId, iteration, vectorName );
|
||||
|
||||
label->setText( "Requesting blob ID for vector name (see log for response" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SimpleDialog::onParquetClicked()
|
||||
{
|
||||
if ( !isTokenValid() ) return;
|
||||
|
||||
if ( m_sumoConnector->blobUrls().empty() )
|
||||
{
|
||||
onFindBlobIdClicked();
|
||||
}
|
||||
|
||||
if ( !m_sumoConnector->blobUrls().empty() )
|
||||
{
|
||||
m_sumoConnector->requestBlobDownload( m_sumoConnector->blobUrls().back() );
|
||||
|
||||
label->setText( "Requesting blob ID for vector name (see log for response" );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SimpleDialog::onShowContentParquetClicked()
|
||||
{
|
||||
if ( m_sumoConnector->blobContents().empty() ) return;
|
||||
|
||||
auto blob = m_sumoConnector->blobContents().back();
|
||||
|
||||
auto content = blob.contents;
|
||||
|
||||
// TODO: show content using parquet reader
|
||||
auto tableText = RifArrowTools::readFirstRowsOfTable( content );
|
||||
RiaLogging::info( tableText );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SimpleDialog::onRealizationsClicked()
|
||||
{
|
||||
if ( !isTokenValid() ) return;
|
||||
|
||||
SumoCaseId caseId( "485041ce-ad72-48a3-ac8c-484c0ed95cf8" );
|
||||
QString iteration = "iter-0";
|
||||
|
||||
m_sumoConnector->requestRealizationIdsForEnsembleBlocking( caseId, iteration );
|
||||
|
||||
auto ids = m_sumoConnector->realizationIds();
|
||||
for ( const auto& id : ids )
|
||||
{
|
||||
RiaLogging::info( id );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool SimpleDialog::isTokenValid()
|
||||
{
|
||||
if ( !m_sumoConnector )
|
||||
{
|
||||
createConnection();
|
||||
}
|
||||
|
||||
if ( m_sumoConnector->token().isEmpty() )
|
||||
{
|
||||
m_sumoConnector->requestToken();
|
||||
}
|
||||
|
||||
return !m_sumoConnector->token().isEmpty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void SimpleDialog::onTokenReady( const QString& token )
|
||||
{
|
||||
RiaLogging::info( "Token ready: " + token );
|
||||
}
|
||||
|
||||
void SimpleDialog::onOkClicked()
|
||||
{
|
||||
qDebug( "OK button clicked" );
|
||||
accept();
|
||||
}
|
||||
|
||||
void SimpleDialog::onCancelClicked()
|
||||
{
|
||||
qDebug( "Cancel button clicked" );
|
||||
reject();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSumoDataFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
if ( !m_dialog )
|
||||
{
|
||||
m_dialog = new SimpleDialog( RiaGuiApplication::instance()->mainWindow() );
|
||||
}
|
||||
m_dialog->show();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSumoDataFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "SUMO" );
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2024 Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
#include "Cloud/RiaSumoConnector.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QPointer>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
class SimpleDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SimpleDialog( QWidget* parent = nullptr );
|
||||
~SimpleDialog();
|
||||
|
||||
void createConnection();
|
||||
|
||||
private:
|
||||
void onOkClicked();
|
||||
void onCancelClicked();
|
||||
void onTokenReady( const QString& token );
|
||||
void onAuthClicked();
|
||||
void onAssetsClicked();
|
||||
void onCasesClicked();
|
||||
void onVectorNamesClicked();
|
||||
void onFindBlobIdClicked();
|
||||
void onParquetClicked();
|
||||
void onShowContentParquetClicked();
|
||||
void onRealizationsClicked();
|
||||
|
||||
bool isTokenValid();
|
||||
|
||||
private:
|
||||
QLabel* label;
|
||||
QPushButton* okButton;
|
||||
QPushButton* cancelButton;
|
||||
QPushButton* authButton;
|
||||
QPushButton* assetsButton;
|
||||
QPushButton* casesButton;
|
||||
QPushButton* vectorNamesButton;
|
||||
QPushButton* blobIdButton;
|
||||
QPushButton* parquetDownloadButton;
|
||||
QPushButton* showContentParquetButton;
|
||||
QPushButton* realizationIdsButton;
|
||||
|
||||
QPointer<RiaSumoConnector> m_sumoConnector;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSumoDataFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
SimpleDialog* m_dialog = nullptr;
|
||||
};
|
||||
Reference in New Issue
Block a user