From 906a9b9bd19da2af5095493df12c76c0af4bc659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eide?= Date: Mon, 30 Sep 2024 09:33:11 +0200 Subject: [PATCH] Updates --- src/ert/config/ensemble_config.py | 9 +++++++-- src/ert/config/field.py | 2 +- src/ert/config/queue_config.py | 8 ++++---- .../unit_tests/config/test_observations.py | 19 ++++++++++--------- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/ert/config/ensemble_config.py b/src/ert/config/ensemble_config.py index c431ebc238e..b4d79b90ab9 100644 --- a/src/ert/config/ensemble_config.py +++ b/src/ert/config/ensemble_config.py @@ -15,7 +15,12 @@ from ert.field_utils import get_shape +<<<<<<< HEAD from .field import Field +======= +from ._read_summary import read_summary +from .field import Field as FieldConfig +>>>>>>> 9beba276b (Updates) from .gen_data_config import GenDataConfig from .gen_kw_config import GenKwConfig from .parameter_config import ParameterConfig @@ -52,8 +57,8 @@ class EnsembleConfig: response_configs: Dict[str, Union[SummaryConfig, GenDataConfig]] = field( default_factory=dict ) - parameter_configs: Dict[str, Union[GenKwConfig, Field, SurfaceConfig]] = field( - default_factory=dict + parameter_configs: Dict[str, Union[GenKwConfig, FieldConfig, SurfaceConfig]] = field( + default_factory=dict ) refcase: Optional[Refcase] = None eclbase: Optional[str] = None diff --git a/src/ert/config/field.py b/src/ert/config/field.py index 520ff9d82d1..d3ccb79b3a9 100644 --- a/src/ert/config/field.py +++ b/src/ert/config/field.py @@ -3,7 +3,7 @@ import logging import os import time -from dataclasses import dataclass +from pydantic.dataclasses import dataclass from functools import cached_property from pathlib import Path from typing import TYPE_CHECKING, Any, List, Optional, Union, overload diff --git a/src/ert/config/queue_config.py b/src/ert/config/queue_config.py index 9d71067057b..8ff658b6745 100644 --- a/src/ert/config/queue_config.py +++ b/src/ert/config/queue_config.py @@ -81,7 +81,7 @@ def driver_options(self) -> Dict[str, Any]: @pydantic.dataclasses.dataclass class LocalQueueOptions(QueueOptions): - name: Literal[QueueSystem.LOCAL.lower()] = QueueSystem.LOCAL.lower() + name: Literal[QueueSystem.LOCAL] = QueueSystem.LOCAL @property def driver_options(self) -> Dict[str, Any]: @@ -90,7 +90,7 @@ def driver_options(self) -> Dict[str, Any]: @pydantic.dataclasses.dataclass class LsfQueueOptions(QueueOptions): - name: Literal[QueueSystem.LSF.lower()] = QueueSystem.LSF.lower() + name: Literal[QueueSystem.LSF] = QueueSystem.LSF bhist_cmd: Optional[NonEmptyString] = None bjobs_cmd: Optional[NonEmptyString] = None bkill_cmd: Optional[NonEmptyString] = None @@ -113,7 +113,7 @@ def driver_options(self) -> Dict[str, Any]: @pydantic.dataclasses.dataclass class TorqueQueueOptions(QueueOptions): - name: Literal[QueueSystem.TORQUE.lower()] = QueueSystem.TORQUE.lower() + name: Literal[QueueSystem.TORQUE] = QueueSystem.TORQUE qsub_cmd: Optional[NonEmptyString] = None qstat_cmd: Optional[NonEmptyString] = None qdel_cmd: Optional[NonEmptyString] = None @@ -149,7 +149,7 @@ def check_memory_per_job(cls, value: Optional[str]) -> Optional[str]: @pydantic.dataclasses.dataclass class SlurmQueueOptions(QueueOptions): - name: Literal[QueueSystem.SLURM.lower()] = QueueSystem.SLURM.lower() + name: Literal[QueueSystem.SLURM] = QueueSystem.SLURM sbatch: NonEmptyString = "sbatch" scancel: NonEmptyString = "scancel" scontrol: NonEmptyString = "scontrol" diff --git a/tests/ert/unit_tests/config/test_observations.py b/tests/ert/unit_tests/config/test_observations.py index 9d3dfb35e66..ecf442153ba 100644 --- a/tests/ert/unit_tests/config/test_observations.py +++ b/tests/ert/unit_tests/config/test_observations.py @@ -8,6 +8,7 @@ import pytest from hypothesis import given, settings from hypothesis import strategies as st +from pydantic import ValidationError from resdata.summary import Summary from ert.config import ( @@ -244,7 +245,7 @@ def test_that_having_no_refcase_but_history_observations_causes_exception(tmpdir fo.writelines("2023-02-01") with pytest.raises( - expected_exception=ConfigValidationError, + expected_exception=ValidationError, match="REFCASE is required for HISTORY_OBSERVATION", ): ErtConfig.from_file("config.ert") @@ -381,7 +382,7 @@ def test_that_missing_time_map_raises_exception(tmpdir): ) with pytest.raises( - expected_exception=ConfigValidationError, + expected_exception=ValidationError, match="TIME_MAP", ): ErtConfig.from_file("config.ert") @@ -420,7 +421,7 @@ def test_that_badly_formatted_obs_file_shows_informative_error_message(tmpdir): ) with pytest.raises( - expected_exception=ConfigValidationError, + expected_exception=ValidationError, match=r"Failed to read OBS_FILE .*/obs_data.txt: could not convert" " string 'not_an_int' to float64 at row 0, column 1", ): @@ -464,7 +465,7 @@ def test_that_giving_both_index_file_and_index_list_raises_an_exception(tmpdir): ) with pytest.raises( - expected_exception=ConfigValidationError, + expected_exception=ValidationError, match="both INDEX_FILE and INDEX_LIST", ): ErtConfig.from_file("config.ert") @@ -516,7 +517,7 @@ def run_sim(start_date, keys=None, values=None, days=None): "DAYS", "2.0", pytest.raises( - ConfigValidationError, + ValidationError, match=r"Could not find 2014-09-12 00:00:00 \(DAYS=2.0\)" " in the time map for observations FOPR_1", ), @@ -527,7 +528,7 @@ def run_sim(start_date, keys=None, values=None, days=None): "HOURS", 48.0, pytest.raises( - ConfigValidationError, + ValidationError, match=r"Could not find 2014-09-12 00:00:00 \(HOURS=48.0\)" " in the time map for observations FOPR_1", ), @@ -538,7 +539,7 @@ def run_sim(start_date, keys=None, values=None, days=None): "DATE", "2014-09-12", pytest.raises( - ConfigValidationError, + ValidationError, match=r"Could not find 2014-09-12 00:00:00 \(DATE=2014-09-12\)" " in the time map for observations FOPR_1", ), @@ -621,7 +622,7 @@ def test_that_having_observations_on_starting_date_errors(tmpdir): run_sim(date) with pytest.raises( - ConfigValidationError, + ValidationError, match="not possible to use summary observations from the start", ): ErtConfig.from_file("config.ert") @@ -767,7 +768,7 @@ def test_that_different_length_values_fail(monkeypatch, copy_snake_oil_case_stor with obs_file.open(mode="a") as fin: fin.write(observations) - with pytest.raises(ConfigValidationError, match="must be of equal length"): + with pytest.raises(ValidationError, match="must be of equal length"): ErtConfig.from_file("snake_oil.ert")