Skip to content

Commit ab1cc5c

Browse files
Migrate to modern logger interface (#80)
## Description The `logger.warn()` method is deprecated since Python2.7 and replaced with `logger.warning()`. It leads to those warnings: ```python DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead ``` This small PR resolves those warnings. It also fixes a few typos along the way. Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
1 parent d12d5a1 commit ab1cc5c

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

python/cuopt_self_hosted/cuopt_sh_client/cuopt_self_host_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ def get_optimized_routes(
659659
Delete the solution when it is returned. Defaults to True.
660660
"""
661661
if filepath and cuopt_problem_json_data.startswith("/"):
662-
log.warn(
662+
log.warning(
663663
"Path of the data file on the server was specified, "
664664
"but an absolute path was given. "
665665
"Best practice is to specify the relative path of a "
@@ -782,7 +782,7 @@ def read_cuopt_problem_data(cuopt_data_model, filepath):
782782
cuopt_data_model = _mps_parse(cuopt_data_model, solver_config)
783783

784784
elif filepath and cuopt_data_model.startswith("/"):
785-
log.warn(
785+
log.warning(
786786
"Path of the data file on the server was specified, "
787787
"but an absolute path was given. "
788788
"Best practice is to specify the relative path of a "
@@ -904,7 +904,7 @@ def delete_solution(self, id):
904904
pass
905905

906906
except requests.exceptions.HTTPError as e:
907-
log.warn(f"Deletion of solution {id} failed")
907+
log.warning(f"Deletion of solution {id} failed")
908908
log.debug(str(e))
909909
err, _ = self._handle_request_exception(response)
910910
raise ValueError(err)

python/cuopt_server/cuopt_server/cuopt_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def watcher(app_exit, results_queue, job_queue, abort_queue, abort_list):
6363
# extract GPU id number from each line (looks like "GPU 0: ..."
6464
gpu_ids = [s.split(" ")[1][0:-1] for s in gpu_string]
6565

66-
# if for some reson the parse failed (nvidia-smi output changed)
66+
# if for some reason the parse failed (nvidia-smi output changed)
6767
gpu_ids = [s for s in gpu_ids if s.isnumeric()]
6868
except Exception:
6969
gpu_string = None
@@ -391,7 +391,7 @@ def record_factory(*args, **kwargs):
391391
else:
392392
if gpu_count < 1:
393393
gpu_count = 1
394-
logging.warn("GPU count cannot be less than 1")
394+
logging.warning("GPU count cannot be less than 1")
395395
if gpu_count < len(gpu_ids):
396396
gpu_ids = gpu_ids[0:gpu_count]
397397

python/cuopt_server/cuopt_server/utils/job_queue.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def check_client_version(client_vers):
110110
return []
111111
cv = client_vers.split(".")
112112
if len(cv) < 2:
113-
logging.warn("Client version missing or bad format")
113+
logging.warning("Client version missing or bad format")
114114
return [
115115
f"Client version missing or not the current format. "
116116
f"Please upgrade your cuOpt client to '{major}.{minor}', "
@@ -121,7 +121,7 @@ def check_client_version(client_vers):
121121
cmajor, cminor = cv[:2]
122122
matches = (cmajor, cminor) == (major, minor)
123123
if not matches:
124-
logging.warn(f"Client version {cmajor}.{cminor} does not match")
124+
logging.warning(f"Client version {cmajor}.{cminor} does not match")
125125
return [
126126
f"Client version is '{cmajor}.{cminor}' but server "
127127
f"version is '{major}.{minor}'. Please use a matching client."
@@ -569,7 +569,7 @@ def add_incumbent(self, sol):
569569
# we know when the list has reached empty again
570570
# we can send the sentinel value
571571
if self.is_done():
572-
logging.warn("Incumbent added after job marked done!")
572+
logging.warning("Incumbent added after job marked done!")
573573
sol["solution"] = sol["solution"].tolist()
574574
self.incumbents.append(sol)
575575

@@ -636,7 +636,7 @@ def set_data_size_and_type(self, size, rtype):
636636

637637
# might as well make sure these match
638638
if rtype != self.rtype:
639-
logging.warn(
639+
logging.warning(
640640
"in set_data_size_and_type result mime_type "
641641
f"does not match, updating {rtype} {self.rtype}"
642642
)
@@ -872,7 +872,7 @@ def _load_data(self):
872872
)
873873
logging.debug(
874874
message(
875-
"feature check succeeeded for tier '%s', "
875+
"feature check succeeded for tier '%s', "
876876
% request_filter.get_tier()
877877
)
878878
)
@@ -1445,7 +1445,7 @@ def _try_extension(self, ext, raw_data):
14451445
"Pickle data format is deprecated. "
14461446
"Use zlib, msgpack, or plain JSON"
14471447
)
1448-
logging.warn("pickle data is deprecated")
1448+
logging.warning("pickle data is deprecated")
14491449
logging.debug("pickle data")
14501450
else:
14511451
raise ValueError(
@@ -1763,8 +1763,8 @@ def process(self, abort_list):
17631763
res.set_result(exception_handler(e))
17641764

17651765

1766-
# TOOD: ExitJob is meant for the solver, Shutdown and
1767-
# CudaUnhealty are meant for the result thread
1766+
# TODO: ExitJob is meant for the solver, Shutdown and
1767+
# CudaUnhealthy are meant for the result thread
17681768
# Probably should be in different class hierarchies.
17691769
# The latter two probably ought to be SolveResponses
17701770
class ExitJob:

0 commit comments

Comments
 (0)