Silence TensorFlow
=========================================================================================
|pip| |downloads|
Simple python package to shut up Tensorflow warnings and logs, letting you focus on the
important errors.
How do I install this package?
----------------------------------------------
As usual, just download it using pip:
.. code:: shell
pip install silence_tensorflow
How do I use it?
----------------------------------------
You only need to import the package before import Tensorflow:
.. code:: python
from silence_tensorflow import silence_tensorflow
silence_tensorflow()
import tensorflow as tf
...
# your code
Can it be done within the import?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sure, you can do everything with a single line by
importing the submodule auto:
.. code:: python
import silence_tensorflow.auto
import tensorflow as tf
...
# your code
How can I get pylint to ignore the unused import?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can use the flag 'disable=unused-import' as such:
.. code:: python
import silence_tensorflow.auto # pylint: disable=unused-import
import tensorflow as tf
...
# your code
How can I get pylint to ignore the unused variable?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you import silence_tensorflow in the context of a function
you will get a different warning from pyling: unused variable.
You can use the flag 'disable=unused-variable' as such:
.. code:: python
def func():
import silence_tensorflow.auto # pylint: disable=unused-variable
import tensorflow as tf
...
# your code
How does this work under the hood?
----------------------------------------
This package will set the `KMP_AFFINITY` system variable to `"noverbose"`,
`TF_CPP_MIN_LOG_LEVEL` to level `3` (only errors logged).
If you need a custom value for `KMP_AFFINITY` you should reset it after importing the package, as follows:
.. code:: python
import os
from silence_tensorflow import silence_tensorflow
backup = os.environ["KMP_AFFINITY"]
silence_tensorflow()
os.environ["KMP_AFFINITY"] = backup
.. |pip| image:: https://badge.fury.io/py/silence-tensorflow.svg
:target: https://badge.fury.io/py/silence-tensorflow
:alt: Pypi project
.. |downloads| image:: https://pepy.tech/badge/silence-tensorflow
:target: https://pepy.tech/badge/silence-tensorflow
:alt: Pypi total project downloads
Raw data
{
"_id": null,
"home_page": "https://github.com/LucaCappelletti94/silence_tensorflow",
"name": "silence-tensorflow",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Luca Cappelletti",
"author_email": "cappelletti.luca94@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/2e/1c/5c4aef549a6963b2c0eb90261a58d79af8fd1c893b613818a3ea6becfc2f/silence_tensorflow-1.2.1.tar.gz",
"platform": null,
"description": "Silence TensorFlow\n=========================================================================================\n|pip| |downloads|\n\nSimple python package to shut up Tensorflow warnings and logs, letting you focus on the \nimportant errors.\n\nHow do I install this package?\n----------------------------------------------\nAs usual, just download it using pip:\n\n.. code:: shell\n\n pip install silence_tensorflow\n\n\nHow do I use it?\n----------------------------------------\nYou only need to import the package before import Tensorflow:\n\n.. code:: python\n\n from silence_tensorflow import silence_tensorflow\n silence_tensorflow()\n import tensorflow as tf\n\n ...\n\n # your code\n\nCan it be done within the import?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nSure, you can do everything with a single line by\nimporting the submodule auto:\n\n.. code:: python\n\n import silence_tensorflow.auto\n import tensorflow as tf\n\n ...\n\n # your code\n\nHow can I get pylint to ignore the unused import?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nYou can use the flag 'disable=unused-import' as such:\n\n.. code:: python\n\n import silence_tensorflow.auto # pylint: disable=unused-import\n import tensorflow as tf\n\n ...\n\n # your code\n\nHow can I get pylint to ignore the unused variable?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nIf you import silence_tensorflow in the context of a function\nyou will get a different warning from pyling: unused variable.\nYou can use the flag 'disable=unused-variable' as such:\n\n.. code:: python\n \n def func():\n import silence_tensorflow.auto # pylint: disable=unused-variable\n import tensorflow as tf\n\n ...\n\n # your code\n\nHow does this work under the hood?\n----------------------------------------\nThis package will set the `KMP_AFFINITY` system variable to `\"noverbose\"`,\n`TF_CPP_MIN_LOG_LEVEL` to level `3` (only errors logged).\n\nIf you need a custom value for `KMP_AFFINITY` you should reset it after importing the package, as follows:\n\n.. code:: python\n\n import os\n from silence_tensorflow import silence_tensorflow\n backup = os.environ[\"KMP_AFFINITY\"]\n silence_tensorflow()\n os.environ[\"KMP_AFFINITY\"] = backup\n\n.. |pip| image:: https://badge.fury.io/py/silence-tensorflow.svg\n :target: https://badge.fury.io/py/silence-tensorflow\n :alt: Pypi project\n\n.. |downloads| image:: https://pepy.tech/badge/silence-tensorflow\n :target: https://pepy.tech/badge/silence-tensorflow\n :alt: Pypi total project downloads",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simple python package to shut up Tensorflow warnings and logs.",
"version": "1.2.1",
"project_urls": {
"Homepage": "https://github.com/LucaCappelletti94/silence_tensorflow"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2e1c5c4aef549a6963b2c0eb90261a58d79af8fd1c893b613818a3ea6becfc2f",
"md5": "dda2c2b04a99a5fcdb86364f230a8792",
"sha256": "b59e8ede929c46d244e1742c6e11ee91164d3e654ac6868061507031a788bf1c"
},
"downloads": -1,
"filename": "silence_tensorflow-1.2.1.tar.gz",
"has_sig": false,
"md5_digest": "dda2c2b04a99a5fcdb86364f230a8792",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3778,
"upload_time": "2022-08-22T17:36:14",
"upload_time_iso_8601": "2022-08-22T17:36:14.480570Z",
"url": "https://files.pythonhosted.org/packages/2e/1c/5c4aef549a6963b2c0eb90261a58d79af8fd1c893b613818a3ea6becfc2f/silence_tensorflow-1.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-08-22 17:36:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "LucaCappelletti94",
"github_project": "silence_tensorflow",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "silence-tensorflow"
}