microsoft/qlib · error · ValueError

You can choose only one of `local_path`(save the files in a

Error message

You can choose only one of `local_path`(save the files in a path) or `kwargs`(pass in the objects directly)

What it means

Error "You can choose only one of `local_path`(save the files in a path) or `kwargs`(pass in the objects directly)" thrown in microsoft/qlib.

Source

Thrown at qlib/workflow/__init__.py:531

            with R.start(experiment_name='test'):
                R.save_objects(local_path='results/pred.pkl', artifact_path="prediction")
                rid = R.get_recorder().id
            ...
            R.get_recorder(recorder_id=rid).load_object("prediction/pred.pkl")  #  after saving objects, you can load the previous object with this api


        Parameters
        ----------
        local_path : str
            if provided, them save the file or directory to the artifact URI.
        artifact_path : str
            the relative path for the artifact to be stored in the URI.
        **kwargs: Dict[Text, Any]
            the object to be saved.
            For example, `{"pred.pkl": pred}`
        """
        if local_path is not None and len(kwargs) > 0:
            raise ValueError(
                "You can choose only one of `local_path`(save the files in a path) or `kwargs`(pass in the objects directly)"
            )
        self.get_exp().get_recorder(start=True).save_objects(local_path, artifact_path, **kwargs)

    def load_object(self, name: Text):
        """
        Method for loading an object from artifacts in the experiment in the uri.
        """
        return self.get_exp().get_recorder(start=True).load_object(name)

    def log_params(self, **kwargs):
        """
        Method for logging parameters during an experiment. In addition to using ``R``, one can also log to a specific recorder after getting it with `get_recorder` API.

        - If `active recorder` exists: it will log parameters through the active recorder.
        - If `active recorder` not exists: the system will create a default experiment as well as a new recorder, and log parameters under it.

        Here are some use cases:

View on GitHub (pinned to 79633dd950)

Solutions

  1. Pass only one of `local_path` or `kwargs`, not both.
  2. Remove either the `local_path` argument or the object kwargs from the call.

When it happens

Trigger: This error is raised at qlib/workflow/__init__.py:531 when the guard condition fails: "choose only one of local_path or kwargs". It triggers when the code path receives input or a state that violates the precondition checked at this point — e.g. an unimplemented abstract method being called, an unsupported argument type/value, or an invalid configuration. To avoid it, satisfy the documented precondition before this call: implement the required method in your subclass, or pass a supported value of the expected type as described by the message.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15). Data as JSON: /api/errors/dd516fb1b80ef413. Report an issue: GitHub.