pyro-ppl / pyro

Deep universal probabilistic programming with Python and PyTorch
http://pyro.ai
Apache License 2.0
8.55k stars 987 forks source link

Incompatibility with pipreqs #2018

Open rdturnermtl opened 5 years ago

rdturnermtl commented 5 years ago

Issue Description

The pyro package has an incompatibility with the pipreqs tool. pipreqs can generate a list of dependencies for any code base using imports. However, there is an ambiguity with the other pyro package. When pipreqs encounters import pyro it does not know which package we plan to import.

Environment

ProductName:    Mac OS X
ProductVersion: 10.14.6
BuildVersion:   18G87

>>> python --version
Python 3.6.5

>>> pip freeze
certifi==2019.6.16
chardet==3.0.4
docopt==0.6.2
idna==2.8
pipreqs==0.4.9
requests==2.22.0
urllib3==1.25.3
yarg==0.1.9

>>> python -c 'import pyro; print(pyro.__version__)'
0.4.0

Code Snippet

If we run pipreqs with the above requirements,

>>> pipreqs folder_using_pyro/

Then we get a requirements file:

matplotlib==3.1.1
numpy==1.17.0
pandas==0.25.0
pyro==3.16
seaborn==0.9.0
torch==1.2.0

After installing pip install pyro-ppl to get pyro in the environment, then pipreqs gives both packages:

pyro_ppl==0.4.0
numpy==1.17.0
torch==1.2.0
matplotlib==3.1.1
pandas==0.25.0
pyro==3.16
seaborn==0.9.0

The source file tested on in folder_using_pyro is the example here:

import os
from functools import partial
import numpy as np
import pandas as pd
import seaborn as sns
import torch
import torch.nn as nn

import matplotlib.pyplot as plt

import pyro
from pyro.distributions import Normal, Uniform, Delta
from pyro.infer import SVI, Trace_ELBO
from pyro.optim import Adam
from pyro.distributions.util import logsumexp
from pyro.infer import EmpiricalMarginal, SVI, Trace_ELBO, TracePredictive
from pyro.infer.mcmc import MCMC, NUTS
import pyro.optim as optim
import pyro.poutine as poutine

# for CI testing
smoke_test = ('CI' in os.environ)
assert pyro.__version__.startswith('0.4.0')
pyro.enable_validation(True)
pyro.set_rng_seed(1)
pyro.enable_validation(True)
jpchen commented 5 years ago

this sounds like a pipreq issue. can you add it to their module mappings? seems to work for other projects that have the same issue.

rdturnermtl commented 5 years ago

Issue has been filled on pipreqs side with #168.