Skip to content

Commit

Permalink
Use scheduler to start Everserver
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Nov 13, 2024
1 parent 8903abb commit 4540d0d
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 574 deletions.
30 changes: 8 additions & 22 deletions src/everest/bin/everest_script.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
#!/usr/bin/env python

import argparse
import asyncio
import json
import logging
import signal
import threading
from functools import partial

from ert.config import ErtConfig
from ert.storage import open_storage
from everest.config import EverestConfig, ServerConfig
from everest.detached import (
ServerStatus,
everserver_status,
generate_everserver_ert_config,
server_is_running,
start_server,
wait_for_context,
wait_for_server,
)
from everest.plugins.site_config_env import PluginSiteConfigEnv
from everest.util import makedirs_if_needed, version_info

from .utils import (
Expand Down Expand Up @@ -48,7 +44,7 @@ def everest_entry(args=None):
partial(handle_keyboard_interrupt, options=options),
)

run_everest(options)
asyncio.run(run_everest(options))


def _build_args_parser():
Expand Down Expand Up @@ -80,7 +76,7 @@ def _build_args_parser():
return arg_parser


def run_everest(options):
async def run_everest(options):
logger = logging.getLogger("everest_main")
server_state = everserver_status(options.config)

Expand All @@ -100,22 +96,12 @@ def run_everest(options):
job_name = fm_job.split()[0]
logger.info("Everest forward model contains job {}".format(job_name))

with PluginSiteConfigEnv():
ert_config = ErtConfig.with_plugins().from_dict(
config_dict=generate_everserver_ert_config(
options.config, options.debug
)
)

makedirs_if_needed(options.config.output_dir, roll_if_exists=True)

with open_storage(ert_config.ens_path, "w") as storage, PluginSiteConfigEnv():
context = start_server(options.config, ert_config, storage)
print("Waiting for server ...")
wait_for_server(options.config, timeout=600, context=context)
print("Everest server found!")
run_detached_monitor(options.config, show_all_jobs=options.show_all_jobs)
wait_for_context()
await start_server(options.config, options.debug)
print("Waiting for server ...")
wait_for_server(options.config, timeout=600)
print("Everest server found!")
run_detached_monitor(options.config, show_all_jobs=options.show_all_jobs)

server_state = everserver_status(options.config)
server_state_info = server_state["message"]
Expand Down
2 changes: 1 addition & 1 deletion src/everest/config/everest_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class EverestConfig(BaseModelWithPropertySupport): # type: ignore
""",
)
simulator: Optional[SimulatorConfig] = Field(
default=None, description="Simulation settings"
default_factory=SimulatorConfig, description="Simulation settings"
)
forward_model: Optional[List[str]] = Field(
default=None, description="List of jobs to run"
Expand Down
4 changes: 2 additions & 2 deletions src/everest/config/server_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class ServerConfig(BaseModel, HasErtQueueOptions): # type: ignore
""",
) # Corresponds to queue name
exclude_host: Optional[str] = Field(
None,
"",
description="""Comma separated list of nodes that should be
excluded from the slurm run""",
)
include_host: Optional[str] = Field(
None,
"",
description="""Comma separated list of nodes that
should be included in the slurm run""",
)
Expand Down
4 changes: 2 additions & 2 deletions src/everest/config/simulator_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class SimulatorConfig(BaseModel, HasErtQueueOptions, extra="forbid"): # type: i
"needs to be deleted.",
)
exclude_host: Optional[str] = Field(
None,
"",
description="""Comma separated list of nodes that should be
excluded from the slurm run.""",
)
include_host: Optional[str] = Field(
None,
"",
description="""Comma separated list of nodes that
should be included in the slurm run""",
)
Expand Down
Loading

0 comments on commit 4540d0d

Please sign in to comment.