コード例 #1
0
def run_gui(args):
    app = QApplication(
        [])  # Early so that QT is initialized before other imports
    app.setWindowIcon(resourceIcon("application/window_icon_cutout"))
    res_config = ResConfig(args.config)

    # Create logger inside function to make sure all handlers have been added to
    # the root-logger.
    logger = logging.getLogger(__name__)
    logger.info(
        "Logging forward model jobs",
        extra={
            "workflow_jobs":
            str(res_config.model_config.getForwardModel().joblist())
        },
    )

    os.chdir(res_config.config_path)
    # Changing current working directory means we need to update the config file to
    # be the base name of the original config
    args.config = os.path.basename(args.config)
    ert = EnKFMain(res_config, strict=True, verbose=args.verbose)
    notifier = ErtNotifier(args.config)
    # window reference must be kept until app.exec returns:
    window = _start_window(ert, notifier, args)  # noqa
    return app.exec_()
コード例 #2
0
def test_gui_iter_num(monkeypatch, tmpdir, qtbot, patch_enkf_main):
    # won't run simulations so we mock it and test whether "iter_num" is in arguments
    def _assert_iter_in_args(panel):
        assert panel.getSimulationArguments().iter_num == 10

    args_mock = Mock()
    type(args_mock).config = PropertyMock(return_value="config.ert")

    monkeypatch.setattr(
        ert_gui.simulation.simulation_panel.SimulationPanel,
        "runSimulation",
        _assert_iter_in_args,
    )

    notifier = ErtNotifier(args_mock.config)
    gui = _start_window(patch_enkf_main, notifier, args_mock)
    qtbot.addWidget(gui)

    sim_mode = gui.findChild(qtpy.QtWidgets.QWidget, name="Simulation_mode")
    qtbot.keyClick(sim_mode, Qt.Key_Down)

    sim_panel = gui.findChild(qtpy.QtWidgets.QWidget, name="Simulation_panel")

    ensemble_panel = gui.findChild(qtpy.QtWidgets.QWidget,
                                   name="Ensemble_experiment_panel")
    # simulate entering number 10 as iter_num
    qtbot.keyClick(ensemble_panel._iter_field, Qt.Key_Backspace)
    qtbot.keyClicks(ensemble_panel._iter_field, "10")
    qtbot.keyClick(ensemble_panel._iter_field, Qt.Key_Enter)

    start_simulation = gui.findChild(qtpy.QtWidgets.QWidget,
                                     name="start_simulation")
    qtbot.mouseClick(start_simulation, Qt.LeftButton)
    assert sim_panel.getSimulationArguments().iter_num == 10
コード例 #3
0
ファイル: test_base_run_model.py プロジェクト: oysteoh/ert
 def test_instantiation(self):
     config_file = self.createTestPath("local/simple_config/minimum_config")
     with ErtTestContext("kjell", config_file) as work_area:
         ert = work_area.getErt()
         notifier = ErtNotifier(ert, config_file)
         with ERT.adapt(notifier):
             brm = BaseRunModel(ert.get_queue_config())
             assert not brm.isQueueRunning()
コード例 #4
0
def test_gui_load(monkeypatch, tmpdir, qtbot, patch_enkf_main):
    args_mock = Mock()
    type(args_mock).config = PropertyMock(return_value="config.ert")
    notifier = ErtNotifier(args_mock.config)
    gui = _start_window(patch_enkf_main, notifier, args_mock)
    qtbot.addWidget(gui)

    sim_panel = gui.findChild(qtpy.QtWidgets.QWidget, name="Simulation_panel")
    single_run_panel = gui.findChild(qtpy.QtWidgets.QWidget,
                                     name="Single_test_run_panel")
    assert (sim_panel.getCurrentSimulationModel() ==
            single_run_panel.getSimulationModel())

    sim_mode = gui.findChild(qtpy.QtWidgets.QWidget, name="Simulation_mode")
    qtbot.keyClick(sim_mode, Qt.Key_Down)

    ensemble_panel = gui.findChild(qtpy.QtWidgets.QWidget,
                                   name="Ensemble_experiment_panel")
    assert sim_panel.getCurrentSimulationModel(
    ) == ensemble_panel.getSimulationModel()