NVIDIA / NVFlare

NVIDIA Federated Learning Application Runtime Environment
https://nvidia.github.io/NVFlare/
Apache License 2.0
627 stars 179 forks source link

Latest cryptography breaks poc prepare #2761

Closed parkeraddison closed 1 month ago

parkeraddison commented 2 months ago

Fixes #2760

Description

The latest release of cryptography @ 43.0.0 breaks some nvflare commands like nvflare poc prepare with the following error:

# pip install nvflare
# nvflare poc prepare
prepare poc at /tmp/nvflare/poc for 2 clients
provision at /tmp/nvflare/poc for 2 clients with /tmp/nvflare/poc/project.yml
Exception raised during provision.  Incomplete prod_n folder removed.
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/nvflare/lighter/spec.py", line 174, in provision
    b.build(project, ctx)
  File "/usr/local/lib/python3.10/site-packages/nvflare/lighter/impl/cert.py", line 137, in build
    self._build_write_cert_pair(server, "server", ctx)
  File "/usr/local/lib/python3.10/site-packages/nvflare/lighter/impl/cert.py", line 119, in _build_write_cert_pair
    pkcs12 = serialization.pkcs12.serialize_key_and_certificates(
AttributeError: module 'cryptography.hazmat.primitives.serialization' has no attribute 'pkcs12'

This PR modifies setup.cfg to specify a maximum version <43, the last working version of cryptography is 42.0.8 https://pypi.org/project/cryptography/#history.

Unsure which branches this change needs to be merged into so that the latest 2.4.1 release on PyPI is fixed.

Types of changes

parkeraddison commented 2 months ago

Hmm, it looks like #2721 #2746 were merged into main and 2.4.1_no_xgb respectively but a fresh install of pip install nvflare (version 2.4.1) still results in the above AttributeError.

YuanTingHsieh commented 2 months ago

@parkeraddison thanks so much for bring this up to us.

Yes, we are aware of this problem so that's those 2 PRs you see. We are looking to revert 2.4 branch to 2.4.1_no_xgb branch once our testing are done. And this fix will be in the coming 2.5 as well.

chesterxgchen commented 2 months ago

@IsaacYangSLA can you port this to 2.5.0 branch with Parker's changes

chesterxgchen commented 2 months ago

I still haven't revert 2.4.1 tlo no_xgb ? I thought we did a while back

IsaacYangSLA commented 2 months ago

@parkeraddison , thanks for the PR. Since #2721 resolved the issue, we think the error is now fixed. If it's OK with you, can you try 2.5.0rc4 (or main branch)? We will close this PR once you agree the problem is fixed.

parkeraddison commented 1 month ago

Thanks for tackling this, and thanks for being patient with my delay -- I've just finished moving across the world for grad school at ETH Zurich!

Tested with pip install nvflare (v2.4.2) and pip install nvflare==2.5.0rc4. Both now work and am able to successfully run nvflare poc prepare and nvflare poc start without facing any errors. Looks good to close :+1: