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

Warning for query with wrong order (e.g. -q "0.01>E_CC_MP2_2B") #54

Open
eszter137 opened this issue Jul 17, 2019 · 6 comments
Open

Warning for query with wrong order (e.g. -q "0.01>E_CC_MP2_2B") #54

eszter137 opened this issue Jul 17, 2019 · 6 comments

Comments

@eszter137
Copy link

eszter137 commented Jul 17, 2019

The problem is with the ordering of the relation in the above query; -q "E_CC_MP2_2B<0.01" would work.
Current error message:

Traceback (most recent call last):
  File "/Users/es732/anaconda3/bin/abcd", line 10, in <module>
    sys.exit(main())
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/abcd/frontends/cli/parser.py", line 101, in main
    return callback_func(**kwargs)
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/abcd/frontends/cli/decorators.py", line 32, in wrapper
    func(*args, config=config, **kwargs)
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/abcd/frontends/cli/decorators.py", line 52, in wrapper
    func(*args, db=db, query=q, **kwargs)
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/abcd/frontends/cli/decorators.py", line 23, in wrapper
    func(*args, style=style, **kwargs)
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/abcd/frontends/cli/commands.py", line 174, in summary
    data = db.hist('arrays.' + p, query=query, bins=bins, truncate=truncate)
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/abcd/backends/atoms_mongoengine.py", line 628, in hist
    data = self.property(name, query)
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/abcd/backends/atoms_mongoengine.py", line 485, in property
    return [val['data'] for val in AtomsModel.objects.query(query).aggregate(*pipeline)]
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/mongoengine/queryset/base.py", line 1212, in aggregate
    return self._collection.aggregate(pipeline, cursor={}, **kwargs)
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/pymongo/collection.py", line 2411, in aggregate
    **kwargs)
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/pymongo/collection.py", line 2318, in _aggregate
    user_fields={'cursor': {'firstBatch': 1}})
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/pymongo/pool.py", line 584, in command
    user_fields=user_fields)
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/pymongo/network.py", line 158, in command
    parse_write_concern_error=parse_write_concern_error)
  File "/Users/es732/anaconda3/lib/python3.7/site-packages/pymongo/helpers.py", line 155, in _check_command_response
    raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: $or/$and/$nor entries need to be full objects```
@gabor1 gabor1 added the bug Something isn't working label Jul 17, 2019
@fekad
Copy link
Contributor

fekad commented Jul 18, 2019

@gabor1 Do you want to support when you have "{value}{operator}{key}" or you want to catch the error? We would have a more complex parser for recognising what "0.01>E_CC_MP2_2B" means at all?

@gabor1
Copy link
Contributor

gabor1 commented Jul 18, 2019

well binary operators like that work both ways in any programming language, so it would be strange not to support that, no?

@fekad
Copy link
Contributor

fekad commented Jul 18, 2019

No, it is more like a filter where you have syntax like: {labels} {operators} {values}. Like in a dictionary you have a specific structure (keys and values) and you cannot switch the order. I mean in special cases you can but that will be a completly different object.

In the case of the programing language, it is easier because you can evaluate the whole expression.

Here have to figure out which one is the label: "0.01" or "E_CC_MP2_2B":

atoms.info["0.01"] > "E_CC_MP2_2B"

vs

atoms.info["E_CC_MP2_2B"] < 0.01

@gabor1
Copy link
Contributor

gabor1 commented Jul 18, 2019

fine. we'll call it an enhancement and so push it down the priority list ;-)

@gabor1 gabor1 added enhancement New feature or request and removed bug Something isn't working labels Jul 18, 2019
@fekad
Copy link
Contributor

fekad commented Jul 18, 2019

To implement this issue there could cause a big performance decrease because we have to handle all labels in the query as a regex. I would estimate feature needs more than 2 weeks to implement it properly.

@gabor1
Copy link
Contributor

gabor1 commented Jul 19, 2019

This was discussed, and we decided that once strings values are indicated with quotes, it should be no problem to have either order around a binary operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants