This is bad:
What a user to do if they need to use PYTHONWARNINGS?
Adding to the existing setting is the way, but overriding it is taking away control from the user.
And after removing this override I still can't figure why I'm getting these:
PYTHONWARNINGS=ignore python -c "import pytorch_lightning"
/home/stas/anaconda3/envs/main-38/lib/python3.8/site-packages/wandb/util.py:36: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
from collections import namedtuple, Mapping, Sequence
/home/stas/anaconda3/envs/main-38/lib/python3.8/site-packages/wandb/vendor/graphql-core-1.1/graphql/type/directives.py:55: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
assert isinstance(locations, collections.Iterable), 'Must provide locations for directive.'
PYTHONWARNINGS=ignore / -W ignore doesn't get rid of those.
There must be yet another override somewhere else.
I reported the deprecations https://github.com/wandb/client/issues/1503, but clearly something in PL or its dependencies is stealing user's control away still.
Thanks.
@teddykoker
This makes sense to me, I'll submit a PR to remove that line. I searched the full codebase and couldn't find any other usage of PYTHONWARNINGS.
Additionally I checked the dependencies in requirements.txt and couldn't find PYTHONWARNINGS. I know some of the logging libraries override code in places, but I can't think of an easy way to recursively search all dependencies for this override.
It has something to do with wandb, I reduced it to:
PYTHONWARNINGS=ignore python -c "import pytorch_lightning.loggers.wandb"
/home/stas/anaconda3/envs/main-38/lib/python3.8/site-packages/wandb/util.py:36: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
from collections import namedtuple, Mapping, Sequence
/home/stas/anaconda3/envs/main-38/lib/python3.8/site-packages/wandb/vendor/graphql-core-1.1/graphql/type/directives.py:55: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
assert isinstance(locations, collections.Iterable), 'Must provide locations for directive.'
Strangely, the following doesn't emit any warnings:
python -c "import wandb; from wandb.wandb_run import Run"
so there must be some interaction going there, that it happens when invoked from pytorch_lightning.loggers.wandb.
(One can isolate the cause relatively quickly, by commenting out all of __init__.py, and then bisecting, until you find which import causes the problem, then stepping into that module and repeating this process again. Took me probably 5 min to reduce it to wandb - but at times it's a slower process)
nailed it:
PYTHONWARNINGS=ignore python -c "import mlflow, wandb"
/home/stas/anaconda3/envs/main-38/lib/python3.8/site-packages/wandb/util.py:36: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working
from collections import namedtuple, Mapping, Sequence
/home/stas/anaconda3/envs/main-38/lib/python3.8/site-packages/wandb/vendor/graphql-core-1.1/graphql/type/directives.py:55: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Pyth
The guilty line is:
https://github.com/mlflow/mlflow/blob/2f5b870d81b92d0e3558c3b36a820f8eaf3cda59/mlflow/__init__.py#L45
warnings.filterwarnings("module", category=DeprecationWarning)
bug report filed: https://github.com/mlflow/mlflow/issues/3704