{"record":{"id":"b1f8053c20144c67","repo":"microsoft/qlib","slug":"please-give-the-search-space-of-strategy","errorCode":null,"errorMessage":"Please give the search space of strategy.","messagePattern":"Please give the search space of strategy\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/contrib/tuner/tuner.py","lineNumber":182,"sourceCode":"        with open(estimator_path, \"w\") as fp:\n            yaml.dump(estimator_config, fp)\n\n        return estimator_path\n\n    def setup_space(self):\n        # 1. Setup model space\n        model_space_name = self.tuner_config[\"model\"].get(\"space\", None)\n        if model_space_name is None:\n            raise ValueError(\"Please give the search space of model.\")\n        model_space = getattr(\n            importlib.import_module(\".space\", package=\"qlib.contrib.tuner\"),\n            model_space_name,\n        )\n\n        # 2. Setup strategy space\n        strategy_space_name = self.tuner_config[\"strategy\"].get(\"space\", None)\n        if strategy_space_name is None:\n            raise ValueError(\"Please give the search space of strategy.\")\n        strategy_space = getattr(\n            importlib.import_module(\".space\", package=\"qlib.contrib.tuner\"),\n            strategy_space_name,\n        )\n\n        # 3. Setup data label space if given\n        if self.tuner_config.get(\"data_label\", None) is not None:\n            data_label_space_name = self.tuner_config[\"data_label\"].get(\"space\", None)\n            if data_label_space_name is not None:\n                data_label_space = getattr(\n                    importlib.import_module(\".space\", package=\"qlib.contrib.tuner\"),\n                    data_label_space_name,\n                )\n        else:\n            data_label_space_name = None\n\n        # 4. Combine the searching space\n        space = dict()","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/contrib/tuner/tuner.py#L164-L200","documentation":"QLibTuner.setup_space (qlib/contrib/tuner/tuner.py) also requires the 'strategy' section of the tuner config to carry a 'space' key naming a strategy search-space class in qlib.contrib.tuner.space. Without it, the tuner has no strategy variants to explore and raises ValueError('Please give the search space of strategy.') at setup time.","triggerScenarios":"A tuner YAML whose strategy section omits space: (only class/module_path given); QLibTuner.setup_space() raises during tuner construction, right after the model space check.","commonSituations":"Converting a normal workflow config (strategy has no search space concept) into a tuner config; the model section was updated but the strategy section forgotten; a misspelled space name resolves later to AttributeError.","solutions":["Add space: <ClassName> under strategy in the tuner YAML, e.g. strategy: {space: TopkDropoutStrategySpace}","Confirm the class exists in qlib/contrib/tuner/space.py","Start from the tuner example configs so both model and strategy sections keep their space keys"],"exampleFix":"# before (tuner_config.yaml)\nstrategy:\n  class: TopkDropoutStrategy\n  module_path: qlib.contrib.strategy.signal_strategy\n\n# after\nstrategy:\n  space: TopkDropoutStrategySpace\n  class: TopkDropoutStrategy\n  module_path: qlib.contrib.strategy.signal_strategy","handlingStrategy":"validation","validationCode":"strategy_space = cfg.get('strategy', {}).get('space')\nassert strategy_space, 'tuner config strategy section needs a space: entry'\nfrom qlib.contrib.tuner import space as tuner_space\nassert hasattr(tuner_space, strategy_space), f'{strategy_space} not found in qlib.contrib.tuner.space'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give both model and strategy sections a space key when authoring tuner YAMLs","Validate the whole tuner config (spaces, report_type, report_factor, optim_type) in one pre-flight pass"],"tags":["qlib","tuner","configuration","search-space"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}