OneZoom / tree-build

Scripts for assembling the tree, metadata and downstream data products such as popularity and popular images
MIT License
1 stars 2 forks source link

Cryptography error when running process_image_bits with pydal #80

Closed davidebbo closed 2 months ago

davidebbo commented 3 months ago

Installing the cryptography package fixes it, but it's interesting that @hyanwong is not seeing this.

Repro: run process_image_bits 763016

Result:

Traceback (most recent call last):
  File "/home/david/www-dev/web2py/applications/tree-build/.venv/bin/process_image_bits", line 33, in <module>
    sys.exit(load_entry_point('oz-tree-build', 'console_scripts', 'process_image_bits')())
  File "/home/david/www-dev/web2py/applications/tree-build/oz_tree_build/images_and_vernaculars/process_image_bits.py", line 149, in main
    process_args(parser.parse_args())
  File "/home/david/www-dev/web2py/applications/tree-build/oz_tree_build/images_and_vernaculars/process_image_bits.py", line 132, in process_args
    return resolve_from_config(args.ott, args.conf_file)
  File "/home/david/www-dev/web2py/applications/tree-build/oz_tree_build/images_and_vernaculars/process_image_bits.py", line 38, in resolve_from_config
    return resolve(db, ott)
  File "/home/david/www-dev/web2py/applications/tree-build/oz_tree_build/images_and_vernaculars/process_image_bits.py", line 58, in resolve
    rows = db.executesql(
  File "/home/david/www-dev/web2py/applications/tree-build/.venv/lib/python3.10/site-packages/pydal/base.py", line 900, in executesql
    adapter.execute(query, placeholders)
  File "/home/david/www-dev/web2py/applications/tree-build/.venv/lib/python3.10/site-packages/pydal/adapters/__init__.py", line 66, in wrap
    if not args[0].connection:
  File "/home/david/www-dev/web2py/applications/tree-build/.venv/lib/python3.10/site-packages/pydal/connection.py", line 33, in connection
    return self.get_connection()
  File "/home/david/www-dev/web2py/applications/tree-build/.venv/lib/python3.10/site-packages/pydal/connection.py", line 66, in get_connection
    connection = self.connector()
  File "/home/david/www-dev/web2py/applications/tree-build/.venv/lib/python3.10/site-packages/pydal/adapters/mysql.py", line 65, in connector
    conn = self.driver.connect(**self.driver_args)
  File "/home/david/www-dev/web2py/applications/tree-build/.venv/lib/python3.10/site-packages/pymysql/connections.py", line 358, in __init__
    self.connect()
  File "/home/david/www-dev/web2py/applications/tree-build/.venv/lib/python3.10/site-packages/pymysql/connections.py", line 664, in connect
    self._request_authentication()
  File "/home/david/www-dev/web2py/applications/tree-build/.venv/lib/python3.10/site-packages/pymysql/connections.py", line 976, in _request_authentication
    auth_packet = _auth.caching_sha2_password_auth(self, auth_packet)
  File "/home/david/www-dev/web2py/applications/tree-build/.venv/lib/python3.10/site-packages/pymysql/_auth.py", line 266, in caching_sha2_password_auth
    data = sha2_rsa_encrypt(conn.password, conn.salt, conn.server_public_key)
  File "/home/david/www-dev/web2py/applications/tree-build/.venv/lib/python3.10/site-packages/pymysql/_auth.py", line 143, in sha2_rsa_encrypt
    raise RuntimeError(
RuntimeError: 'cryptography' package is required for sha256_password or caching_sha2_password auth methods
hyanwong commented 3 months ago

It could be that I have the package installed in that venv already. Odd that pydal doesn't list it as a requirement, though (if it is from there: it looks from the above as if it's coming from pymysql.

Either way, easy enough to add to setup.cfg, I guess?

davidebbo commented 3 months ago

Interesting finding:

davidebbo commented 3 months ago

It could be that I have the package installed in that venv already

You can check what's in your .env\lib\python3.10\site-packages

davidebbo commented 3 months ago

And course, we can just add it, but it's nice to understand why we saw something different if possible.

hyanwong commented 3 months ago

Weird. Maybe worth adding anyway?

hyanwong commented 3 months ago

Looks like my .venv wasn't set up right, and was using my "normal" python, which definitely has it. So that explains why I don't see the message.

Here's an SO answer. Seems like it's an optional dependency of pymysql:

https://stackoverflow.com/questions/54477829/cryptography-is-required-for-sha256-password-or-caching-sha2-password

davidebbo commented 3 months ago

Ok, that explains it. So we should just add the dependency.

hyanwong commented 2 months ago

Fixed in 9db169e9eaea59c94573929c31cd75659216f8f4