Ax: [BUG?] Error when running `from ax.service.ax_client import AxClient`

Created on 26 Mar 2020  路  4Comments  路  Source: facebook/Ax

When running the test code for service API in the docs, there is an error. So what could go wrong here?
This happens on Python 3.8.2@arch linux and Ax 0.1.10, not on Ax 0.1.9.

P.S. Loop & developer API works fine on Python 3.8.2@arch linux and Ax 0.1.10.

NameError                                 Traceback (most recent call last)
<ipython-input-2-798f8f12f1e0> in <module>
----> 1 from ax.service.ax_client import AxClient
      2 from ax.utils.measurement.synthetic_functions import branin
      3 
      4 ax_client = AxClient()
      5 ax_client.create_experiment(

/usr/lib/python3.8/site-packages/ax/service/ax_client.py in <module>
     72 
     73 
---> 74 class AxClient:
     75     """
     76     Convenience handler for management of experimentation cycle through a

/usr/lib/python3.8/site-packages/ax/service/ax_client.py in AxClient()
    824         retries=3,
    825         default_return_on_suppression=False,
--> 826         exception_type=(OperationalError,),
    827     )
    828     def _save_experiment_and_maybe_generation_strategy_to_db_if_possible(

NameError: name 'OperationalError' is not defined
bug fixready

Most helpful comment

Let's actually re-open this because this is a real bug that we need to fix on our end! But yes that is absolutely the right intermediate solution.

@2timesjay, can you triage this?

All 4 comments

This is because you haven't installed SQLAlchemy. It's not listed as a requirement but the AxClient class contains the OperationalError (which comes from SQLAlchemy) in some of its methods' decorators.

@retry_on_exception(
        retries=3,
        default_return_on_suppression=False,
        exception_type=(OperationalError,),
    )
    def _save_experiment_and_maybe_generation_strategy_to_db_if_possible(
        self, save_generation_strategy: bool = True, suppress_all_errors: bool = False
    ) -> bool:

This decorator was recently added. It should either be replaced with some other logic, or SQLAlchemy should be listed as a requirement.

For now, try pip3 install SQLAlchemy to fix your bug.

Thanks for the solution!

Let's actually re-open this because this is a real bug that we need to fix on our end! But yes that is absolutely the right intermediate solution.

@2timesjay, can you triage this?

Fixed by release 0.1.11

Was this page helpful?
0 / 5 - 0 ratings