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

SQLA queries fail due to AbstractConcreteBase and has a mapping pending until all subclasses are defined #262

Open
albireox opened this issue Aug 3, 2024 · 0 comments

Comments

@albireox
Copy link
Member

albireox commented Aug 3, 2024

When I try a query using the SQLAlchemy model they all fail with error AbstractConcreteBase and has a mapping pending until all subclasses are defined.

For example

>>> from sdssdb.sqlalchemy.sdss5db import database, catalogdb

>>> database.set_profile('tunnel_pipelines')
True

>>> session = database.Session()

>>> session.query(catalogdb.Gaia_DR3).first()
[ERROR]: Traceback (most recent call last):
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3577, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-5-3e43bb8cd684>", line 1, in <module>
    x = session.query(catalogdb.Gaia_DR3).first()
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 2166, in query
    return self._query_cls(entities, self, **kwargs)
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/orm/query.py", line 180, in __init__
    self._set_entities(entities)
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/orm/query.py", line 187, in _set_entities
    self._raw_columns = [
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/orm/query.py", line 188, in <listcomp>
    coercions.expect(
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/sql/coercions.py", line 183, in expect
    insp = inspection.inspect(element, raiseerr=False)
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/inspection.py", line 64, in inspect
    ret = reg(subject)
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/orm/decl_api.py", line 1056, in _inspect_decl_meta
    _DeferredMapperConfig.raise_unmapped_for_cls(cls)
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/orm/decl_base.py", line 1091, in raise_unmapped_for_cls
    class_._sa_raise_deferred_config()
  File "/Users/gallegoj/.pyenv/versions/3.10.14/envs/valis/lib/python3.10/site-packages/sqlalchemy/ext/declarative/extensions.py", line 307, in _sa_raise_deferred_config
    raise orm_exc.UnmappedClassError(
sqlalchemy.orm.exc.UnmappedClassError: Class sdssdb.sqlalchemy.sdss5db.catalogdb.Gaia_DR3 is a subclass of AbstractConcreteBase and has a mapping pending until all subclasses are defined. Call the sqlalchemy.orm.configure_mappers() function after all subclasses have been defined to complete the mapping of this class.

Running configure_mappers() doesn't seem to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant