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

Hide underscore fields from suggested query fields #2419

Open
Zethson opened this issue Feb 3, 2025 · 0 comments
Open

Hide underscore fields from suggested query fields #2419

Zethson opened this issue Feb 3, 2025 · 0 comments
Assignees
Labels

Comments

@Zethson
Copy link
Member

Zethson commented Feb 3, 2025

Add a description

---------------------------------------------------------------------------
FieldError                                Traceback (most recent call last)
Cell In[20], line 5
      1 old_gene_symbols = ["MALAT1"]
      2 new_gene_symbols = ["TSPAN6"]
----> 5 old_fs = ln.FeatureSet.filter(gene__name__in=old_gene_symbols).all()
      7 new_gene = bt.Gene.filter(symbol__in=new_gene_symbols).all()
      8 for fs in old_fs:

File ~/code/lamindb/lamindb/_record.py:332, in filter(cls, *queries, **expressions)
    329 if "_using_key" in expressions:
    330     _using_key = expressions.pop("_using_key")
--> 332 return QuerySet(model=cls, using=_using_key).filter(*queries, **expressions)

File ~/code/lamindb/lamindb/_query_set.py:612, in QuerySet.filter(self, *queries, **expressions)
    610 expressions = process_expressions(self, expressions)
    611 if len(expressions) > 0:
--> 612     return super().filter(*queries, **expressions)
    613 else:
    614     return self

File ~/miniforge3/envs/lamindb/lib/python3.12/site-packages/django/db/models/query.py:1476, in QuerySet.filter(self, *args, **kwargs)
   1471 """
   1472 Return a new QuerySet instance with the args ANDed to the existing
   1473 set.
   1474 """
   1475 self._not_support_combined_queries("filter")
-> 1476 return self._filter_or_exclude(False, args, kwargs)

File ~/miniforge3/envs/lamindb/lib/python3.12/site-packages/django/db/models/query.py:1494, in QuerySet._filter_or_exclude(self, negate, args, kwargs)
   1492     clone._deferred_filter = negate, args, kwargs
   1493 else:
-> 1494     clone._filter_or_exclude_inplace(negate, args, kwargs)
   1495 return clone

File ~/miniforge3/envs/lamindb/lib/python3.12/site-packages/django/db/models/query.py:1501, in QuerySet._filter_or_exclude_inplace(self, negate, args, kwargs)
   1499     self._query.add_q(~Q(*args, **kwargs))
   1500 else:
-> 1501     self._query.add_q(Q(*args, **kwargs))

File ~/miniforge3/envs/lamindb/lib/python3.12/site-packages/django/db/models/sql/query.py:1609, in Query.add_q(self, q_object)
   1600 # For join promotion this case is doing an AND for the added q_object
   1601 # and existing conditions. So, any existing inner join forces the join
   1602 # type to remain inner. Existing outer joins can however be demoted.
   1603 # (Consider case where rel_a is LOUTER and rel_a__col=1 is added - if
   1604 # rel_a doesn't produce any rows, then the whole condition must fail.
   1605 # So, demotion is OK.
   1606 existing_inner = {
   1607     a for a in self.alias_map if self.alias_map[a].join_type == INNER
   1608 }
-> 1609 clause, _ = self._add_q(q_object, self.used_aliases)
   1610 if clause:
   1611     self.where.add(clause, AND)

File ~/miniforge3/envs/lamindb/lib/python3.12/site-packages/django/db/models/sql/query.py:1641, in Query._add_q(self, q_object, used_aliases, branch_negated, current_negated, allow_joins, split_subq, check_filterable, summarize, update_join_types)
   1637 joinpromoter = JoinPromoter(
   1638     q_object.connector, len(q_object.children), current_negated
   1639 )
   1640 for child in q_object.children:
-> 1641     child_clause, needed_inner = self.build_filter(
   1642         child,
   1643         can_reuse=used_aliases,
   1644         branch_negated=branch_negated,
   1645         current_negated=current_negated,
   1646         allow_joins=allow_joins,
   1647         split_subq=split_subq,
   1648         check_filterable=check_filterable,
   1649         summarize=summarize,
   1650         update_join_types=update_join_types,
   1651     )
   1652     joinpromoter.add_votes(needed_inner)
   1653     if child_clause:

File ~/miniforge3/envs/lamindb/lib/python3.12/site-packages/django/db/models/sql/query.py:1491, in Query.build_filter(self, filter_expr, branch_negated, current_negated, can_reuse, allow_joins, split_subq, check_filterable, summarize, update_join_types)
   1489 if not arg:
   1490     raise FieldError("Cannot parse keyword query %r" % arg)
-> 1491 lookups, parts, reffed_expression = self.solve_lookup_type(arg, summarize)
   1493 if check_filterable:
   1494     self.check_filterable(reffed_expression)

File ~/miniforge3/envs/lamindb/lib/python3.12/site-packages/django/db/models/sql/query.py:1303, in Query.solve_lookup_type(self, lookup, summarize)
   1301             expression = Ref(annotation, expression)
   1302         return expression_lookups, (), expression
-> 1303 _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
   1304 field_parts = lookup_splitted[0 : len(lookup_splitted) - len(lookup_parts)]
   1305 if len(lookup_parts) > 1 and not field_parts:

File ~/miniforge3/envs/lamindb/lib/python3.12/site-packages/django/db/models/sql/query.py:1768, in Query.names_to_path(self, names, opts, allow_many, fail_on_missing)
   1760     if pos == -1 or fail_on_missing:
   1761         available = sorted(
   1762             [
   1763                 *get_field_names_from_opts(opts),
   (...)
   1766             ]
   1767         )
-> 1768         raise FieldError(
   1769             "Cannot resolve keyword '%s' into field. "
   1770             "Choices are: %s" % (name, ", ".join(available))
   1771         )
   1772     break
   1773 # Check if we need any joins for concrete inheritance cases (the
   1774 # field lives in parent, but we are currently in one of its
   1775 # children)

FieldError: Cannot resolve keyword 'gene' into field. Choices are: _artifacts_m2m, _aux, _branch_code, _curation, _links_artifact, _tidytables, artifacts, cell_markers, components, composite, composite_id, created_at, created_by, created_by_id, description, dtype, features, genes, hash, id, is_type, itype, links_cellmarker, links_feature, links_gene, links_pathway, links_project, links_protein, maximal_set, minimal_set, n, name, ordered_set, otype, params, pathways, projects, proteins, records, run, run_id, slot, space, space_id, type, type_id, uid, validated_by, validated_by_id, validated_schemas

And maybe we should even hide most of the traceback while we're at it.

@Zethson Zethson added the 🚸 ux label Feb 3, 2025
@Zethson Zethson self-assigned this Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant