Home > Software design >  Cannot import kats python library: "ImportError: cannot import name 'outcome_constraint_fr
Cannot import kats python library: "ImportError: cannot import name 'outcome_constraint_fr

Time:03-15

I am working on an azure-databricks notebook, I've been using the kats library without problems for some weeks, but now it suddenly stopped working 3 days ago, this Friday (11/03/2022) and I can't understand the reason.

When I import the library or any of its module the following error pops out:

ImportError: cannot import name 'outcome_constraint_from_str' from 'ax.service.utils.instantiation' (/databricks/python/lib/python3.7/site-packages/ax/service/utils/instantiation.py)


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<command-719456472689071> in <module>
----> 1 import kats
      2 dir(kats)

/databricks/python/lib/python3.7/site-packages/kats/__init__.py in <module>
      1 from . import consts   # noqa
----> 2 from . import utils  # noqa
      3 from . import detectors  # noqa
      4 from . import models  # noqa
      5 from . import tsfeatures   # noqa

/databricks/python/lib/python3.7/site-packages/kats/utils/__init__.py in <module>
      5 from . import parameter_tuning_utils   # noqa
      6 from . import simulator   # noqa
----> 7 from . import time_series_parameter_tuning   # noqa

/databricks/python/lib/python3.7/site-packages/kats/utils/time_series_parameter_tuning.py in <module>
     36 from ax.modelbridge.registry import Models
     37 from ax.runners.synthetic import SyntheticRunner
---> 38 from ax.service.utils.instantiation import (
     39     outcome_constraint_from_str,
     40     parameter_from_json,

ImportError: cannot import name 'outcome_constraint_from_str' from 'ax.service.utils.instantiation' (/databricks/python/lib/python3.7/site-packages/ax/service/utils/instantiation.py)

The problem seems to be with one of the dependencies, which like kats is also developed by facebook: ax-platform I tried reinstalling and upgrading both kats and ax-platform and I cannot understand the reason. There are no older versions to go back to, but I noticed from their github page that the "outcome_constraint_from_str" function had received some modifications near the date it stopped working. enter image description here https://github.com/facebook/Ax/commit/7510bbd90d29702727a6185ad670d5bed2d1f8e5

Could it be just a bug of some new released modification?

CodePudding user response:

There are no older versions to go back to

There are two versions of Kats library.

• Kats 101, basic data structure and functionalities in Kats

• Kats 20x, advanced topics, including advanced forecasting techniques, advanced detection algorithms, TsFeatures, meta-learning, global model etc.

Try to install previous version of Kats library and then you can try.

Refer this github link

CodePudding user response:

I tried installing the previous version of the ax-platform and kats imported correctly. As of today (14/03/2022) this solved the issue:

pip install ax-platform==0.2.3
  • Related