transientskp / tkp

A transients-discovery pipeline for astronomical image-based surveys
http://docs.transientskp.org/
BSD 2-Clause "Simplified" License
19 stars 14 forks source link

ERROR: test_store_varmetric (test_alchemy.TestApi) #584

Closed AntoniaR closed 3 years ago

AntoniaR commented 3 years ago

When running the TraP test suite on the branch Issue579, this error arose:

======================================================================
ERROR: test_store_varmetric (test_alchemy.TestApi)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/antoniar/TraP_Develop/tkp/tests/test_database/test_alchemy.py", line 125, in test_store_varmetric
    q = tkp.db.alchemy.varmetric.store_varmetric(self.session, self.dataset1)
  File "/home/antoniar/TraP_Develop/tkp/tkp/db/alchemy/varmetric.py", line 217, in store_varmetric
    filtered = session.query(*fields).select_from(subquery)
  File "/home/antoniar/TraP_Develop_Env/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2106, in query
    return self._query_cls(entities, self, **kwargs)
  File "/home/antoniar/TraP_Develop_Env/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 180, in __init__
    self._set_entities(entities)
  File "/home/antoniar/TraP_Develop_Env/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 194, in _set_entities
    for ent in util.to_list(entities)
  File "/home/antoniar/TraP_Develop_Env/local/lib/python2.7/site-packages/sqlalchemy/sql/coercions.py", line 188, in expect
    element, argname=argname, **kw
  File "/home/antoniar/TraP_Develop_Env/local/lib/python2.7/site-packages/sqlalchemy/sql/coercions.py", line 388, in _literal_coercion
    return self._text_coercion(element, argname, **kw)
  File "/home/antoniar/TraP_Develop_Env/local/lib/python2.7/site-packages/sqlalchemy/sql/coercions.py", line 834, in _text_coercion
    else "column",
ArgumentError: Textual column expression 'runcat' should be explicitly declared with text('runcat'), or use column('runcat') for more specificity

It is not related to the changes made to resolve Issue579 see Issue579

The issue is with this part of the code and sqlalchemy wants things specifying more explicitly.

https://github.com/transientskp/tkp/blob/fa65950f6a8891e97880e483e03206a06e5f130e/tkp/db/alchemy/varmetric.py#L210-L217

I think this issue from Stack overflow explains how to fix it... https://stackoverflow.com/questions/54483184/sqlalchemy-warning-textual-column-expression-should-be-explicitly-declared Though I'm not sure if just casting it as text would help or if it needs to be defined in the more complex column format.

AntoniaR commented 3 years ago

This issue is caused by using the latest version of sqlalchemy. Short term work around given in Issue #586

Will close this issue for now and return to it as part of upgrades to Python 3.0 in Issue #371.