Repository: microsoft/qlib
File: qlib/finco/task.py (Python)

Code before:

        if isinstance(analysers, list) and len(analysers):
            self.logger.info(f"selected analysers: {analysers}", plain=True)

            workflow_config = (
                self._context_manager.get_context("workflow_config")
                if self._context_manager.get_context("workflow_config")
                else "workflow_config.yaml"
            )
            workspace = self._context_manager.get_context("workspace")
            workflow_path = workspace.joinpath(workflow_config)
            with workflow_path.open() as f:
                workflow = yaml.safe_load(f)

            experiment_name = workflow["experiment_name"] if "experiment_name" in workflow else "workflow"

            model = init_instance_by_config(workflow["task"]["model"])
            dataset = init_instance_by_config(workflow["task"]["dataset"])

            tasks = []
            for analyser in analysers:
                if analyser in self.__ANALYZERS_PROJECT.keys():
                    tasks.append(
                        self.__ANALYZERS_PROJECT.get(analyser)(
                            workspace=workspace,
                            model=model,
                            dataset=dataset,
                            recorder=R.get_recorder(experiment_name=experiment_name),
                        )
                    )

            for task in tasks:
                resp = task.analyse()
                self._context_manager.set_context(resp, task.__class__.__doc__)

        return []


class ActionTask(Task):
    pass


class CMDTask(ActionTask):
    """
    This CMD task is responsible for ensuring compatibility across different operating systems.
    """

    def __init__(self, cmd_intention: str, cwd=None):
        self.cwd = cwd
        self.cmd_intention = cmd_intention
        self._output = None

Review comment (suggestion):
I don't think `SignalRecord` is one of Analysor.
Please refer to `SignalAnalyzer.__name__: SignalRecord,`
Thus `model` and `dataset` is not necessary paramters


Code after:
        if isinstance(analysers, list) and len(analysers):
            self.logger.info(f"selected analysers: {analysers}", plain=True)

            workflow_config = (
                self._context_manager.get_context("workflow_config")
                if self._context_manager.get_context("workflow_config")
                else "workflow_config.yaml"
            )
            workspace = self._context_manager.get_context("workspace")
            workflow_path = workspace.joinpath(workflow_config)
            with workflow_path.open() as f:
                workflow = yaml.safe_load(f)

            experiment_name = workflow["experiment_name"] if "experiment_name" in workflow else "workflow"
            R.set_uri(Path.joinpath(workspace, 'mlruns').as_uri())

            tasks = []
            for analyser in analysers:
                if analyser in self.__ANALYZERS_PROJECT.keys():
                    tasks.append(
                        self.__ANALYZERS_PROJECT.get(analyser)(
                            recorder=R.get_recorder(experiment_name=experiment_name),
                            output_dir=workspace
                        )
                    )

            for task in tasks:
                resp = task.analyse()
                self._context_manager.set_context(resp, task.__class__.__doc__)

        return []


class ActionTask(Task):
    pass


class CMDTask(ActionTask):
    """
    This CMD task is responsible for ensuring compatibility across different operating systems.
    """

    def __init__(self, cmd_intention: str, cwd=None):
        self.cwd = cwd
        self.cmd_intention = cmd_intention
        self._output = None
        super().__init__()

    def execute(self):
        prompt = self.user.render(
            cmd_intention=self.cmd_intention, user_os=platform.system()