libAtoms / abcd

1 stars 4 forks source link

bug: delete-key not working #91

Closed stenczelt closed 2 years ago

stenczelt commented 4 years ago

the delete-key command is not working, or at least not clear why this is not

(base) root@4ffcaf769b06:/opt/pw_dev# abcd delete-key -q="C_max_force_component" C_max_force_component
['C_max_force_component']
('NAME', 'C_max_force_component')
Traceback (most recent call last):
  File "/opt/conda/bin/abcd", line 8, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.7/site-packages/abcd/frontends/commandline/parser.py", line 121, in main
    callback_func(**kwargs)
  File "/opt/conda/lib/python3.7/site-packages/abcd/frontends/commandline/decorators.py", line 59, in wrapper
    func(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/abcd/frontends/commandline/decorators.py", line 15, in wrapper
    func(*args, config=config, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/abcd/frontends/commandline/decorators.py", line 48, in wrapper
    func(*args, db=db, query=query, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/abcd/frontends/commandline/commands.py", line 205, in key_delete
    query += keys
TypeError: can only concatenate tuple (not "list") to tuple

The part of the code where this fails is clearly wrong to try adding a list to a tuple: https://github.com/libAtoms/abcd/blob/3265335d70c6838cadc03e5ce4335f653815893f/abcd/frontends/commandline/commands.py#L198-L212

gabor1 commented 4 years ago

Should -q be followed by an equals sign? I never use it that way just follow it with a space

-- Gábor

On 28 Mar 2020, at 15:45, Tamas Stenczel notifications@github.com wrote:

 the delete-key command is not working, or at least not clear why this is not

(base) root@4ffcaf769b06:/opt/pw_dev# abcd delete-key -q="C_max_force_component" C_max_force_component ['C_max_force_component'] ('NAME', 'C_max_force_component') Traceback (most recent call last): File "/opt/conda/bin/abcd", line 8, in sys.exit(main()) File "/opt/conda/lib/python3.7/site-packages/abcd/frontends/commandline/parser.py", line 121, in main callback_func(kwargs) File "/opt/conda/lib/python3.7/site-packages/abcd/frontends/commandline/decorators.py", line 59, in wrapper func(*args, *kwargs) File "/opt/conda/lib/python3.7/site-packages/abcd/frontends/commandline/decorators.py", line 15, in wrapper func(args, config=config, kwargs) File "/opt/conda/lib/python3.7/site-packages/abcd/frontends/commandline/decorators.py", line 48, in wrapper func(*args, db=db, query=query, **kwargs) File "/opt/conda/lib/python3.7/site-packages/abcd/frontends/commandline/commands.py", line 205, in key_delete query += keys TypeError: can only concatenate tuple (not "list") to tuple The part of the code where this fails is clearly wrong to try adding a list to a tuple: https://github.com/libAtoms/abcd/blob/3265335d70c6838cadc03e5ce4335f653815893f/abcd/frontends/commandline/commands.py#L198-L212

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

gabor1 commented 4 years ago

I just checked, and the = has nothing to do with it

gabor1 commented 4 years ago

I agree it's a bug - the query or the keys variable must have changed its type during development and this code path wasn't updated. presumably one can make a tuple out of a list and then concatenate? (it's a strange design choice to make the query a tuple. I normally use tuples when I want an immutable, and a list when it changes)

stenczelt commented 4 years ago

I agree withe that it's a strange design, we could look what is happening actually. I suggest this to be solved with a test being added as well.

gabor1 commented 4 years ago

Let's fix it there for now by just converting the list to a tuple

-- Gábor

On 28 Mar 2020, at 20:31, Tamas Stenczel notifications@github.com wrote:

 I agree withe that it's a strange design, we could look what is happening actually. I suggest this to be solved with a test being added as well.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.