Skip to content

simplify the configparser usage to get parsed attributes easily #5804

Description

@wyli

Is your feature request related to a problem? Please describe.

the current usage looks tedious (https://github.com/Project-MONAI/research-contributions/blob/07da7ad36a0b218556a427f3bc5292a772c30f60/auto3dseg/algorithm_templates/segresnet2d/scripts/infer.py#L34-L50)

parser = ConfigParser()
parser.read_config(config_file_)
parser.update(pairs=_args)

data_file_base_dir = parser.get_parsed_content("data_file_base_dir")
data_list_file_path = parser.get_parsed_content("data_list_file_path")
self.fast = parser.get_parsed_content("infer")["fast"]
self.num_adjacent_slices = parser.get_parsed_content("num_adjacent_slices")
self.num_sw_batch_size = parser.get_parsed_content("num_sw_batch_size")
self.output_classes = parser.get_parsed_content("output_classes")
self.overlap_ratio = parser.get_parsed_content("overlap_ratio")
self.patch_size_valid = parser.get_parsed_content("patch_size_valid")
softmax = parser.get_parsed_content("softmax")

ckpt_name = parser.get_parsed_content("infer")["ckpt_name"]
data_list_key = parser.get_parsed_content("infer")["data_list_key"]
output_path = parser.get_parsed_content("infer")["ouptut_path"]

this is a feature request of simplifying the APIs to support more user-friendly calls
to get the parsed config as attributes directly:

cfg = ConfigParser()
cfg.read_config(config_file_)
cfg.update(pairs=_args)

data_file_base_dir = cfg.data_file_base_dir
data_list_file_path = cfg.data_list_file_path
self.fast = cfg.infer.fast
...

cc @Project-MONAI/core-reviewers

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions