Fix: logging on py310 (#2802)

* feat: encourage py311

* fix: logging import on py310

* fix: do upper and simplify handling
This commit is contained in:
NanoCode012
2025-06-19 02:46:27 +07:00
committed by GitHub
parent a85efffbef
commit 0bb9077553
2 changed files with 16 additions and 8 deletions

View File

@@ -14,7 +14,7 @@ This guide covers all the ways you can install and set up Axolotl for your envir
## Requirements {#sec-requirements}
- NVIDIA GPU (Ampere architecture or newer for `bf16` and Flash Attention) or AMD GPU
- Python ≥3.10
- Python ≥3.11
- PyTorch ≥2.5.1
## Installation Methods {#sec-installation-methods}
@@ -153,7 +153,7 @@ We recommend using WSL2 (Windows Subsystem for Linux) or Docker.
### Conda/Pip venv {#sec-conda}
1. Install Python ≥3.10
1. Install Python ≥3.11
2. Install PyTorch: https://pytorch.org/get-started/locally/
3. Install Axolotl:
```{.bash}

View File

@@ -25,12 +25,20 @@ class AxolotlOrWarnErrorFilter(logging.Filter):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.axolotl_level = logging.getLevelNamesMapping()[
os.getenv("AXOLOTL_LOG_LEVEL", DEFAULT_AXOLOTL_LOG_LEVEL)
]
self.other_level = logging.getLevelNamesMapping()[
os.getenv("LOG_LEVEL", DEFAULT_LOG_LEVEL)
]
axolotl_log_level = os.getenv(
"AXOLOTL_LOG_LEVEL", DEFAULT_AXOLOTL_LOG_LEVEL
).upper()
other_log_level = os.getenv("LOG_LEVEL", DEFAULT_LOG_LEVEL).upper()
try:
# py311+ only
level_mapping = logging.getLevelNamesMapping()
self.axolotl_level = level_mapping[axolotl_log_level]
self.other_level = level_mapping[other_log_level]
except AttributeError:
# For py310, use getLevelName directly
self.axolotl_level = logging.getLevelName(axolotl_log_level)
self.other_level = logging.getLevelName(other_log_level)
def filter(self, record: LogRecord) -> bool:
# General filter