py-why / EconML

ALICE (Automated Learning and Intelligence for Causation and Economics) is a Microsoft Research project aimed at applying Artificial Intelligence concepts to economic decision making. One of its goals is to build a toolkit that combines state-of-the-art machine learning techniques with econometrics in order to bring automation to complex causal inference problems. To date, the ALICE Python SDK (econml) implements orthogonal machine learning algorithms such as the double machine learning work of Chernozhukov et al. This toolkit is designed to measure the causal effect of some treatment variable(s) t on an outcome variable y, controlling for a set of features x.
https://www.microsoft.com/en-us/research/project/alice/
Other
3.82k stars 716 forks source link

Unable to run tests #913

Open ronikobrosly opened 2 months ago

ronikobrosly commented 2 months ago

Hi, I'm working on a PR but first I'd like to make sure I can get all tests running. I followed all of the instructions in the For Developers, Pre-commit hooks, and Running the tests section of the README. When I run the command python setup.py pytest I get the following:

(econml) C:\Users\ronik\Desktop\EconML>python setup.py pytest
C:\Users\ronik\anaconda3\envs\econml\lib\site-packages\ptr\__init__.py:81: SetuptoolsDeprecationWarning: The test command is disabled and references to it are deprecated.
!!

        ********************************************************************************
        Please remove any references to `setuptools.command.test` in all supported versions of the affected package.

        By 2024-Nov-15, you need to update your project and remove deprecated calls
        or your builds will no longer be supported.
        ********************************************************************************

!!
  class PyTest(orig.test):
running pytest
Traceback (most recent call last):
  File "setup.py", line 34, in <module>
    setup(ext_modules=c_extensions + pyx_extensions,
  File "C:\Users\ronik\anaconda3\envs\econml\lib\site-packages\setuptools\__init__.py", line 111, in setup
    return distutils.core.setup(**attrs)
  File "C:\Users\ronik\anaconda3\envs\econml\lib\site-packages\setuptools\_distutils\core.py", line 184, in setup
    return run_commands(dist)
  File "C:\Users\ronik\anaconda3\envs\econml\lib\site-packages\setuptools\_distutils\core.py", line 200, in run_commands
    dist.run_commands()
  File "C:\Users\ronik\anaconda3\envs\econml\lib\site-packages\setuptools\_distutils\dist.py", line 964, in run_commands
    self.run_command(cmd)
  File "C:\Users\ronik\anaconda3\envs\econml\lib\site-packages\setuptools\dist.py", line 948, in run_command
    super().run_command(command)
  File "C:\Users\ronik\anaconda3\envs\econml\lib\site-packages\setuptools\_distutils\dist.py", line 983, in run_command
    cmd_obj.run()
  File "C:\Users\ronik\anaconda3\envs\econml\lib\site-packages\ptr\__init__.py", line 195, in run
    setattr(dist, attr, getattr(self.distribution, attr))
AttributeError: 'Distribution' object has no attribute 'tests_require'

This is with python 3.8.x. Any suggestions?

kbattocchi commented 2 months ago

Oops, that documentation is out of date - it should say python -m pytest rather than python setup.py pytest, I'll update it.

Even with that change, it's likely that you'll need some extra dependencies for tests - I think pip install pytest pytest-xdist pytest-cov coverage[toml] will get all of the test runner dependencies, and you'll also need to run pip install jupyter jupyter-client nbconvert nbformat seaborn xgboost tqdm if you want to run the notebook tests. (You'll also need to have installed the [all] extra for econml, or else you'll might be missing some package dependencies like tensorflow that are needed only by a smaller subset of our API).

However, as mentioned in that section of the README, it usually does not make sense to run all of the tests, so I'd default to using unittest to just run the tests for the code that you're working on (but thanks for the bug report, we shouldn't have misleading directions in the README).

ronikobrosly commented 2 months ago

Okay thanks for the heads up @kbattocchi !