Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Sep 30, 2024
1 parent 43724a8 commit 906a9b9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
9 changes: 7 additions & 2 deletions src/ert/config/ensemble_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 23 in src/ert/config/ensemble_config.py

View workflow job for this annotation

GitHub Actions / type-checking (3.12)

invalid decimal literal
from .gen_data_config import GenDataConfig
from .gen_kw_config import GenKwConfig
from .parameter_config import ParameterConfig
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ert/config/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/ert/config/queue_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
19 changes: 10 additions & 9 deletions tests/ert/unit_tests/config/test_observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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",
):
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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",
),
Expand All @@ -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",
),
Expand All @@ -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",
),
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")


Expand Down

0 comments on commit 906a9b9

Please sign in to comment.