Repository: Project-MONAI/MONAI
File: monai/bundle/workflows.py (Python)

Code before:
        else:
            super().__setattr__(name, value)  # setting regular attribute

    def get_workflow_type(self):
        """
        Get the workflow type, it can be `None`, "train", or "infer".

        """
        return self.workflow

    def add_property(self, name: str, required: str, desc: str | None = None):
        """
        Besides the default predefined properties, some 3rd party aplications may need the bundle
        dfinition to provide additonal properties for the specific use cases, if the bundlle can't
        provide the property, means it can't work with the application.
        This utility adds the property for the application requirements check and access.

        Args:
            name: the name of target property.
            required: whether the property is "must-have".
            desc: description document for the property.

        """
        if name in self.properties:
            warnings.warn(f"property '{name}' already exists in the properties list.")
            return
        self.properties[name] = {BundleProperty.DESC: desc, BundleProperty.REQUIRED: required}

    def check_properties(self) -> list[str] | None:
        """
        Check whether the required properties are existing in the bundle workflow.
        If no workflow type specified, return None, otherwise, return a list of required but missing properties.

        """
        if self.properties is None:
            return None
        return [n for n, p in self.properties.items() if p.get(BundleProperty.REQUIRED, False) and not hasattr(self, n)]


class ConfigWorkflow(BundleWorkflow):
    """
    Specification for the config-based bundle workflow.
    Standardized the `initialize`, `run`, `finalize` behavior in a config-based training, evaluation, or inference.
    For more information: https://docs.monai.io/en/latest/mb_specification.html.

    Args:
        run_id: ID name of the expected config expression to run, default to "run".
            to run the config, the target config must contain this ID.
        init_id: ID name of the expected config expression to initialize before running, default to "initialize".
            allow a config to have no `initialize` logic and the ID.
        final_id: ID name of the expected config expression to finalize after running, default to "finalize".

Review comment (suggestion):
```suggestion
            warnings.warn(f"Property '{name}' already exists in the properties list.")
```
If we don't have the return this allows a property to be replaced but with a warning.

Code after:
        else:
            super().__setattr__(name, value)  # setting regular attribute

    def get_workflow_type(self):
        """
        Get the workflow type, it can be `None`, "train", or "infer".

        """
        return self.workflow

    def add_property(self, name: str, required: str, desc: str | None = None) -> None:
        """
        Besides the default predefined properties, some 3rd party aplications may need the bundle
        definition to provide additonal properties for the specific use cases, if the bundlle can't
        provide the property, means it can't work with the application.
        This utility adds the property for the application requirements check and access.

        Args:
            name: the name of target property.
            required: whether the property is "must-have".
            desc: descriptions for the property.
        """
        if self.properties is None:
            self.properties = {}
        if name in self.properties:
            warnings.warn(f"property '{name}' already exists in the properties list, overriding it.")
        self.properties[name] = {BundleProperty.DESC: desc, BundleProperty.REQUIRED: required}

    def check_properties(self) -> list[str] | None:
        """
        Check whether the required properties are existing in the bundle workflow.
        If no workflow type specified, return None, otherwise, return a list of required but missing properties.

        """
        if self.properties is None:
            return None
        return [n for n, p in self.properties.items() if p.get(BundleProperty.REQUIRED, False) and not hasattr(self, n)]


class ConfigWorkflow(BundleWorkflow):
    """
    Specification for the config-based bundle workflow.
    Standardized the `initialize`, `run`, `finalize` behavior in a config-based training, evaluation, or inference.
    For more information: https://docs.monai.io/en/latest/mb_specification.html.

    Args:
        run_id: ID name of the expected config expression to run, default to "run".
            to run the config, the target config must contain this ID.
        init_id: ID name of the expected config expression to initialize before running, default to "initialize".
            allow a config to have no `initialize` logic and the ID.
        final_id: ID name of the expected config expression to finalize after running, default to "finalize".