Repository: microsoft/qlib
File: qlib/workflow/__init__.py (Python)

Code before:
# Licensed under the MIT License.

from contextlib import contextmanager
from typing import Text, Optional
from .expm import MLflowExpManager
from .exp import Experiment
from .recorder import Recorder
from ..utils import Wrapper


class QlibRecorder:
    """
    A global system that helps to manage the experiments.
    """

    def __init__(self, exp_manager):
        self.exp_manager = exp_manager

    def __repr__(self):
        return "{name}(manager={manager})".format(name=self.__class__.__name__, manager=self.exp_manager)

    @contextmanager
    def start(
        self,
        experiment_id: Optional[Text] = None,
        experiment_name: Optional[Text] = None,
        recorder_id: Optional[Text] = None,
        recorder_name: Optional[Text] = None,
        uri: Optional[Text] = None,
        resume: bool = False,
    ):
        """
        Method to start an experiment. This method can only be called within a Python's `with` statement. Here is the example code:

        .. code-block:: Python

            # start new experiment and recorder
            with R.start('test', 'recorder_1'):
                model.fit(dataset)
                R.log...
                ... # further operations

            # resume previous experiment and recorder
            with R.start('test', 'recorder_1', resume=True): # if users want to resume recorder, they have to specify the exact same name for experiment and recorder.
                ... # further operations

        Parameters
        ----------
        experiment_id : str
            id of the experiment one wants to start.
        experiment_name : str

Review comment (bug):
You change the order of  the parameters. 
This is not compatible with the previous version.
You can use https://python-3-for-scientists.readthedocs.io/en/latest/python3_advanced.html  to raise error when receiving non-keyward arguments to help users debug.

Code after:
# Licensed under the MIT License.

from contextlib import contextmanager
from typing import Text, Optional
from .expm import MLflowExpManager
from .exp import Experiment
from .recorder import Recorder
from ..utils import Wrapper


class QlibRecorder:
    """
    A global system that helps to manage the experiments.
    """

    def __init__(self, exp_manager):
        self.exp_manager = exp_manager

    def __repr__(self):
        return "{name}(manager={manager})".format(name=self.__class__.__name__, manager=self.exp_manager)

    @contextmanager
    def start(
        self,
        *,
        experiment_id: Optional[Text] = None,
        experiment_name: Optional[Text] = None,
        recorder_id: Optional[Text] = None,
        recorder_name: Optional[Text] = None,
        uri: Optional[Text] = None,
        resume: bool = False,
    ):
        """
        Method to start an experiment. This method can only be called within a Python's `with` statement. Here is the example code:

        .. code-block:: Python

            # start new experiment and recorder
            with R.start('test', 'recorder_1'):
                model.fit(dataset)
                R.log...
                ... # further operations

            # resume previous experiment and recorder
            with R.start('test', 'recorder_1', resume=True): # if users want to resume recorder, they have to specify the exact same name for experiment and recorder.
                ... # further operations

        Parameters
        ----------
        experiment_id : str
            id of the experiment one wants to start.