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

get_annotation_count throws error for reference tables #133

Open
schlegelp opened this issue Nov 22, 2023 · 0 comments
Open

get_annotation_count throws error for reference tables #133

schlegelp opened this issue Nov 22, 2023 · 0 comments

Comments

@schlegelp
Copy link

Hi!

I ran into this error when trying to get the annotation count for a reference table:

>>> client = CAVEclient('flywire_fafb_production')
>>> client.annotation.get_annotation_count('fly_synapses_neuropil_v5')
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
Cell In[133], line 1
----> 1 client.annotation.get_annotation_count('fly_synapses_neuropil_v5')

File ~/.pyenv/versions/3.9.9/lib/python3.9/site-packages/caveclient/annotationengine.py:190, in AnnotationClientV2.get_annotation_count(self, table_name, aligned_volume_name)
    187 url = self._endpoints["table_count"].format_map(endpoint_mapping)
    189 response = self.session.get(url)
--> 190 return handle_response(response)

File ~/.pyenv/versions/3.9.9/lib/python3.9/site-packages/caveclient/base.py:88, in handle_response(response, as_json, log_warning)
     86 def handle_response(response, as_json=True, log_warning=True):
     87     """Deal with potential errors in endpoint response and return json for default case"""
---> 88     _raise_for_status(response, log_warning=log_warning)
     89     _check_authorization_redirect(response)
     90     if as_json:

File ~/.pyenv/versions/3.9.9/lib/python3.9/site-packages/caveclient/base.py:79, in _raise_for_status(r, log_warning)
     71     http_error_msg = "%s Server Error: %s for url: %s content:%s" % (
     72         r.status_code,
     73         reason,
     74         r.url,
     75         r.content,
     76     )
     78 if http_error_msg:
---> 79     raise requests.HTTPError(http_error_msg, response=r)
     80 if log_warning:
     81     warning = r.headers.get("Warning")

HTTPError: 500 Server Error: Foreign key associated with column 'fly_synapses_neuropil_v5.target_id' could not find table 'synapses_nt_v1' with which to generate a foreign key to target column 'id' for url: https://prod.flywire-daf.com/annotation/api/v2/aligned_volume/fafb_seung_alignment_v0/table/fly_synapses_neuropil_v5/count content:b'{"code": 500, "message": "Foreign key associated with column \'fly_synapses_neuropil_v5.target_id\' could not find table \'synapses_nt_v1\' with which to generate a foreign key to target column \'id\'", "traceback": ["Traceback (most recent call last):\\n", "  File \\"/usr/local/lib/python3.9/site-packages/flask/app.py\\", line 1950, in full_dispatch_request\\n    rv = self.dispatch_request()\\n", "  File \\"/usr/local/lib/python3.9/site-packages/flask/app.py\\", line 1936, in dispatch_request\\n    return self.view_functions[rule.endpoint](**req.view_args)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/flask_restx/api.py\\", line 403, in wrapper\\n    resp = resource(*args, **kwargs)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/flask/views.py\\", line 89, in view\\n    return self.dispatch_request(*args, **kwargs)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/flask_restx/resource.py\\", line 49, in dispatch_request\\n    resp = meth(*args, **kwargs)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/middle_auth_client/decorators.py\\", line 265, in decorated_function\\n    return f(*args, **kwargs)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/middle_auth_client/decorators.py\\", line 397, in decorated_function\\n    return f(*args, **kwargs)\\n", "  File \\"/app/./annotationengine/api.py\\", line 282, in get\\n    return db.database.get_annotation_table_size(table_name), 200\\n", "  File \\"/usr/local/lib/python3.9/site-packages/dynamicannotationdb/database.py\\", line 165, in get_annotation_table_size\\n    return session.query(Model).count()\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py\\", line 3803, in count\\n    return self.from_self(col).scalar()\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py\\", line 3523, in scalar\\n    ret = self.one()\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py\\", line 3490, in one\\n    ret = self.one_or_none()\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py\\", line 3459, in one_or_none\\n    ret = list(self)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py\\", line 3531, in __iter__\\n    context = self._compile_context()\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py\\", line 4085, in _compile_context\\n    entity.setup_context(self, context)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py\\", line 4853, in setup_context\\n    column = query._adapt_clause(self.column, False, True)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py\\", line 394, in _adapt_clause\\n    return visitors.replacement_traverse(clause, {}, replace)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/visitors.py\\", line 484, in replacement_traverse\\n    obj = clone(obj, **opts)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/visitors.py\\", line 473, in clone\\n    newelem = replace(elem)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py\\", line 390, in replace\\n    e = adapter(elem)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/util.py\\", line 848, in replace\\n    return self._corresponding_column(col, True)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/util.py\\", line 820, in _corresponding_column\\n    newcol = self.selectable.corresponding_column(\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/selectable.py\\", line 560, in corresponding_column\\n    if self.c.contains_column(column):\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py\\", line 893, in __get__\\n    obj.__dict__[self.__name__] = result = self.fget(obj)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/selectable.py\\", line 647, in columns\\n    self._populate_column_collection()\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/selectable.py\\", line 1395, in _populate_column_collection\\n    for col in self.element.columns._all_columns:\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py\\", line 893, in __get__\\n    obj.__dict__[self.__name__] = result = self.fget(obj)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/selectable.py\\", line 647, in columns\\n    self._populate_column_collection()\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/selectable.py\\", line 3906, in _populate_column_collection\\n    c._make_proxy(self, key=key, name=name, name_is_truncatable=True)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/schema.py\\", line 1791, in _make_proxy\\n    fk = [\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/schema.py\\", line 1792, in <listcomp>\\n    ForeignKey(f.column, _constraint=f.constraint)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py\\", line 893, in __get__\\n    obj.__dict__[self.__name__] = result = self.fget(obj)\\n", "  File \\"/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/schema.py\\", line 2247, in column\\n    raise exc.NoReferencedTableError(\\n", "sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column \'fly_synapses_neuropil_v5.target_id\' could not find table \'synapses_nt_v1\' with which to generate a foreign key to target column \'id\'\\n"]}\n'

This is with caveclient 5.13.0

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