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

@@ -36,6 +36,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 filelock import FileLock
from huggingface_hub import Repository
@@ -54,7 +55,7 @@ from transformers.utils import get_full_repo_name, is_offline_mode
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/summarization/requirements.txt")
# You should update this to your particular problem to have better documentation of `model_type`
@@ -322,11 +323,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()