ert 19.0.1__py3-none-any.whl → 20.0.0b0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. ert/__main__.py +94 -63
  2. ert/analysis/_es_update.py +11 -14
  3. ert/cli/main.py +1 -0
  4. ert/config/__init__.py +3 -2
  5. ert/config/_create_observation_dataframes.py +51 -375
  6. ert/config/_observations.py +483 -200
  7. ert/config/_read_summary.py +4 -5
  8. ert/config/ert_config.py +59 -67
  9. ert/config/everest_control.py +40 -39
  10. ert/config/everest_response.py +1 -13
  11. ert/config/field.py +0 -72
  12. ert/config/forward_model_step.py +17 -1
  13. ert/config/gen_data_config.py +14 -17
  14. ert/config/observation_config_migrations.py +821 -0
  15. ert/config/parameter_config.py +18 -28
  16. ert/config/parsing/__init__.py +0 -1
  17. ert/config/parsing/_parse_zonemap.py +45 -0
  18. ert/config/parsing/config_keywords.py +1 -0
  19. ert/config/parsing/config_schema.py +2 -0
  20. ert/config/parsing/observations_parser.py +2 -0
  21. ert/config/response_config.py +5 -23
  22. ert/config/rft_config.py +44 -19
  23. ert/config/summary_config.py +1 -13
  24. ert/config/surface_config.py +0 -57
  25. ert/dark_storage/compute/misfits.py +0 -42
  26. ert/dark_storage/endpoints/__init__.py +0 -2
  27. ert/dark_storage/endpoints/experiment_server.py +5 -3
  28. ert/dark_storage/endpoints/experiments.py +2 -5
  29. ert/dark_storage/json_schema/experiment.py +1 -2
  30. ert/ensemble_evaluator/config.py +2 -1
  31. ert/field_utils/__init__.py +0 -2
  32. ert/field_utils/field_utils.py +1 -117
  33. ert/gui/ertwidgets/listeditbox.py +9 -1
  34. ert/gui/ertwidgets/models/ertsummary.py +20 -6
  35. ert/gui/ertwidgets/pathchooser.py +9 -1
  36. ert/gui/ertwidgets/stringbox.py +11 -3
  37. ert/gui/ertwidgets/textbox.py +10 -3
  38. ert/gui/ertwidgets/validationsupport.py +19 -1
  39. ert/gui/main_window.py +11 -6
  40. ert/gui/simulation/experiment_panel.py +10 -3
  41. ert/gui/simulation/run_dialog.py +11 -1
  42. ert/gui/tools/manage_experiments/export_dialog.py +4 -0
  43. ert/gui/tools/manage_experiments/manage_experiments_panel.py +1 -0
  44. ert/gui/tools/manage_experiments/storage_info_widget.py +1 -1
  45. ert/gui/tools/manage_experiments/storage_widget.py +18 -3
  46. ert/gui/tools/plot/data_type_proxy_model.py +1 -1
  47. ert/gui/tools/plot/plot_api.py +35 -27
  48. ert/gui/tools/plot/plot_widget.py +5 -0
  49. ert/gui/tools/plot/plot_window.py +4 -7
  50. ert/plugins/plugin_manager.py +4 -0
  51. ert/run_models/ensemble_experiment.py +1 -3
  52. ert/run_models/ensemble_smoother.py +1 -3
  53. ert/run_models/everest_run_model.py +12 -13
  54. ert/run_models/initial_ensemble_run_model.py +19 -22
  55. ert/run_models/model_factory.py +7 -7
  56. ert/run_models/multiple_data_assimilation.py +1 -3
  57. ert/sample_prior.py +12 -14
  58. ert/services/__init__.py +7 -3
  59. ert/services/_storage_main.py +59 -22
  60. ert/services/ert_server.py +186 -24
  61. ert/shared/net_utils.py +43 -18
  62. ert/shared/version.py +3 -3
  63. ert/storage/local_ensemble.py +46 -115
  64. ert/storage/local_experiment.py +0 -16
  65. ert/utils/__init__.py +20 -0
  66. {ert-19.0.1.dist-info → ert-20.0.0b0.dist-info}/METADATA +4 -51
  67. {ert-19.0.1.dist-info → ert-20.0.0b0.dist-info}/RECORD +79 -84
  68. everest/bin/everest_script.py +5 -5
  69. everest/bin/kill_script.py +2 -2
  70. everest/bin/monitor_script.py +2 -2
  71. everest/bin/utils.py +4 -4
  72. everest/detached/everserver.py +6 -6
  73. everest/gui/everest_client.py +0 -6
  74. everest/gui/main_window.py +2 -2
  75. everest/util/__init__.py +1 -19
  76. ert/dark_storage/compute/__init__.py +0 -0
  77. ert/dark_storage/endpoints/compute/__init__.py +0 -0
  78. ert/dark_storage/endpoints/compute/misfits.py +0 -95
  79. ert/services/_base_service.py +0 -387
  80. ert/services/webviz_ert_service.py +0 -20
  81. ert/shared/storage/command.py +0 -38
  82. ert/shared/storage/extraction.py +0 -42
  83. {ert-19.0.1.dist-info → ert-20.0.0b0.dist-info}/WHEEL +0 -0
  84. {ert-19.0.1.dist-info → ert-20.0.0b0.dist-info}/entry_points.txt +0 -0
  85. {ert-19.0.1.dist-info → ert-20.0.0b0.dist-info}/licenses/COPYING +0 -0
  86. {ert-19.0.1.dist-info → ert-20.0.0b0.dist-info}/top_level.txt +0 -0
ert/__main__.py CHANGED
@@ -8,10 +8,12 @@ import multiprocessing
8
8
  import os
9
9
  import re
10
10
  import resource
11
+ import shutil
11
12
  import sys
12
13
  import warnings
13
14
  from argparse import ArgumentParser, ArgumentTypeError
14
15
  from collections.abc import Sequence
16
+ from datetime import datetime
15
17
  from pathlib import Path
16
18
  from typing import Any
17
19
  from uuid import UUID
@@ -24,6 +26,9 @@ from _ert.threading import set_signal_handler
24
26
  from ert.base_model_context import use_runtime_plugins
25
27
  from ert.cli.main import ErtCliError, run_cli
26
28
  from ert.config import ConfigValidationError, ErtConfig, lint_file
29
+ from ert.config.observation_config_migrations import (
30
+ remove_refcase_and_time_map_dependence_from_obs_config,
31
+ )
27
32
  from ert.logging import LOGGING_CONFIG
28
33
  from ert.mode_definitions import (
29
34
  ENIF_MODE,
@@ -36,9 +41,9 @@ from ert.mode_definitions import (
36
41
  from ert.namespace import Namespace
37
42
  from ert.plugins import ErtRuntimePlugins, get_site_plugins, setup_site_logging
38
43
  from ert.run_models.multiple_data_assimilation import MultipleDataAssimilationConfig
39
- from ert.services import ErtServer, WebvizErt
44
+ from ert.services import ErtServer
45
+ from ert.services._storage_main import add_parser_options as ert_api_add_parser_options
40
46
  from ert.shared.status.utils import get_ert_memory_usage
41
- from ert.shared.storage.command import add_parser_options as ert_api_add_parser_options
42
47
  from ert.storage import ErtStorageException, ErtStoragePermissionError
43
48
  from ert.trace import trace, tracer
44
49
  from ert.validation import (
@@ -53,6 +58,66 @@ from ert.validation import (
53
58
  logger = logging.getLogger(__name__)
54
59
 
55
60
 
61
+ def run_convert_observations(
62
+ args: Namespace, _: ErtRuntimePlugins | None = None
63
+ ) -> None:
64
+ changes = remove_refcase_and_time_map_dependence_from_obs_config(args.config)
65
+
66
+ if changes is None or changes.is_empty():
67
+ logger.info("convert_observations did not make any changes")
68
+ print(
69
+ "No observations dependent on TIME_MAP / REFCASE found, you can "
70
+ "safely remove TIME_MAP / REFCASE and the "
71
+ "corresponding files from ERT config."
72
+ )
73
+ return
74
+
75
+ obs_config_to_edit_path = changes.obs_config_path + ".updated"
76
+ print(
77
+ f"Making copy of obs config "
78
+ f"@ {changes.obs_config_path} -> {obs_config_to_edit_path}"
79
+ )
80
+
81
+ shutil.copy(changes.obs_config_path, obs_config_to_edit_path)
82
+ print(f"Applying change to obs config @ {obs_config_to_edit_path}...")
83
+ changes.apply_to_file(Path(obs_config_to_edit_path))
84
+ convert_observations_trace = ""
85
+ for history_change in changes.history_changes:
86
+ convert_observations_trace += (
87
+ f"History obs {history_change.source_observation.name} "
88
+ f"-> {len(history_change.summary_obs_declarations)} summary observations\n"
89
+ )
90
+
91
+ for gen_obs_change in changes.general_obs_changes:
92
+ convert_observations_trace += (
93
+ f"General obs {gen_obs_change.source_observation.name}, changing "
94
+ f"DATE {gen_obs_change.source_observation.date} "
95
+ f"to RESTART={gen_obs_change.restart}\n"
96
+ )
97
+ for summary_change in changes.summary_obs_changes:
98
+ convert_observations_trace += (
99
+ f"Summary obs {summary_change.source_observation.name}, changing "
100
+ f"RESTART {summary_change.source_observation.restart} "
101
+ f"to DATE={summary_change.date}\n"
102
+ )
103
+
104
+ logger.info(f"convert_observations trace: \n {convert_observations_trace}")
105
+ print(convert_observations_trace)
106
+
107
+ os.rename(
108
+ changes.obs_config_path,
109
+ f"{changes.obs_config_path}-{datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}.old",
110
+ )
111
+ os.rename(obs_config_to_edit_path, changes.obs_config_path)
112
+ msg = (
113
+ f"Observation changes applied to {changes.obs_config_path}. The old "
114
+ f"observations file is now at {changes.obs_config_path}.old and can be "
115
+ f"safely deleted if the new one works."
116
+ )
117
+ print(msg)
118
+ logger.info(msg)
119
+
120
+
56
121
  def run_ert_storage(args: Namespace, _: ErtRuntimePlugins | None = None) -> None:
57
122
  with ErtServer.start_server(
58
123
  verbose=True,
@@ -63,67 +128,24 @@ def run_ert_storage(args: Namespace, _: ErtRuntimePlugins | None = None) -> None
63
128
 
64
129
 
65
130
  def run_webviz_ert(args: Namespace, _: ErtRuntimePlugins | None = None) -> None:
66
- try:
67
- import webviz_ert # type: ignore # noqa
68
- except ImportError as err:
69
- raise ValueError(
70
- "Running `ert vis` requires that webviz_ert is installed"
71
- ) from err
72
-
73
- kwargs: dict[str, Any] = {"verbose": args.verbose}
74
- ert_config = ErtConfig.with_plugins(get_site_plugins()).from_file(args.config)
75
-
76
- os.chdir(ert_config.config_path)
77
- ens_path = ert_config.ens_path
78
-
79
- # Changing current working directory means we need to
80
- # only use the base name of the config file path
81
- kwargs["ert_config"] = os.path.basename(args.config)
82
- kwargs["project"] = os.path.abspath(ens_path)
83
-
84
131
  yellow = "\x1b[33m"
85
132
  green = "\x1b[32m"
86
133
  bold = "\x1b[1m"
87
134
  reset = "\x1b[0m"
88
135
 
89
- try:
90
- with ErtServer.init_service(project=Path(ens_path).absolute()) as storage:
91
- storage.wait_until_ready()
92
- print(
93
- f"""
136
+ print(
137
+ f"""
94
138
  ---------------------------------------------------------------
95
139
 
96
- {yellow}{bold}Webviz-ERT is deprecated and will be removed in the near future{reset}
140
+ {yellow}{bold}Webviz-ERT is removed.
97
141
 
98
142
  {green}{bold}Plotting capabilities provided by Webviz-ERT are now available
99
143
  using the ERT plotter{reset}
100
144
 
101
- ---------------------------------------------------------------
102
-
103
- Starting up Webviz-ERT. This might take more than a minute.
104
-
105
145
  ---------------------------------------------------------------
106
146
  """
107
- )
108
- logger.info("Show Webviz-ert deprecation warning")
109
- webviz_kwargs = {
110
- "experimental_mode": args.experimental_mode,
111
- "verbose": args.verbose,
112
- "title": kwargs.get("ert_config", "ERT - Visualization tool"),
113
- "project": kwargs.get("project", os.getcwd()),
114
- }
115
- with WebvizErt.start_server(**webviz_kwargs) as webviz_ert_server:
116
- webviz_ert_server.wait()
117
- except PermissionError as pe:
118
- print(f"Error: {pe}", file=sys.stderr)
119
- print(
120
- "Cannot start or connect to storage service due to permission issues.",
121
- file=sys.stderr,
122
- )
123
- print(
124
- "This is most likely due to another user starting ERT using this storage",
125
- file=sys.stderr,
126
- )
147
+ )
148
+ logger.info("Show Webviz-ert removal warning")
127
149
 
128
150
 
129
151
  def strip_error_message_and_raise_exception(validated: ValidationStatus) -> None:
@@ -317,19 +339,6 @@ def get_ert_parser(parser: ArgumentParser | None = None) -> ArgumentParser:
317
339
  ert_api_parser.set_defaults(func=run_ert_storage)
318
340
  ert_api_add_parser_options(ert_api_parser)
319
341
 
320
- ert_vis_parser = subparsers.add_parser(
321
- "vis",
322
- description="Launch webviz-driven visualization tool.",
323
- )
324
- ert_vis_parser.set_defaults(func=run_webviz_ert)
325
- ert_vis_parser.add_argument("--name", "-n", type=str, default="Webviz-ERT")
326
- ert_vis_parser.add_argument(
327
- "--experimental-mode",
328
- action="store_true",
329
- help="Feature flag for enabling experimental plugins",
330
- )
331
- ert_api_add_parser_options(ert_vis_parser) # ert vis shares args with ert api
332
-
333
342
  # test_run_parser
334
343
  test_run_description = f"Run '{TEST_RUN_MODE}' in cli"
335
344
  test_run_parser = subparsers.add_parser(
@@ -564,6 +573,28 @@ def get_ert_parser(parser: ArgumentParser | None = None) -> ArgumentParser:
564
573
  "--ensemble", help="Which ensemble to use", default=None
565
574
  )
566
575
 
576
+ # convert_observations_parser
577
+ convert_obs_parser = subparsers.add_parser(
578
+ "convert_observations",
579
+ help=(
580
+ "Convert HISTORY_OBSERVATION to SUMMARY_OBSERVATION and "
581
+ "remove REFCASE and TIME_MAP from ERT config."
582
+ ),
583
+ description=(
584
+ "Convert HISTORY_OBSERVATION to SUMMARY_OBSERVATION, "
585
+ "and embed REFCASE and TIME_MAP into observations"
586
+ ),
587
+ )
588
+ convert_obs_parser.set_defaults(func=run_convert_observations)
589
+ convert_obs_parser.add_argument(
590
+ "config",
591
+ type=valid_file,
592
+ help="Path to ERT config file",
593
+ )
594
+ convert_obs_parser.add_argument(
595
+ "--verbose", action="store_true", help="Show verbose output.", default=False
596
+ )
597
+
567
598
  # Common arguments/defaults for all non-gui modes
568
599
  for cli_parser in [
569
600
  test_run_parser,
@@ -323,16 +323,13 @@ def analysis_ES(
323
323
  logger.info(log_msg)
324
324
  progress_callback(AnalysisStatusEvent(msg=log_msg))
325
325
 
326
- log_msg = f"There are {num_obs} responses and {ensemble_size} realizations."
327
- logger.info(log_msg)
328
- progress_callback(AnalysisStatusEvent(msg=log_msg))
329
-
330
- log_msg = (
331
- f"There are {(~non_zero_variance_mask).sum()} parameters with 0 variance "
332
- f"that will not be updated."
333
- )
334
- logger.info(log_msg)
335
- progress_callback(AnalysisStatusEvent(msg=log_msg))
326
+ if (param_count := (~non_zero_variance_mask).sum()) > 0:
327
+ log_msg = (
328
+ f"There are {param_count} parameters with 0 variance "
329
+ f"that will not be updated."
330
+ )
331
+ logger.info(log_msg)
332
+ progress_callback(AnalysisStatusEvent(msg=log_msg))
336
333
 
337
334
  if module.localization:
338
335
  config_node = source_ensemble.experiment.parameter_configuration[
@@ -382,16 +379,16 @@ def analysis_ES(
382
379
  )
383
380
 
384
381
  else:
382
+ log_msg = f"There are {num_obs} responses and {ensemble_size} realizations."
383
+ logger.info(log_msg)
384
+ progress_callback(AnalysisStatusEvent(msg=log_msg))
385
+
385
386
  # In-place multiplication is not yet supported, therefore avoiding @=
386
387
  param_ensemble_array[non_zero_variance_mask] = param_ensemble_array[ # noqa: PLR6104
387
388
  non_zero_variance_mask
388
389
  ] @ T.astype(param_ensemble_array.dtype)
389
390
 
390
- log_msg = f"Storing data for {param_group}.."
391
- logger.info(log_msg)
392
- progress_callback(AnalysisStatusEvent(msg=log_msg))
393
391
  start = time.time()
394
-
395
392
  target_ensemble.save_parameters_numpy(
396
393
  param_ensemble_array, param_group, iens_active_index
397
394
  )
ert/cli/main.py CHANGED
@@ -133,6 +133,7 @@ def run_cli(args: Namespace, runtime_plugins: ErtRuntimePlugins | None = None) -
133
133
  if args.port_range is None
134
134
  else (min(args.port_range), max(args.port_range) + 1),
135
135
  use_ipc_protocol=using_local_queuesystem,
136
+ prioritize_private_ip_address=ert_config.prioritize_private_ip_address,
136
137
  )
137
138
 
138
139
  if model.check_if_runpath_exists():
ert/config/__init__.py CHANGED
@@ -1,3 +1,4 @@
1
+ from ._observations import Observation
1
2
  from .analysis_config import (
2
3
  AnalysisConfig,
3
4
  ObservationGroups,
@@ -47,7 +48,7 @@ from .queue_config import (
47
48
  LocalQueueOptions,
48
49
  QueueConfig,
49
50
  )
50
- from .response_config import InvalidResponseFile, ResponseConfig, ResponseMetadata
51
+ from .response_config import InvalidResponseFile, ResponseConfig
51
52
  from .rft_config import RFTConfig
52
53
  from .summary_config import SummaryConfig
53
54
  from .surface_config import SurfaceConfig
@@ -113,6 +114,7 @@ __all__ = [
113
114
  "LegacyWorkflowConfigs",
114
115
  "LocalQueueOptions",
115
116
  "ModelConfig",
117
+ "Observation",
116
118
  "ObservationGroups",
117
119
  "ObservationSettings",
118
120
  "ObservationType",
@@ -131,7 +133,6 @@ __all__ = [
131
133
  "QueueSystem",
132
134
  "RFTConfig",
133
135
  "ResponseConfig",
134
- "ResponseMetadata",
135
136
  "SamplerConfig",
136
137
  "SiteInstalledForwardModelStep",
137
138
  "SiteOrUserForwardModelStep",