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

KeyError upon running example #3

Open
simenkva opened this issue Nov 16, 2023 · 1 comment
Open

KeyError upon running example #3

simenkva opened this issue Nov 16, 2023 · 1 comment

Comments

@simenkva
Copy link
Contributor

I got a KeyError when running a simple example, based on examples provided within this repos:

pythonschool ❯ pyscf --dry-run pyscf_config.yaml
import numpy as np
import pyscf
results = {}
klass = Mole
Traceback (most recent call last):
  File "/Users/simenkva/anaconda3/envs/pythonschool/bin/pyscf", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/simenkva/anaconda3/envs/pythonschool/lib/python3.11/site-packages/pyscfcli/cli.py", line 454, in main
    result = task.result()
             ^^^^^^^^^^^^^
  File "/Users/simenkva/anaconda3/envs/pythonschool/lib/python3.11/site-packages/pyscfcli/cli.py", line 435, in result
    self.run()
  File "/Users/simenkva/anaconda3/envs/pythonschool/lib/python3.11/site-packages/pyscfcli/cli.py", line 422, in run
    ctx = handlers[klass](token, ctx)
          ~~~~~~~~^^^^^^^
KeyError: 'Mole'

I found that handlers is a dict with uppercase keys, but klass is not uppercase. The fix was to use handlers[klass.upper()](token, ctx), and now the program seems to work.

If this is the complete solution, I could fix it and submit a pull request...

@sunqm
Copy link
Contributor

sunqm commented Nov 16, 2023

Yes, the klass should be an uppercase name to match the names in the dict

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

2 participants