Repository: Project-MONAI/MONAI
File: monai/handlers/mlflow_handler.py (Python)

Code before:

    Args:
        tracking_uri: connects to a tracking URI. can also set the `MLFLOW_TRACKING_URI` environment
            variable to have MLflow find a URI from there. in both cases, the URI can either be
            an HTTP/HTTPS URI for a remote server, a database connection string, or a local path
            to log data to a directory. The URI defaults to path `mlruns`.
            for more details: https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.set_tracking_uri.
        iteration_log: whether to log data to MLFlow when iteration completed, default to `True`.
            ``iteration_log`` can be also a function and it will be interpreted as an event filter
            (see https://pytorch.org/ignite/generated/ignite.engine.events.Events.html for details).
            Event filter function accepts as input engine and event value (iteration) and should return True/False.
        epoch_log: whether to log data to MLFlow when epoch completed, default to `True`.
            ``epoch_log`` can be also a function and it will be interpreted as an event filter.
            See ``iteration_log`` argument for more details.
        dataset_log: whether to log information about the dataset at the beginning. This arg
            is only useful when MLFlow version >= 2.4.0. For more details, please go to the
            website: https://mlflow.org/docs/latest/python_api/mlflow.data.html.
        epoch_logger: customized callable logger for epoch level logging with MLFlow.
            Must accept parameter "engine", use default logger if None.
        iteration_logger: customized callable logger for iteration level logging with MLFlow.
            Must accept parameter "engine", use default logger if None.
        dataset_logger: customized callable logger to log the dataset information with MLFlow.
            Must accept parameter "dataset_dict", use default logger if None.
        dataset_dict: a dictionary in which the key is the name of the dataset and the value is a PyTorch
            dataset, that needs to be recorded.
        dataset_keys: a key or a collection of keys to indicate contents in the dataset that
            need to be stored by MLFlow.
        output_transform: a callable that is used to transform the
            ``ignite.engine.state.output`` into a scalar to track, or a dictionary of {key: scalar}.
            By default this value logging happens when every iteration completed.
            The default behavior is to track loss from output[0] as output is a decollated list
            and we replicated loss value for every item of the decollated list.
            `engine.state` and `output_transform` inherit from the ignite concept:
            https://pytorch-ignite.ai/concepts/03-state/, explanation and usage example are in the tutorial:
            https://github.com/Project-MONAI/tutorials/blob/master/modules/batch_output_transform.ipynb.
        global_epoch_transform: a callable that is used to customize global epoch number.
            For example, in evaluation, the evaluator engine might want to track synced epoch number
            with the trainer engine.
        state_attributes: expected attributes from `engine.state`, if provided, will extract them
            when epoch completed.
        tag_name: when iteration output is a scalar, `tag_name` is used to track, defaults to `'Loss'`.
        experiment_name: the experiment name of MLflow, default to `'monai_experiment'`. An experiment can be
            used to record several runs.
        run_name: the run name in an experiment. A run can be used to record information about a workflow,
            like the loss, metrics and so on.
        experiment_param: a dict recording parameters which will not change through the whole workflow,
            like torch version, cuda version and so on.
        artifacts: paths to images that need to be recorded after running the workflow.
        optimizer_param_names: parameter names in the optimizer that need to be recorded during running the
            workflow, default to `'lr'`.
        close_on_complete: whether to close the mlflow run in `complete` phase in workflow, default to False.

Review comment (refactor):
I feel these `dataset_log`, `dataset_dict`, `dataset_keys` are too complicated to understand and use..
Can we simplify them? Maybe only 1 arg?
CC @KumoLiu and @wyli 

Thanks.


Code after:

    Args:
        tracking_uri: connects to a tracking URI. can also set the `MLFLOW_TRACKING_URI` environment
            variable to have MLflow find a URI from there. in both cases, the URI can either be
            an HTTP/HTTPS URI for a remote server, a database connection string, or a local path
            to log data to a directory. The URI defaults to path `mlruns`.
            for more details: https://mlflow.org/docs/latest/python_api/mlflow.html#mlflow.set_tracking_uri.
        iteration_log: whether to log data to MLFlow when iteration completed, default to `True`.
            ``iteration_log`` can be also a function and it will be interpreted as an event filter
            (see https://pytorch.org/ignite/generated/ignite.engine.events.Events.html for details).
            Event filter function accepts as input engine and event value (iteration) and should return True/False.
        epoch_log: whether to log data to MLFlow when epoch completed, default to `True`.
            ``epoch_log`` can be also a function and it will be interpreted as an event filter.
            See ``iteration_log`` argument for more details.
        epoch_logger: customized callable logger for epoch level logging with MLFlow.
            Must accept parameter "engine", use default logger if None.
        iteration_logger: customized callable logger for iteration level logging with MLFlow.
            Must accept parameter "engine", use default logger if None.
        dataset_logger: customized callable logger to log the dataset information with MLFlow.
            Must accept parameter "dataset_dict", use default logger if None.
        dataset_dict: a dictionary in which the key is the name of the dataset and the value is a PyTorch
            dataset, that needs to be recorded. This arg is only useful when MLFlow version >= 2.4.0.
            For more details about how to log data with MLFlow, please go to the website:
            https://mlflow.org/docs/latest/python_api/mlflow.data.html.
        dataset_keys: a key or a collection of keys to indicate contents in the dataset that
            need to be stored by MLFlow.
        output_transform: a callable that is used to transform the
            ``ignite.engine.state.output`` into a scalar to track, or a dictionary of {key: scalar}.
            By default this value logging happens when every iteration completed.
            The default behavior is to track loss from output[0] as output is a decollated list
            and we replicated loss value for every item of the decollated list.
            `engine.state` and `output_transform` inherit from the ignite concept:
            https://pytorch-ignite.ai/concepts/03-state/, explanation and usage example are in the tutorial:
            https://github.com/Project-MONAI/tutorials/blob/master/modules/batch_output_transform.ipynb.
        global_epoch_transform: a callable that is used to customize global epoch number.
            For example, in evaluation, the evaluator engine might want to track synced epoch number
            with the trainer engine.
        state_attributes: expected attributes from `engine.state`, if provided, will extract them
            when epoch completed.
        tag_name: when iteration output is a scalar, `tag_name` is used to track, defaults to `'Loss'`.
        experiment_name: the experiment name of MLflow, default to `'monai_experiment'`. An experiment can be
            used to record several runs.
        run_name: the run name in an experiment. A run can be used to record information about a workflow,
            like the loss, metrics and so on.
        experiment_param: a dict recording parameters which will not change through the whole workflow,
            like torch version, cuda version and so on.
        artifacts: paths to images that need to be recorded after running the workflow.
        optimizer_param_names: parameter names in the optimizer that need to be recorded during running the
            workflow, default to `'lr'`.
        close_on_complete: whether to close the mlflow run in `complete` phase in workflow, default to False.