MCPcopy Create free account
hub / github.com/ModalityDance/Omni-R1 / LoggingLevel

Function LoggingLevel

src/transformers/src/transformers/testing_utils.py:1453–1470  ·  view source on GitHub ↗

This is a context manager to temporarily change transformers modules logging level to the desired value and have it restored to the original setting at the end of the scope. Example: ```python with LoggingLevel(logging.INFO): AutoModel.from_pretrained("openai-community

(level)

Source from the content-addressed store, hash-verified

1451
1452@contextlib.contextmanager
1453def LoggingLevel(level):
1454 """
1455 This is a context manager to temporarily change transformers modules logging level to the desired value and have it
1456 restored to the original setting at the end of the scope.
1457
1458 Example:
1459
1460 ```python
1461 with LoggingLevel(logging.INFO):
1462 AutoModel.from_pretrained("openai-community/gpt2") # calls logger.info() several times
1463 ```
1464 """
1465 orig_level = transformers_logging.get_verbosity()
1466 try:
1467 transformers_logging.set_verbosity(level)
1468 yield
1469 finally:
1470 transformers_logging.set_verbosity(orig_level)
1471
1472
1473@contextlib.contextmanager

Calls

no outgoing calls

Tested by

no test coverage detected