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

fix: Use logging instead of print statements for backend loading and UniSim data storage messages #19

Merged
merged 2 commits into from
Jul 18, 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
5 changes: 3 additions & 2 deletions unisim/backend/load_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.

import logging
import os

from ..config import get_accelerator, get_backend, set_accelerator, set_backend
Expand Down Expand Up @@ -83,5 +84,5 @@
else:
raise ValueError(f"Unknown backend {get_backend()}")

print("INFO: Loaded backend")
print(f"INFO: Using {get_backend().name.upper()} with {get_accelerator().name.upper()}")
logging.info("Loaded backend")
logging.info("Using %s with %s", get_backend().name.upper(), get_accelerator().name.upper())
11 changes: 6 additions & 5 deletions unisim/unisim.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.

import logging
from abc import ABC
from typing import Any, Dict, List, Sequence

Expand Down Expand Up @@ -81,14 +82,14 @@ def __init__(
self.verbose = verbose

if self.store_data:
print("INFO: UniSim is storing a copy of the indexed data")
print("INFO: If you are using large data corpus, consider disabling this behavior using store_data=False")
logging.info("UniSim is storing a copy of the indexed data")
logging.info("If you are using large data corpus, consider disabling this behavior using store_data=False")
else:
print("INFO: UniSim is not storing a copy of the indexed data to save memory")
print("INFO: If you want to store a copy of the data, use store_data=True")
logging.info("UniSim is not storing a copy of the indexed data to save memory")
logging.info("If you want to store a copy of the data, use store_data=True")

if use_accelerator and get_accelerator() == AcceleratorType.cpu:
print("INFO: Accelerator is not available, using CPU")
logging.info("Accelerator is not available, using CPU")
self.use_accelerator = False

# internal state
Expand Down