Skip to content

Commit

Permalink
Remove ability to modify logging levels
Browse files Browse the repository at this point in the history
Summary: Logging levels were used inconsistently and would cause problems with multithreaded servers. We remove this ability.

Test Plan: Tests updated.
  • Loading branch information
JasonKChow committed Feb 10, 2025
1 parent c024380 commit 01d91b5
Show file tree
Hide file tree
Showing 19 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion aepsych/benchmark/pathos_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

ctx._force_start_method("spawn") # fixes problems with CUDA and fork

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


class PathosBenchmark(Benchmark):
Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/message_handlers/handle_ask.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import aepsych.utils_logging as utils_logging

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


def handle_ask(server, request):
Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/message_handlers/handle_can_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import aepsych.utils_logging as utils_logging

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


def handle_can_model(server, request):
Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/message_handlers/handle_exit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import aepsych.utils_logging as utils_logging

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


def handle_exit(server, request):
Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/message_handlers/handle_get_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import aepsych.utils_logging as utils_logging

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


def handle_get_config(server, request):
Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/message_handlers/handle_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import aepsych.utils_logging as utils_logging

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


def handle_info(server, request: Dict[str, Any]) -> Dict[str, Any]:
Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/message_handlers/handle_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import aepsych.utils_logging as utils_logging

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


def handle_params(server, request):
Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/message_handlers/handle_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import numpy as np
import torch

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


def handle_query(server, request):
Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/message_handlers/handle_resume.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import aepsych.utils_logging as utils_logging

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


def handle_resume(server, request):
Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/message_handlers/handle_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from aepsych.strategy import SequentialStrategy
from aepsych.version import __version__

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


def _configure(server, config):
Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/message_handlers/handle_tell.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import pandas as pd
import torch

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()
DEFAULT_DESC = "default description"
DEFAULT_NAME = "default name"

Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pandas as pd
from aepsych.server.message_handlers.handle_tell import flatten_tell_record

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


def replay(server, uuid_to_replay, skip_computations=False):
Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
)
from aepsych.strategy import SequentialStrategy, Strategy

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


def get_next_filename(folder, fname, ext):
Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import aepsych.utils_logging as utils_logging
import numpy as np

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()
BAD_REQUEST = "bad request"


Expand Down
2 changes: 1 addition & 1 deletion aepsych/server/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import aepsych.database.db as db
import aepsych.utils_logging as utils_logging

logger = utils_logging.getLogger(logging.INFO)
logger = utils_logging.getLogger()


def get_next_filename(folder, fname, ext):
Expand Down
10 changes: 7 additions & 3 deletions aepsych/utils_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def format(self, record):
return formatter.format(record)


def getLogger(level=logging.INFO, log_path: str = "logs") -> logging.Logger:
def getLogger(log_path: str = "logs") -> logging.Logger:
"""Get a logger with the specified level and log path.
Args:
Expand All @@ -53,7 +53,7 @@ def getLogger(level=logging.INFO, log_path: str = "logs") -> logging.Logger:
"formatters": {"standard": {"()": ColorFormatter}},
"handlers": {
"default": {
"level": level,
"level": logging.INFO,
"class": "logging.StreamHandler",
"formatter": "standard",
},
Expand All @@ -65,7 +65,11 @@ def getLogger(level=logging.INFO, log_path: str = "logs") -> logging.Logger:
},
},
"loggers": {
"": {"handlers": ["default", "file"], "level": level, "propagate": False},
"": {
"handlers": ["default", "file"],
"level": logging.DEBUG,
"propagate": False,
},
},
}

Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_pairwise_probit.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def test_hyperparam_consistency(self):
class PairwiseProbitModelServerTest(unittest.TestCase):
def setUp(self):
# setup logger
server.logger = utils_logging.getLogger(logging.DEBUG, "logs")
server.logger = utils_logging.getLogger("logs")
# random datebase path name without dashes
database_path = "./{}.db".format(str(uuid.uuid4().hex))
self.s = server.AEPsychServer(database_path=database_path)
Expand Down
2 changes: 1 addition & 1 deletion tests/server/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def asyncSetUp(self):
port = 5555

# setup logger
server.logger = utils_logging.getLogger(logging.DEBUG, "logs")
server.logger = utils_logging.getLogger("unittests")

# random datebase path name without dashes
database_path = self.database_path
Expand Down
2 changes: 1 addition & 1 deletion tests/test_datafetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def pre_seed_config(

def setUp(self):
# setup logger
server.logger = utils_logging.getLogger(logging.DEBUG, "logs")
server.logger = utils_logging.getLogger("logs")

database_path = Path(__file__).parent / "test_databases" / "1000_outcome.db"

Expand Down

0 comments on commit 01d91b5

Please sign in to comment.