def _run(workspace: Workspace, args: Any, plugin_registry: ert3.config.ConfigPluginRegistry) -> None: assert args.sub_cmd == "run" workspace.assert_experiment_exists(args.experiment_name) ert.storage.assert_storage_initialized(workspace_name=workspace.name) experiment_run_config = workspace.load_experiment_run_config( args.experiment_name, plugin_registry=plugin_registry) if args.local_test_run: if args.realization is None: realization = 0 else: realization = args.realization experiment_run_config = _build_local_test_run_config( experiment_run_config, plugin_registry=plugin_registry, realization=realization, ) else: if args.realization is not None: raise ert.exceptions.ExperimentError( "Specifying realization index only works for local test runs.") if experiment_run_config.experiment_config.type == "evaluation": ert3.engine.run( experiment_run_config, workspace, args.experiment_name, local_test_run=args.local_test_run, ) elif experiment_run_config.experiment_config.type == "sensitivity": ert3.engine.run_sensitivity_analysis(experiment_run_config, workspace, args.experiment_name)
def _run(workspace: Workspace, args: Any) -> None: assert args.sub_cmd == "run" workspace.assert_experiment_exists(args.experiment_name) ert.storage.assert_storage_initialized(workspace_name=workspace.name) experiment_run_config = workspace.load_experiment_run_config( args.experiment_name) if experiment_run_config.experiment_config.type == "evaluation": ert3.engine.run(experiment_run_config, workspace, args.experiment_name) elif experiment_run_config.experiment_config.type == "sensitivity": ert3.engine.run_sensitivity_analysis(experiment_run_config, workspace, args.experiment_name)
def _main() -> None: parser = _build_argparser() args = parser.parse_args() # Commands that do not require an ert workspace: if args.sub_cmd is None: parser.print_help() return if args.sub_cmd == "init": _init(args) return elif args.sub_cmd == "service": _service(args) return # The remaining commands require an existing ert workspace: workspace = Workspace(pathlib.Path.cwd()) if args.sub_cmd == "run": _run(workspace, args) elif args.sub_cmd == "export": _export(workspace, args) elif args.sub_cmd == "record": _record(workspace, args) elif args.sub_cmd == "status": _status(workspace, args) elif args.sub_cmd == "clean": _clean(workspace, args) else: raise NotImplementedError( f"No implementation to handle command {args.sub_cmd}")
def _record(workspace: Workspace, args: Any) -> None: assert args.sub_cmd == "record" if args.sub_record_cmd == "sample": parameters_config = workspace.load_parameters_config() collection = ert3.engine.sample_record( parameters_config, args.parameter_group, args.ensemble_size, ) future = ert.storage.transmit_record_collection( record_coll=collection, record_name=args.record_name, workspace_name=workspace.name, ) get_event_loop().run_until_complete(future) elif args.sub_record_cmd == "load": if args.mime_type == "guess" and not args.blob_record: guess = mimetypes.guess_type(str(args.record_file))[0] if guess: if ert.serialization.has_serializer(guess): record_mime = guess else: print(f"Unsupported type '{guess}', defaulting to " + f"'{DEFAULT_RECORD_MIME_TYPE}'.") record_mime = DEFAULT_RECORD_MIME_TYPE else: print(f"Unable to guess what type '{args.record_file}' is, " + f"defaulting to '{DEFAULT_RECORD_MIME_TYPE}'.") record_mime = DEFAULT_RECORD_MIME_TYPE else: record_mime = args.mime_type if args.blob_record or args.is_directory: record_mime = "application/octet-stream" get_event_loop().run_until_complete( ert3.engine.load_record( workspace, args.record_name, args.record_file, record_mime, args.is_directory, )) else: raise NotImplementedError( f"No implementation to handle record command {args.sub_record_cmd}" )
def _main() -> None: parser = _build_argparser() args = parser.parse_args() # Commands that do not require an ert workspace: if args.sub_cmd is None: parser.print_help() return if args.sub_cmd == "init": _init(args) return elif args.sub_cmd == "service": _service(args) return elif args.sub_cmd == "vis": _visualise(args) return # The remaining commands require an existing ert workspace: workspace = Workspace(pathlib.Path.cwd()) plugin_registry = ert3.config.ConfigPluginRegistry() plugin_registry.register_category( category="transformation", optional=True, base_config=ert3.config.plugins.TransformationConfigBase, ) plugin_manager = ert3.plugins.ErtPluginManager() plugin_manager.collect(registry=plugin_registry) if args.sub_cmd == "run": _run(workspace, args, plugin_registry=plugin_registry) elif args.sub_cmd == "export": _export(workspace, args, plugin_registry=plugin_registry) elif args.sub_cmd == "record": _record(workspace, args) elif args.sub_cmd == "status": _status(workspace, args) elif args.sub_cmd == "clean": _clean(workspace, args) else: raise NotImplementedError( f"No implementation to handle command {args.sub_cmd}")
def _export(workspace: Workspace, args: Any, plugin_registry: ert3.config.ConfigPluginRegistry) -> None: assert args.sub_cmd == "export" experiment_run_config = workspace.load_experiment_run_config( args.experiment_name, plugin_registry=plugin_registry) ert3.engine.export(workspace, args.experiment_name, experiment_run_config)
workspace = Workspace(pathlib.Path.cwd()) plugin_registry = ert3.config.ConfigPluginRegistry() plugin_registry.register_category( category="transformation", optional=True, base_config=ert3.config.plugins.TransformationConfigBase, ) plugin_manager = ert3.plugins.ErtPluginManager() plugin_manager.collect(registry=plugin_registry) if args.sub_cmd == "run": _run(workspace, args, plugin_registry=plugin_registry) elif args.sub_cmd == "export": _export(workspace, args, plugin_registry=plugin_registry) elif args.sub_cmd == "record": _record(workspace, args) elif args.sub_cmd == "status": _status(workspace, args) elif args.sub_cmd == "clean": _clean(workspace, args) else: raise NotImplementedError( f"No implementation to handle command {args.sub_cmd}") if __name__ == "__main__": workspace_ = Workspace(pathlib.Path.cwd()) ert3.console.clean(workspace_, set(), True) _main()
def _export(workspace: Workspace, args: Any) -> None: assert args.sub_cmd == "export" experiment_run_config = workspace.load_experiment_run_config( args.experiment_name) ert3.engine.export(workspace, args.experiment_name, experiment_run_config)