Skip to content

Commit e5cf74a

Browse files
authored
docstring fixes (#6507)
### 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. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Wenqi Li <wenqil@nvidia.com>
1 parent 4e0b179 commit e5cf74a

15 files changed

Lines changed: 40 additions & 41 deletions

File tree

monai/apps/auto3dseg/auto_runner.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class AutoRunner:
121121
runner = AutoRunner(work_dir=work_dir, input=input, algos=algos)
122122
runner.run()
123123
124-
- User can specify a a local folder with algorithms templates and run AutoRunner:
124+
- User can specify a local folder with algorithms templates and run AutoRunner:
125125
126126
.. code-block:: python
127127
@@ -414,23 +414,23 @@ def set_gpu_customization(
414414
parameters for each bundleAlgo based on gpus. Custom parameters are obtained through dummy
415415
training to simulate the actual model training process and hyperparameter optimization (HPO)
416416
experiments.
417-
gpu_customization_specs (optinal): the dictionary to enable users overwrite the HPO settings. user can
417+
gpu_customization_specs (optional): the dictionary to enable users overwrite the HPO settings. user can
418418
overwrite part of variables as follows or all of them. The structure is as follows.
419419
420420
.. code-block:: python
421421
422422
gpu_customization_specs = {
423-
'ALOG': {
423+
'ALGO': {
424424
'num_trials': 6,
425425
'range_num_images_per_batch': [1, 20],
426426
'range_num_sw_batch_size': [1, 20]
427427
}
428428
}
429429
430-
ALGO: the name of algorithm. It could be one of algorithm names (e.g., 'dints') or 'unversal' which
430+
ALGO: the name of algorithm. It could be one of algorithm names (e.g., 'dints') or 'universal' which
431431
would apply changes to all algorithms. Possible options are
432432
433-
- {``"unversal"``, ``"dints"``, ``"segresnet"``, ``"segresnet2d"``, ``"swinunetr"``}.
433+
- {``"universal"``, ``"dints"``, ``"segresnet"``, ``"segresnet2d"``, ``"swinunetr"``}.
434434
435435
num_trials: the number of HPO trials/experiments to run.
436436
range_num_images_per_batch: the range of number of images per mini-batch.
@@ -468,7 +468,7 @@ def set_training_params(self, params: dict[str, Any] | None = None) -> None:
468468
self.train_params = deepcopy(params) if params is not None else {}
469469
if "CUDA_VISIBLE_DEVICES" in self.train_params:
470470
warnings.warn(
471-
"CUDA_VISIBLE_DEVICES is deprecated from 'set_training_params'. Use 'set_device_info' intead.",
471+
"CUDA_VISIBLE_DEVICES is deprecated from 'set_training_params'. Use 'set_device_info' instead.",
472472
DeprecationWarning,
473473
)
474474

@@ -483,7 +483,7 @@ def set_device_info(
483483
Set the device related info
484484
485485
Args:
486-
cuda_visible_device: define GPU ids for data analyzer, training, and ensembling.
486+
cuda_visible_devices: define GPU ids for data analyzer, training, and ensembling.
487487
List of GPU ids [0,1,2,3] or a string "0,1,2,3".
488488
Default using env "CUDA_VISIBLE_DEVICES" or all devices available.
489489
num_nodes: number of nodes for training and ensembling.
@@ -497,7 +497,7 @@ def set_device_info(
497497
- single node multi-GPU running "torchrun --nnodes=1 --nproc_per_node=2 "
498498
499499
If user define this prefix, please make sure --nproc_per_node matches cuda_visible_device or
500-
os.env['CUDA_VISIBLE_DEVICES]. Also always set --nnodes=1. Set num_nodes for multi-node.
500+
os.env['CUDA_VISIBLE_DEVICES']. Also always set --nnodes=1. Set num_nodes for multi-node.
501501
"""
502502
self.device_setting: dict[str, Any] = {}
503503
if cuda_visible_devices is None:
@@ -527,14 +527,14 @@ def set_device_info(
527527
self.device_setting["CMD_PREFIX"] = cmd_prefix
528528

529529
if cmd_prefix is not None:
530-
logger.info(f"Using user defined command running prefix {cmd_prefix}, will overide other settings")
530+
logger.info(f"Using user defined command running prefix {cmd_prefix}, will override other settings")
531531

532532
def set_ensemble_method(self, ensemble_method_name: str = "AlgoEnsembleBestByFold", **kwargs: Any) -> None:
533533
"""
534534
Set the bundle ensemble method name and parameters for save image transform parameters.
535535
536536
Args:
537-
params: the name of the ensemble method. Only two methods are supported "AlgoEnsembleBestN"
537+
ensemble_method_name: the name of the ensemble method. Only two methods are supported "AlgoEnsembleBestN"
538538
and "AlgoEnsembleBestByFold".
539539
kwargs: the keyword arguments used to define the ensemble method. Currently only ``n_best`` for
540540
``AlgoEnsembleBestN`` is supported.

monai/apps/auto3dseg/bundle_gen.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ def train(
254254
255255
Args:
256256
train_params: training parameters
257-
device_settings: device related settings, should follow the device_setting in auto_runner.set_device_info.
258-
'CUDA_VISIBLE_DEVICES' should be a string e.g. '0,1,2,3'
257+
device_setting: device related settings, should follow the device_setting in auto_runner.set_device_info.
258+
'CUDA_VISIBLE_DEVICES' should be a string e.g. '0,1,2,3'
259259
"""
260260
if device_setting is not None:
261261
self.device_setting.update(device_setting)
@@ -545,17 +545,17 @@ def generate(
545545
.. code-block:: python
546546
547547
gpu_customization_specs = {
548-
'ALOG': {
548+
'ALGO': {
549549
'num_trials': 6,
550550
'range_num_images_per_batch': [1, 20],
551551
'range_num_sw_batch_size': [1, 20]
552552
}
553553
}
554554
555-
ALGO: the name of algorithm. It could be one of algorithm names (e.g., 'dints') or 'unversal' which
555+
ALGO: the name of algorithm. It could be one of algorithm names (e.g., 'dints') or 'universal' which
556556
would apply changes to all algorithms. Possible options are
557557
558-
- {``"unversal"``, ``"dints"``, ``"segresnet"``, ``"segresnet2d"``, ``"swinunetr"``}.
558+
- {``"universal"``, ``"dints"``, ``"segresnet"``, ``"segresnet2d"``, ``"swinunetr"``}.
559559
560560
num_trials: the number of HPO trials/experiments to run.
561561
range_num_images_per_batch: the range of number of images per mini-batch.

monai/apps/auto3dseg/ensemble_builder.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def set_infer_files(self, dataroot: str, data_list_or_path: str | list, data_key
8484
8585
Args:
8686
dataroot: the path of the files
87-
data_src_cfg_file: the data source file path
87+
data_list_or_path: the data source file path
8888
"""
8989

9090
self.infer_files = []
@@ -405,7 +405,7 @@ class EnsembleRunner:
405405
work_dir: working directory to save the intermediate and final results. Default is `./work_dir`.
406406
num_fold: number of fold. Default is 5.
407407
ensemble_method_name: method to ensemble predictions from different model. Default is AlgoEnsembleBestByFold.
408-
Suported methods: ["AlgoEnsembleBestN", "AlgoEnsembleBestByFold"].
408+
Supported methods: ["AlgoEnsembleBestN", "AlgoEnsembleBestByFold"].
409409
mgpu: if using multi-gpu. Default is True.
410410
kwargs: additional image writing, ensembling parameters and prediction parameters for the ensemble inference.
411411
- for image saving, please check the supported parameters in SaveImage transform.
@@ -606,9 +606,8 @@ def run(self, device_setting: dict | None = None) -> None:
606606
algo_config.yaml file, which is pre-filled by the fill_template_config function in the same instance.
607607
608608
Args:
609-
train_params: training parameters
610-
device_settings: device related settings, should follow the device_setting in auto_runner.set_device_info.
611-
'CUDA_VISIBLE_DEVICES' should be a string e.g. '0,1,2,3'
609+
device_setting: device related settings, should follow the device_setting in auto_runner.set_device_info.
610+
'CUDA_VISIBLE_DEVICES' should be a string e.g. '0,1,2,3'
612611
"""
613612
# device_setting set default value and sanity check, in case device_setting not from autorunner
614613
if device_setting is not None:

monai/apps/auto3dseg/hpo_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def __call__(
324324
self, trial: Any, obj_filename: str, output_folder: str = ".", template_path: PathLike | None = None
325325
) -> Any:
326326
"""
327-
Callabe that Optuna will use to optimize the hyper-parameters
327+
Callable that Optuna will use to optimize the hyper-parameters
328328
329329
Args:
330330
obj_filename: the pickle-exported Algo object.

monai/auto3dseg/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def algo_from_pickle(pkl_filename: str, template_path: PathLike | None = None, *
312312
313313
Raises:
314314
ValueError if the pkl_filename does not contain a dict, or the dict does not contain `algo_bytes`.
315-
ModuleNotFoundError if it is unable to instiante the Algo class.
315+
ModuleNotFoundError if it is unable to instantiate the Algo class.
316316
317317
"""
318318
with open(pkl_filename, "rb") as f_pi:

monai/bundle/scripts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ def run(
648648
if other string, treat it as file path to load the tracking settings.
649649
if `dict`, treat it as tracking settings.
650650
will patch the target config content with `tracking handlers` and the top-level items of `configs`.
651-
for detailed usage examples, plesae check the tutorial:
651+
for detailed usage examples, please check the tutorial:
652652
https://github.com/Project-MONAI/tutorials/blob/main/experiment_management/bundle_integrate_mlflow.ipynb.
653653
args_file: a JSON or YAML file to provide default values for `runner_id`, `meta_file`,
654654
`config_file`, `logging`, and override pairs. so that the command line inputs can be simplified.
@@ -699,7 +699,7 @@ def run(
699699
def run_workflow(workflow: str | BundleWorkflow | None = None, args_file: str | None = None, **kwargs: Any) -> None:
700700
"""
701701
Specify `bundle workflow` to run monai bundle components and workflows.
702-
The workflow should be suclass of `BundleWorkflow` and be available to import.
702+
The workflow should be subclass of `BundleWorkflow` and be available to import.
703703
It can be MONAI existing bundle workflows or user customized workflows.
704704
705705
Typical usage examples:

monai/bundle/workflows.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ def get_workflow_type(self):
132132

133133
def add_property(self, name: str, required: str, desc: str | None = None) -> None:
134134
"""
135-
Besides the default predefined properties, some 3rd party aplications may need the bundle
136-
definition to provide additonal properties for the specific use cases, if the bundlle can't
135+
Besides the default predefined properties, some 3rd party applications may need the bundle
136+
definition to provide additional properties for the specific use cases, if the bundle can't
137137
provide the property, means it can't work with the application.
138138
This utility adds the property for the application requirements check and access.
139139
@@ -183,7 +183,7 @@ class ConfigWorkflow(BundleWorkflow):
183183
if other string, treat it as file path to load the tracking settings.
184184
if `dict`, treat it as tracking settings.
185185
will patch the target config content with `tracking handlers` and the top-level items of `configs`.
186-
for detailed usage examples, plesae check the tutorial:
186+
for detailed usage examples, please check the tutorial:
187187
https://github.com/Project-MONAI/tutorials/blob/main/experiment_management/bundle_integrate_mlflow.ipynb.
188188
workflow: specifies the workflow type: "train" or "training" for a training workflow,
189189
or "infer", "inference", "eval", "evaluation" for a inference workflow,
@@ -271,8 +271,8 @@ def finalize(self) -> Any:
271271
def check_properties(self) -> list[str] | None:
272272
"""
273273
Check whether the required properties are existing in the bundle workflow.
274-
If the optional properties have reference in the config, will also check whether the properties are exising.
275-
If no workflow type specified, return None, otherwise, return a list of required but missing properites.
274+
If the optional properties have reference in the config, will also check whether the properties are existing.
275+
If no workflow type specified, return None, otherwise, return a list of required but missing properties.
276276
277277
"""
278278
ret = super().check_properties()
@@ -339,8 +339,8 @@ def add_property( # type: ignore[override]
339339
self, name: str, required: str, config_id: str, desc: str | None = None
340340
) -> None:
341341
"""
342-
Besides the default predefined properties, some 3rd party aplications may need the bundle
343-
definition to provide additonal properties for the specific use cases, if the bundlle can't
342+
Besides the default predefined properties, some 3rd party applications may need the bundle
343+
definition to provide additional properties for the specific use cases, if the bundle can't
344344
provide the property, means it can't work with the application.
345345
This utility adds the property for the application requirements check and access.
346346

monai/networks/blocks/text_embedding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(
4646
) -> None:
4747
"""
4848
Args:
49-
out_channels: number of output channels, to control text-baesd embedding for classes.
49+
out_channels: number of output channels, to control text-based embedding for classes.
5050
spatial_dims: number of spatial dims.
5151
text_dim: dimension of text embeddings.
5252
hidden_size: dimension of hidden features, compatible to different vision feature dimensions.

monai/networks/nets/swin_unetr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ def __init__(
946946
downsample: module used for downsampling, available options are `"mergingv2"`, `"merging"` and a
947947
user-specified `nn.Module` following the API defined in :py:class:`monai.networks.nets.PatchMerging`.
948948
The default is currently `"merging"` (the original version defined in v0.9.0).
949-
use_v2: using swinunetr_v2, which adds a residual convolution block at the beggining of each swin stage.
949+
use_v2: using swinunetr_v2, which adds a residual convolution block at the beginning of each swin stage.
950950
"""
951951

952952
super().__init__()

monai/networks/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ def convert_to_onnx(
697697
for r1, r2 in zip(torch_out, onnx_out):
698698
if isinstance(r1, torch.Tensor):
699699
assert_fn = torch.testing.assert_close if pytorch_after(1, 11) else torch.testing.assert_allclose
700-
assert_fn(r1.cpu(), convert_to_tensor(r2, track_meta=False), rtol=rtol, atol=atol) # type: ignore
700+
assert_fn(r1.cpu(), convert_to_tensor(r2, dtype=r1.dtype), rtol=rtol, atol=atol) # type: ignore
701701

702702
return onnx_model
703703

0 commit comments

Comments
 (0)