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

[BUG] .add_fold returns error #2421

Closed
blythed opened this issue Aug 30, 2024 · 0 comments
Closed

[BUG] .add_fold returns error #2421

blythed opened this issue Aug 30, 2024 · 0 comments
Labels
🐛 bug Something isn't working

Comments

@blythed
Copy link
Collaborator

blythed commented Aug 30, 2024

Code

db = superduper('mongomock://test_db')
q = db['docs'].select().add_fold('train')

Output

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[6], line 1
----> 1 db['docs'].select().add_fold('train')

File ~/superduper-io/superduper/superduper/backends/base/query.py:35, in applies_to.<locals>.decorator.<locals>.decorated(self, *args, **kwargs)
     33     raise TypeError(msg)
     34 assert flavour in flavours, msg
---> 35 return f(self, *args, **kwargs)

File ~/.pyenv/versions/3.11.7/envs/superduper-3.11/lib/python3.11/site-packages/superduper_mongodb/query.py:370, in MongoQuery.add_fold(self, fold)
    364 @applies_to('find', 'find_one', 'select', 'outputs')
    365 def add_fold(self, fold: str):
    366     """Return a query that adds a fold to the query.
    367
    368     :param fold: The fold to add.
    369     """
--> 370     return self.filter(self['_fold'] == fold)

File ~/.pyenv/versions/3.11.7/envs/superduper-3.11/lib/python3.11/site-packages/superduper_mongodb/query.py:255, in MongoQuery.filter(self, *args, **kwargs)
    253     continue
    254 if not isinstance(arg, Query):
--> 255     raise ValueError(f'Filter arguments must be queries, but got: {arg}')
    256 assert len(arg.parts) > 1, f'Invalid filter query: {arg}'
    257 key, (op, op_args, _) = arg.parts[-2:]

ValueError: Filter arguments must be queries, but got: False

In [7]: db['docs'].select() == 2
Out[7]: False

In [8]: db['docs'].select().add_fold('train')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[8], line 1
----> 1 db['docs'].select().add_fold('train')

File ~/superduper-io/superduper/superduper/backends/base/query.py:35, in applies_to.<locals>.decorator.<locals>.decorated(self, *args, **kwargs)
     33     raise TypeError(msg)
     34 assert flavour in flavours, msg
---> 35 return f(self, *args, **kwargs)

File ~/.pyenv/versions/3.11.7/envs/superduper-3.11/lib/python3.11/site-packages/superduper_mongodb/query.py:370, in MongoQuery.add_fold(self, fold)
    364 @applies_to('find', 'find_one', 'select', 'outputs')
    365 def add_fold(self, fold: str):
    366     """Return a query that adds a fold to the query.
    367
    368     :param fold: The fold to add.
    369     """
--> 370     return self.filter(self['_fold'] == fold)

File ~/.pyenv/versions/3.11.7/envs/superduper-3.11/lib/python3.11/site-packages/superduper_mongodb/query.py:255, in MongoQuery.filter(self, *args, **kwargs)
    253     continue
    254 if not isinstance(arg, Query):
--> 255     raise ValueError(f'Filter arguments must be queries, but got: {arg}')
    256 assert len(arg.parts) > 1, f'Invalid filter query: {arg}'
    257 key, (op, op_args, _) = arg.parts[-2:]

ValueError: Filter arguments must be queries, but got: False
@blythed blythed added the 🐛 bug Something isn't working label Aug 30, 2024
@blythed blythed closed this as completed Sep 6, 2024
@github-project-automation github-project-automation bot moved this from To Do to Done in superduper-open-source Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

1 participant