Update no_trainer examples to use new logger (#17044)

* Propagate and fix imports
This commit is contained in:
Zachary Mueller
2022-05-02 11:56:15 -04:00
committed by GitHub
parent daecae1f1c
commit 35d48db881
13 changed files with 38 additions and 76 deletions

View File

@@ -35,6 +35,7 @@ from tqdm.auto import tqdm
import transformers
from accelerate import Accelerator
from accelerate.logging import get_logger
from accelerate.utils import set_seed
from huggingface_hub import Repository
from transformers import (
@@ -55,7 +56,7 @@ from transformers.utils import get_full_repo_name
from transformers.utils.versions import require_version
logger = logging.getLogger(__name__)
logger = get_logger(__name__)
require_version("datasets>=1.8.0", "To fix: pip install -r examples/pytorch/translation/requirements.txt")
# You should update this to your particular problem to have better documentation of `model_type`
@@ -295,11 +296,7 @@ def main():
datefmt="%m/%d/%Y %H:%M:%S",
level=logging.INFO,
)
logger.info(accelerator.state)
# Setup logging, we only want one process per machine to log things on the screen.
# accelerator.is_local_main_process is only True for one process per machine.
logger.setLevel(logging.INFO if accelerator.is_local_main_process else logging.ERROR)
logger.info(accelerator.state, main_process_only=False)
if accelerator.is_local_main_process:
datasets.utils.logging.set_verbosity_warning()
transformers.utils.logging.set_verbosity_info()