Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "allow_unmapped" to Ax SQA objects for SQA 2.0 forward compatibil…
…ity (#3008) Summary: Pull Request resolved: #3008 Pull Request resolved: #2748 T163607006 for more context OSS User trying to use Ax encountered this SQA error when using version 2.0: ``` ArgumentError: Type annotation for "SQAGeneratorRun.arms" can't be correctly interpreted for Annotated Declarative Table form. ORM annotations should normally make use of the ``Mapped[]`` generic type, or other ORM-compatible generic type, as a container for the actual type, which indicates the intent that the attribute is mapped. Class variables that are not intended to be mapped by the ORM should use ClassVar[]. To allow Annotated Declarative to disregard legacy annotations which don't use Mapped[] to pass, set "__allow_unmapped__ = True" on the class or a superclass this class. (Background on this error at: https://sqlalche.me/e/20/zlpr) ``` Currently SQA 1.4 is the only supported version internally. This change follows the suggestion of the error to set "__allow_unmapped__" equal to true, which is also suggested in the SQL alchemy wiki https://docs.sqlalchemy.org/en/20/changelog/migration_20.html?fbclid=IwZXh0bgNhZW0CMTEAAR083E0mVk0DkKTo9R1AimFUsoZ4iV2ei1BVKFYmH4iQVrMqcS6F6fv7ZUw_aem_S3WfZmTwJIdpYJkQDo2icQ#migration-to-2-0-step-six-add-allow-unmapped-to-explicitly-typed-orm-models This should fix the issue encountered when using SQA 2.0 in OSS. Errors came up: ``` ERROR ax/core/tests/test_experiment.py - sqlalchemy.exc.ArgumentError: Could not interpret annotation list[SQAMetric]. Check that it uses names that are correctly imported at the module level. See chained stack trace for more hints. ERROR ax/service/tests/test_ax_client.py - sqlalchemy.exc.InvalidRequestError: Table 'parameter_v2' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object. ``` Fixing these led to another round of errors ``` FAILED ax/core/tests/test_experiment.py::ExperimentTest::test_clone_with - sqlalchemy.exc.ArgumentError: Strings are not accepted for attribute names in loader options; please use class-bound attributes directly. FAILED ax/service/tests/test_ax_client.py::TestAxClient::test_db_write_failure_on_create_experiment - ValueError: `db_settings` argument should be of type ax.storage.sqa_store.(Got: DBSettings(creator=None, decoder=<ax.storage.sqa_store.decoder.Decoder object at 0x7f0b971f5630>, encoder=<ax.storage.sqa_store.encoder.Encoder object at 0x7f0b971f6fe0>, url=None) of type <class 'ax.storage.sqa_store.structs.DBSettings'>. structs.DBSettings. To use `DBSettings`, you will need SQLAlchemy installed in your environment (can be installed through pip). FAILED ax/service/tests/test_ax_client.py::TestAxClient::test_save_and_load_generation_strategy - ValueError: `db_settings` argument should be of type ax.storage.sqa_store.(Got: DBSettings(creator=None, decoder=<ax.storage.sqa_store.decoder.Decoder object at 0x7f0ab0687d30>, encoder=<ax.storage.sqa_store.encoder.Encoder object at 0x7f0ab0685630>, url=None) of type <class 'ax.storage.sqa_store.structs.DBSettings'>. structs.DBSettings. To use `DBSettings`, you will need SQLAlchemy installed in your environment (can be installed through pip). FAILED ax/service/tests/test_ax_client.py::TestAxClient::test_sqa_storage - ValueError: `db_settings` argument should be of type ax.storage.sqa_store.(Got: DBSettings(creator=None, decoder=<ax.storage.sqa_store.decoder.Decoder object at 0x7f0b7f73b460>, encoder=<ax.storage.sqa_store.encoder.Encoder object at 0x7f0b7f7397b0>, url=None) of type <class 'ax.storage.sqa_store.structs.DBSettings'>. structs.DBSettings. To use `DBSettings`, you will need SQLAlchemy installed in your environment (can be installed through pip). ``` Reviewed By: Balandat, mgrange1998 Differential Revision: D62261700 fbshipit-source-id: 6a9968b07cfe7855652507f2d29f64a7ff80826a
- Loading branch information