Closed infacc closed 1 year ago
The actual error happens in a celery task. However, the API should not fail because of an error in a recommender task. That part is easy to fix. Can you also provide the stacktrace from the original exception (it should be in the worker log)? The last line unfortunately does not contain the full stacktrace.
Here is the corresponding worker log:
[2023-08-23 10:43:34,623: ERROR/MainProcess] Task qhana_plugin_registry.recommendations.recommenders.step_data_recommender.fetch_votes[76a42cdf-ab85-4600-8454-913f018eb486] raised unexpected: ProgrammingError('(psycopg2.errors.GroupingError) column "required.count_2" must appear in the GROUP BY clause or be used in an aggregate function\nLINE 1: SELECT "DataToRamp".ramp_id, count(*) AS count_1, required.c...\n ^\n')
Traceback (most recent call last):
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
self.dialect.do_execute(
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/.venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.GroupingError: column "required.count_2" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT "DataToRamp".ramp_id, count(*) AS count_1, required.c...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/.venv/lib/python3.10/site-packages/celery/app/trace.py", line 451, in trace_task
R = retval = fun(*args, **kwargs)
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/qhana_plugin_registry/celery.py", line 41, in __call__
return self.run(*args, **kwargs)
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/qhana_plugin_registry/recommendations/recommenders/step_data_recommender.py", line 112, in fetch_votes
ids: Sequence[Tuple[int, int, int]] = DB.session.execute(q).all()
File "<string>", line 2, in execute
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/.venv/lib/python3.10/site-packages/sqlalchemy/orm/session.py", line 1712, in execute
result = conn._execute_20(statement, params or {}, execution_options)
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1705, in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/.venv/lib/python3.10/site-packages/sqlalchemy/sql/elements.py", line 333, in _execute_on_connection
return connection._execute_clauseelement(
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1572, in _execute_clauseelement
ret = self._execute_context(
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1943, in _execute_context
self._handle_dbapi_exception(
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 2124, in _handle_dbapi_exception
util.raise_(
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/.venv/lib/python3.10/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
raise exception
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/.venv/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
self.dialect.do_execute(
File "/mnt/e/Temp/hiwi/qhana-plugin-registry/.venv/lib/python3.10/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.GroupingError) column "required.count_2" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT "DataToRamp".ramp_id, count(*) AS count_1, required.c...
^
[SQL: SELECT "DataToRamp".ramp_id, count(*) AS count_1, required.count_2
FROM "DataToRamp" LEFT OUTER JOIN (SELECT "DataToRamp".ramp_id AS ramp_id, count(*) AS count_2
FROM "DataToRamp"
WHERE "DataToRamp".relation = %(relation_1)s AND "DataToRamp".required = true GROUP BY "DataToRamp".ramp_id) AS required ON "DataToRamp".ramp_id = required.ramp_id
WHERE "DataToRamp".relation = %(relation_2)s AND "DataToRamp".required = true AND ("DataToRamp".data_type_start = %(data_type_start_1)s OR "DataToRamp".data_type_start = %(data_type_start_2)s) AND ("DataToRamp".data_type_end = %(data_type_end_1)s OR "DataToRamp".data_type_end = %(data_type_end_2)s) AND (EXISTS (SELECT "ContentTypeToData".data_id
FROM "ContentTypeToData"
WHERE "DataToRamp".id = "ContentTypeToData".data_id AND ("ContentTypeToData".content_type_start = %(content_type_start_1)s OR "ContentTypeToData".content_type_start = %(content_type_start_2)s) AND ("ContentTypeToData".content_type_end = %(content_type_end_1)s OR "ContentTypeToData".content_type_end = %(content_type_end_2)s))) GROUP BY "DataToRamp".ramp_id]
[parameters: {'relation_1': 'consumed', 'relation_2': 'consumed', 'data_type_start_1': 'executable', 'data_type_start_2': '*', 'data_type_end_1': 'circuit', 'data_type_end_2': '*', 'content_type_start_1': 'text', 'content_type_start_2': '*', 'content_type_end_1': 'x-qasm', 'content_type_end_2': '*'}]
(Background on this error at: https://sqlalche.me/e/14/f405)
Can you test if the potential fix in #23 works with postgres?
The fix works for the timeline recommendations. I added it also to the data recommendations (same problem).
The plugin registry throws a
ProgrammingError
when getting recommendations. E.g. when selecting a timeline step in the UI.This bug occurs when running the qhana-docker compose setup. Locally the recommendations work as intended. I suppose it is related to using a PostgreSQL database.
Error log: