Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove function that gave impression everest was logging to azure #9558

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/everest/bin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from everest.bin.kill_script import kill_entry
from everest.bin.monitor_script import monitor_entry
from everest.bin.visualization_script import visualization_entry
from everest.util import get_azure_logging_handler
from everest.plugins.everest_plugin_manager import EverestPluginManager


def _create_dump_action(dumps, extended=False):
Expand Down Expand Up @@ -86,12 +86,9 @@ def __init__(self, args):
if not hasattr(self, parsed_args.command):
parser.error("Unrecognized command")

# Setup logging to azure:
logger = logging.getLogger("everest_main")
azure_handler = get_azure_logging_handler()
if azure_handler:
logger.addHandler(azure_handler)

# Setup logging from plugins:
EverestPluginManager().add_log_handle_to_root()
logger = logging.getLogger(__name__)
logger.info(f"Started everest with {parsed_args}")
# Use dispatch pattern to invoke method with same name
getattr(self, parsed_args.command)(args[2:])
Expand Down
15 changes: 4 additions & 11 deletions src/everest/detached/jobs/everserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from everest.config import EverestConfig, ServerConfig
from everest.detached import ServerStatus, get_opt_status, update_everserver_status
from everest.export import check_for_errors
from everest.plugins.everest_plugin_manager import EverestPluginManager
from everest.simulator import JOB_FAILURE
from everest.strings import (
DEFAULT_LOGGING_FORMAT,
Expand All @@ -48,7 +49,7 @@
SIM_PROGRESS_ENDPOINT,
STOP_ENDPOINT,
)
from everest.util import get_azure_logging_handler, makedirs_if_needed, version_info
from everest.util import makedirs_if_needed, version_info


def _get_machine_name() -> str:
Expand Down Expand Up @@ -208,30 +209,21 @@ def make_handler_config(
"filename": path,
}

def azure_handler():
azure_handler = get_azure_logging_handler()
if azure_handler:
return azure_handler
return logging.NullHandler()

logging_config = {
"version": 1,
"disable_existing_loggers": False,
"handlers": {
"root": {"level": "NOTSET", "class": "logging.NullHandler"},
"res": make_handler_config(detached_dir / "simulations.log"),
"everserver": make_handler_config(detached_dir / "endpoint.log"),
"everest": make_handler_config(log_dir / "everest.log", logging_level),
"forward_models": make_handler_config(
log_dir / "forward_models.log", logging_level
),
"azure_handler": {"()": azure_handler},
},
"loggers": {
"": {"handlers": ["root"], "level": "NOTSET"},
"res": {"handlers": ["res"]},
"everserver": {"handlers": ["everserver"]},
"everest": {"handlers": ["everest", "azure_handler"]},
"everest": {"handlers": ["everest"]},
"forward_models": {"handlers": ["forward_models"]},
},
"formatters": {
Expand All @@ -240,6 +232,7 @@ def azure_handler():
}

logging.config.dictConfig(logging_config)
EverestPluginManager().add_log_handle_to_root()


def main():
Expand Down
6 changes: 6 additions & 0 deletions src/everest/plugins/everest_plugin_manager.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from typing import Any

import pluggy
Expand All @@ -20,3 +21,8 @@ def __init__(self, plugins=None) -> None:
def get_documentation(self) -> dict[str, Any]:
docs = self.hook.get_forward_model_documentations()
return {k: v for d in docs for k, v in d.items()} if docs else {}

def add_log_handle_to_root(self):
root_logger = logging.getLogger()
for handler in self.hook.add_log_handle_to_root():
root_logger.addHandler(handler)
8 changes: 0 additions & 8 deletions src/everest/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from ropt.version import version as ropt_version

from ert.shared.version import version as ert_version
from everest.plugins.everest_plugin_manager import EverestPluginManager
from everest.strings import DATE_FORMAT, EVEREST
from everest.util.async_run import async_run # noqa

Expand All @@ -23,13 +22,6 @@ def has_opm():
return False


def get_azure_logging_handler():
pm = EverestPluginManager()
handles = pm.hook.add_log_handle_to_root()
if handles:
return handles[0]


def version_info():
return ("everest:'{}'\nropt:'{}'\nert:'{}'").format(
ert_version, ropt_version, ert_version
Expand Down
Loading