Skip to content

Commit

Permalink
Add support to newer python version (#2951)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanTingHsieh authored Sep 24, 2024
1 parent aa4a0de commit 56558c1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 27 deletions.
8 changes: 4 additions & 4 deletions .github/DISCUSSION_TEMPLATE/q-a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ body:
attributes:
label: Python version (`python3 -V`)
description: Python version (`python3 -V`)
placeholder: "3.8"
placeholder: "3.10"
validations:
required: true
- type: input
attributes:
label: NVFlare version (`python3 -m pip list | grep "nvflare"`)
description: NVFlare version (`python3 -m pip list | grep "nvflare"`)
placeholder: "2.3.8"
placeholder: "2.5.0"
validations:
required: true
- type: input
attributes:
label: NVFlare branch (if running examples, please use the branch that corresponds to the NVFlare version, `git branch`)
description: NVFlare branch (if running examples, please use the branch that corresponds to the NVFlare version, `git branch`)
placeholder: "2.3"
placeholder: "2.5"
- type: input
attributes:
label: Operating system
description: Operating system (Ubuntu, MacOS, Windows, etc)
placeholder: "Ubuntu 20.04"
placeholder: "Ubuntu 22.04"
validations:
required: true
- type: checkboxes
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. ubuntu 16.04]
- Python Version [e.g. 3.8]
- NVFlare Version [e.g. 2.1]
- OS: [e.g. ubuntu 22.04]
- Python Version [e.g. 3.10]
- NVFlare Version [e.g. 2.5]

**Additional context**
Add any other context about the problem here.
4 changes: 2 additions & 2 deletions .github/workflows/premerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-22.04, ubuntu-20.04 ]
python-version: [ "3.8", "3.9", "3.10" ]
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -47,7 +47,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-22.04, ubuntu-20.04 ]
python-version: [ "3.8", "3.9", "3.10" ]
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
10 changes: 2 additions & 8 deletions nvflare/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from nvflare.fuel.hci.tools.authz_preview import define_authz_preview_parser, run_command
from nvflare.lighter.provision import define_provision_parser, handle_provision
from nvflare.private.fed.app.simulator.simulator import define_simulator_parser, run_simulator
from nvflare.private.fed.app.utils import version_check
from nvflare.tool.job.job_cli import def_job_cli_parser, handle_job_cli_cmd
from nvflare.tool.poc.poc_commands import def_poc_parser, handle_poc_cmd
from nvflare.tool.preflight_check import check_packages, define_preflight_check_parser
Expand All @@ -45,13 +46,6 @@
CMD_CONFIG = "config"


def check_python_version():
if sys.version_info >= (3, 11):
raise RuntimeError("Python versions 3.11 and above are not yet supported. Please use Python 3.8, 3.9 or 3.10.")
if sys.version_info < (3, 8):
raise RuntimeError("Python versions 3.7 and below are not supported. Please use Python 3.8, 3.9 or 3.10")


def def_provision_parser(sub_cmd):
cmd = CMD_PROVISION
provision_parser = sub_cmd.add_parser(cmd)
Expand Down Expand Up @@ -218,7 +212,7 @@ def print_nvflare_version():


def main():
check_python_version()
version_check()
run("nvflare")


Expand Down
10 changes: 7 additions & 3 deletions nvflare/private/fed/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ def create_admin_server(fl_server: FederatedServer, server_conf=None, args=None,


def version_check():
if sys.version_info >= (3, 11):
raise RuntimeError("Python versions 3.11 and above are not yet supported. Please use Python 3.8, 3.9 or 3.10.")
if sys.version_info >= (3, 13):
raise RuntimeError(
"Python versions 3.13 and above are not yet supported. Please use Python version between 3.8 and 3.12."
)
if sys.version_info < (3, 8):
raise RuntimeError("Python versions 3.7 and below are not supported. Please use Python 3.8, 3.9 or 3.10")
raise RuntimeError(
"Python versions 3.7 and below are not supported. Please use Python version between 3.8 and 3.12."
)


def init_security_content_service(workspace_dir):
Expand Down
10 changes: 3 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ classifiers =
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux

Expand All @@ -24,7 +26,7 @@ install_requires =
SQLAlchemy==2.0.16
grpcio>=1.62.1
gunicorn>=22.0.0
numpy<=1.26.4
numpy
protobuf>=4.24.4
psutil>=5.9.1
PyYAML>=6.0
Expand All @@ -36,10 +38,6 @@ install_requires =
pyhocon

[options.extras_require]
HE =
tenseal==0.3.12
PSI =
openmined.psi==1.1.1
PT =
torch
torchvision
Expand All @@ -53,8 +51,6 @@ TRACKING =
CONFIG =
omegaconf
app_opt =
%(HE)s
%(PSI)s
%(PT)s
%(SKLEARN)s
%(TRACKING)s
Expand Down
4 changes: 4 additions & 0 deletions tests/unit_test/fuel/utils/component_builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def is_python_greater_than_309():
version_value = 309
elif version.startswith("3.10."):
version_value = 310
elif version.startswith("3.11."):
version_value = 311
elif version.startswith("3.12."):
version_value = 312
else:
raise ValueError("unknown version")
return version_value > 309
Expand Down

0 comments on commit 56558c1

Please sign in to comment.