Skip to content

Commit

Permalink
Inline addNode function
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Oct 4, 2024
1 parent 5adb6c4 commit 611105a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
15 changes: 0 additions & 15 deletions src/ert/config/ensemble_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,6 @@ def hasNodeGenData(self, key: str) -> bool:
config = self.response_configs["gen_data"]
return key in config.keys

def addNode(self, config_node: Union[ParameterConfig, ResponseConfig]) -> None:
assert config_node is not None
if config_node.name in self:
raise ConfigValidationError(
f"Config node with key {config_node.name!r} already present in ensemble config"
)

if isinstance(config_node, ParameterConfig):
logger.info(
f"Adding {type(config_node).__name__} config (of size {len(config_node)}) to parameter_configs"
)
self.parameter_configs[config_node.name] = config_node
else:
self.response_configs[config_node.name] = config_node

def get_keylist_gen_kw(self) -> List[str]:
return [
val.name
Expand Down
20 changes: 8 additions & 12 deletions src/ert/simulator/batch_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,17 @@ def callback(*args, **kwargs):

ens_config = self.ert_config.ensemble_config
for control_name, variables in controls.items():
ens_config.addNode(
ExtParamConfig(
name=control_name,
input_keys=variables,
output_file=control_name + ".json",
)
ens_config.parameter_configs[control_name] = ExtParamConfig(
name=control_name,
input_keys=variables,
output_file=control_name + ".json",
)

if "gen_data" not in ens_config:
ens_config.addNode(
GenDataConfig(
keys=results,
input_files=[f"{k}" for k in results],
report_steps_list=[None for _ in results],
)
ens_config.response_configs["gen_data"] = GenDataConfig(
keys=results,
input_files=[f"{k}" for k in results],
report_steps_list=[None for _ in results],
)
else:
existing_gendata = ens_config.response_configs["gen_data"]
Expand Down

0 comments on commit 611105a

Please sign in to comment.