kiudee / cs-ranking

Context-sensitive ranking and choice in Python with PyTorch
https://cs-ranking.readthedocs.io
Apache License 2.0
66 stars 15 forks source link

Importing csrank causes error without optional theano installed #137

Closed kiudee closed 4 years ago

kiudee commented 4 years ago

Simply running

import csrank

after installing csrank from pip without any optional dependencies, results in the following error:

csrank.util.MissingExtraError: Could not import the optional dependency theano. Please install it or specify the "probabilistic" extra when installing this package.

This should definitely not happen.

Version: 1.2.0

timokau commented 4 years ago

Looks like this has been the case since optional dependencies were introduced. The problem is that we re-export everything at the top level, so import csrank will actually evaluate all the code. This will be solved by https://github.com/kiudee/cs-ranking/pull/115, though we probably want a faster intermediate solution.

timokau commented 4 years ago

I see two options:

  1. make the optional imports more lazy, i.e. only import at usage and not at module import
  2. make the optional imports mandatory again

(2) is probably best for a hotfix 1.2.1.