Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial notebook Exception #62

Closed
acbecker opened this issue Jun 4, 2019 · 2 comments · Fixed by #68
Closed

Tutorial notebook Exception #62

acbecker opened this issue Jun 4, 2019 · 2 comments · Fixed by #68
Assignees
Labels
bug Something isn't working

Comments

@acbecker
Copy link

acbecker commented Jun 4, 2019

I downloaded the notebook available on https://gluon-ts.mxnet.io/examples/forecasting/tutorial.html, and run it on my local laptop (Darwin Kernel Version 16.7.0, Anaconda3 Distro, Python 3.7.3, Jupyter 4.4.0, gluonts 0.1.1) and get the following exception at:

from gluonts.model.simple_feedforward import SimpleFeedForwardEstimator
from gluonts.trainer import Trainer
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/python/anaconda3/lib/python3.7/site-packages/pydantic/validators.py in find_validators(type_, arbitrary_types_allowed)
    261         try:
--> 262             if issubclass(type_, val_type):
    263                 return validators

TypeError: issubclass() arg 1 must be a class

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
<ipython-input-13-1fca1cb620ad> in <module>
----> 1 from gluonts.model.simple_feedforward import SimpleFeedForwardEstimator
      2 from gluonts.trainer import Trainer

~/python/anaconda3/lib/python3.7/site-packages/gluonts/model/simple_feedforward/__init__.py in <module>
      1 # Relative imports
----> 2 from ._estimator import SimpleFeedForwardEstimator
      3 
      4 __all__ = ['SimpleFeedForwardEstimator']

~/python/anaconda3/lib/python3.7/site-packages/gluonts/model/simple_feedforward/_estimator.py in <module>
      7 # First-party imports
      8 from gluonts.core.component import validated
----> 9 from gluonts.distribution import DistributionOutput, StudentTOutput
     10 from gluonts.model.estimator import GluonEstimator
     11 from gluonts.model.predictor import Predictor, RepresentableBlockPredictor

~/python/anaconda3/lib/python3.7/site-packages/gluonts/distribution/__init__.py in <module>
     14 # Relative imports
     15 from . import bijection
---> 16 from .binned import Binned, BinnedOutput
     17 from .distribution import Distribution
     18 from .distribution_output import DistributionOutput

~/python/anaconda3/lib/python3.7/site-packages/gluonts/distribution/binned.py in <module>
    166 
    167 
--> 168 class BinnedOutput(DistributionOutput):
    169     distr_cls: type = Binned
    170 

~/python/anaconda3/lib/python3.7/site-packages/gluonts/distribution/binned.py in BinnedOutput()
    170 
    171     @validated()
--> 172     def __init__(self, bin_centers: List) -> None:
    173         # cannot pass directly nd.array because it is not serializable
    174         bc = mx.nd.array(bin_centers)

~/python/anaconda3/lib/python3.7/site-packages/gluonts/core/component.py in validator(ctor)
    167                 f'{ctor_clsnme}Model',
    168                 __config__=ConfigBase.Config,
--> 169                 **ctor_fields,
    170             )
    171         else:

~/python/anaconda3/lib/python3.7/site-packages/pydantic/main.py in create_model(model_name, __config__, __base__, **field_definitions)
    408                 annotation=f_annotation,
    409                 class_validators=vg.get_validators(f_name),
--> 410                 config=config,
    411             )
    412 

~/python/anaconda3/lib/python3.7/site-packages/pydantic/fields.py in infer(cls, name, value, annotation, class_validators, config)
    105             required=required,
    106             model_config=config,
--> 107             schema=schema,
    108         )
    109 

~/python/anaconda3/lib/python3.7/site-packages/pydantic/fields.py in __init__(self, name, type_, class_validators, default, required, model_config, alias, allow_none, schema)
     85         self.shape: Shape = Shape.SINGLETON
     86         self._schema: Schema = schema
---> 87         self.prepare()
     88 
     89     @classmethod

~/python/anaconda3/lib/python3.7/site-packages/pydantic/fields.py in prepare(self)
    134 
    135         self._populate_sub_fields()
--> 136         self._populate_validators()
    137 
    138     def schema(self, by_alias=True):

~/python/anaconda3/lib/python3.7/site-packages/pydantic/fields.py in _populate_validators(self)
    264                 *tuple(v.func for v in self.class_validators if not v.whole and v.pre),
    265                 *(get_validators() if get_validators else find_validators(self.type_,
--> 266                                                                           self.model_config.arbitrary_types_allowed)),
    267                 *tuple(v.func for v in self.class_validators if not v.whole and not v.pre),
    268             )

~/python/anaconda3/lib/python3.7/site-packages/pydantic/validators.py in find_validators(type_, arbitrary_types_allowed)
    263                 return validators
    264         except TypeError as e:
--> 265             raise RuntimeError(f'error checking inheritance of {type_!r} (type: {display_as_type(type_)})') from e
    266 
    267     if arbitrary_types_allowed:

RuntimeError: error checking inheritance of ~T (type: T)
@lostella
Copy link
Contributor

lostella commented Jun 4, 2019

Hi @acbecker, I just tried running the notebook on a similar configuration: Darwin Kernel Version 17.7.0, Python 3.7.3 (pyenv), Jupyter 4.4.0, gluonts 0.1.1.

I could not reproduce this problem. I did find other problems, but once I get to the cell you mention, everything works OK. We'll keep this here and see again if we can reproduce it. Could Anaconda vs pyenv make a difference?

@jgasthaus
Copy link
Contributor

I was able to reproduce this issue locally and I think #68 should fix it.

@acbecker While we are preparing a new release, can you try if installing a development release,

pip install --upgrade git+https://github.com/jgasthaus/gluon-ts@fix_python37

resolves the issue for you?

@jgasthaus jgasthaus added the bug Something isn't working label Jun 5, 2019
@jgasthaus jgasthaus self-assigned this Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants