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

Add genotype analysis loading #159

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add genotype analysis loading #159

wants to merge 4 commits into from

Conversation

ahdamin
Copy link
Contributor

@ahdamin ahdamin commented Dec 13, 2024

Reported Bug

An issue was reported related to update_comment, and the logs show:

File "/home/worker/app/genotype_api/api/endpoints/samples.py", line 143, in update_comment
    return await sample_service.set_sample_comment(sample_id=sample_id, comment=comment)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/worker/app/genotype_api/services/endpoint_services/sample_service.py", line 137, in set_sample_comment
    return self._get_sample_response(sample)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/worker/app/genotype_api/services/endpoint_services/sample_service.py", line 57, in _get_sample_response
    analyses: list[AnalysisOnSample] = self._get_analyses_on_sample(sample=sample)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/worker/app/genotype_api/services/endpoint_services/sample_service.py", line 41, in _get_analyses_on_sample
    if not sample.analyses:
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 566, in __get__
    return self.impl.get(state, dict_)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 1086, in get
    value = self._fire_loader_callables(state, key, passive)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/attributes.py", line 1121, in _fire_loader_callables
    return self.callable_(state, passive)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/strategies.py", line 967, in _load_for_state
    return self._emit_lazyload(
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/strategies.py", line 1130, in _emit_lazyload
    result = session.execute(
             ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2362, in execute
    return self._execute_internal(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2247, in _execute_internal
    result: Result[Any] = compile_state_cls.orm_execute_statement(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/context.py", line 305, in orm_execute_statement
    result = conn.execute(
             ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1418, in execute
    return meth(
           ^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/sql/elements.py", line 515, in _execute_on_connection
    return connection._execute_clauseelement(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1640, in _execute_clauseelement
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1821, in _execute_context
    self._handle_dbapi_exception(
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 2355, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/base.py", line 1815, in _execute_context
    context = constructor(
              ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 1418, in _init_compiled
    self.cursor = self.create_cursor()
                  ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 1752, in create_cursor
    return self.create_default_cursor()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/engine/default.py", line 1758, in create_default_cursor
    return self._dbapi_connection.cursor()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/pool/base.py", line 1485, in cursor
    return self.dbapi_connection.cursor(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/dialects/mysql/aiomysql.py", line 198, in cursor
    return AsyncAdapt_aiomysql_cursor(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/dialects/mysql/aiomysql.py", line 61, in __init__
    self._cursor = self.await_(cursor.__aenter__())
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 123, in await_only
    raise exc.MissingGreenlet(
sqlalchemy.exc.StatementError: (sqlalchemy.exc.MissingGreenlet) greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place?
[SQL: SELECT analysis.id AS analysis_id, analysis.type AS analysis_type, analysis.source AS analysis_source, analysis.sex AS analysis_sex, analysis.created_at AS analysis_created_at, analysis.sample_id AS analysis_sample_id, analysis.plate_id AS analysis_plate_id
FROM analysis
WHERE %s = analysis.sample_id]
[parameters: [{'%(XXXXXXXXXXX param)s': 'XXXXXX'}]]
(Background on this error at: https://sqlalche.me/e/20/xd2s)

@ahdamin ahdamin closed this Dec 13, 2024
@ahdamin ahdamin reopened this Dec 13, 2024
@clingen-sthlm clingen-sthlm temporarily deployed to stage December 13, 2024 14:11 Inactive
@clingen-sthlm clingen-sthlm deployed to stage December 13, 2024 14:22 Active
@ahdamin ahdamin marked this pull request as ready for review December 13, 2024 14:48
@ahdamin ahdamin requested a review from a team as a code owner December 13, 2024 14:48
Copy link
Contributor

@ChrOertlin ChrOertlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fear we might run into more of these sissues. Given that the async implementation happened after summer and now that we are working again with it errors start happening. We should likely have a sit down and figure things out a bit more.

Why do you think the selectinload will solve the greenlet error indicated? Are there other things we need to consider here as well?

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

Successfully merging this pull request may close these issues.

4 participants