Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Dec 11, 2024
1 parent 5e51044 commit b21ea15
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
4 changes: 1 addition & 3 deletions src/ert/config/queue_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import re
import shutil
from abc import abstractmethod
from dataclasses import field
from copy import copy

from typing import Any, Literal, Mapping, Optional, no_type_check

import pydantic
Expand Down Expand Up @@ -290,7 +288,7 @@ class QueueConfig:
queue_options: (
LsfQueueOptions | TorqueQueueOptions | SlurmQueueOptions | LocalQueueOptions
) = pydantic.Field(default_factory=LocalQueueOptions, discriminator="name")
queue_options_test_run: LocalQueueOptions = field(default_factory=LocalQueueOptions)
queue_options_test_run: LocalQueueOptions = Field(default_factory=LocalQueueOptions)
stop_long_running: bool = False

@no_type_check
Expand Down
42 changes: 24 additions & 18 deletions tests/ert/unit_tests/config/config_dict_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os.path
import stat
from collections import defaultdict
from dataclasses import dataclass, fields
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Literal
from warnings import filterwarnings
Expand Down Expand Up @@ -134,37 +134,43 @@ def memory_with_unit_lsf(draw):

def valid_queue_options(queue_system: str):
return [
field.name.upper()
for field in fields(
queue_systems_and_options[QueueSystemWithGeneric(queue_system)]
)
if field.name != "name"
name.upper()
for name in queue_systems_and_options[
QueueSystemWithGeneric(queue_system)
].model_fields
if name != "name"
]


queue_options_by_type: dict[str, dict[str, list[str]]] = defaultdict(dict)
for system, options in queue_systems_and_options.items():
queue_options_by_type["string"][system.name] = [
field.name.upper()
for field in fields(options)
if ("String" in field.type or "str" in field.type)
and "memory" not in field.name
name.upper()
for name, field in options.model_fields.items()
if ("String" in str(field.annotation) or "str" in str(field.annotation))
and "memory" not in name
]
queue_options_by_type["bool"][system.name] = [
field.name.upper() for field in fields(options) if field.type == "bool"
name.upper()
for name, field in options.model_fields.items()
if "bool" in str(field.annotation)
]
queue_options_by_type["posint"][system.name] = [
field.name.upper()
for field in fields(options)
if "PositiveInt" in field.type or "NonNegativeInt" in field.type
name.upper()
for name, field in options.model_fields.items()
if "PositiveInt" in str(field.annotation)
or "NonNegativeInt" in str(field.annotation)
]
queue_options_by_type["posfloat"][system.name] = [
field.name.upper()
for field in fields(options)
if "NonNegativeFloat" in field.type or "PositiveFloat" in field.type
name.upper()
for name, field in options.model_fields.items()
if "NonNegativeFloat" in str(field.annotation)
or "PositiveFloat" in str(field.annotation)
]
queue_options_by_type["memory"][system.name] = [
field.name.upper() for field in fields(options) if "memory" in field.name
name.upper()
for name, field in options.model_fields.items()
if "memory" in str(field.annotation)
]


Expand Down

0 comments on commit b21ea15

Please sign in to comment.