Skip to content

Commit bc8af47

Browse files
authored
[2.6] Add rank type check for client API (#3524)
Fixes # . ### Description Adding #3523 ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Quick tests passed locally by running `./runtest.sh`. - [ ] In-line docstrings updated. - [ ] Documentation updated.
1 parent 675b463 commit bc8af47

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

examples/advanced/bionemo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ In this repo you will find two notebooks under the `task_fitting` and `downstrea
1616
Download and run the [BioNeMo docker container](https://catalog.ngc.nvidia.com/orgs/nvidia/teams/clara/containers/bionemo-framework).
1717
> **Note:** The examples here were tested with `nvcr.io/nvidia/clara/bionemo-framework:2.5`
1818
19-
We recommend following the [User Guide](https://docs.nvidia.com/bionemo-framework/latest/user-guide/)
19+
We recommend following the [User Guide](https://docs.nvidia.com/bionemo-framework)
2020
on how to get started with BioNeMo 2.
2121

2222
Start the container and Jupyter Lab to run the NVFlare experiments with NVFlare using

nvflare/client/api.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import logging
1616
from threading import Lock
17-
from typing import Any, Dict, Optional
17+
from typing import Any, Dict, Optional, Union
1818

1919
from nvflare.apis.analytix import AnalyticsDataType
2020
from nvflare.app_common.abstract.fl_model import FLModel
@@ -49,7 +49,7 @@ def get_context(ctx: Optional[APIContext] = None) -> APIContext:
4949
raise RuntimeError("APIContext is None")
5050

5151

52-
def init(rank: Optional[str] = None, config_file: Optional[str] = None) -> APIContext:
52+
def init(rank: Optional[Union[str, int]] = None, config_file: Optional[str] = None) -> APIContext:
5353
"""Initializes NVFlare Client API environment.
5454
5555
Args:
@@ -60,6 +60,16 @@ def init(rank: Optional[str] = None, config_file: Optional[str] = None) -> APICo
6060
Returns:
6161
APIContext
6262
"""
63+
64+
# subsequent logic assumes rank is a string
65+
if rank is not None:
66+
if isinstance(rank, int):
67+
rank = str(rank)
68+
elif isinstance(rank, str):
69+
pass
70+
else:
71+
raise ValueError(f"rank must be a string or an integer but got {type(rank)}")
72+
6373
with global_context_lock:
6474
global context_dict
6575
global default_context

0 commit comments

Comments
 (0)