{"record":{"id":"4c9f2e7b0724ae58","repo":"microsoft/qlib","slug":"mount-failed-e-stderr","errorCode":null,"errorMessage":"Mount failed: {e.stderr}","messagePattern":"Mount failed: (.+?)","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"critical","filePath":"qlib/__init__.py","lineNumber":183,"sourceCode":"                        f\"Failed to create directory {mount_path}, please create {mount_path} manually!\"\n                    ) from e\n\n                # check nfs-common\n                command_res = os.popen(\"dpkg -l | grep nfs-common\")\n                command_res = command_res.readlines()\n                if not command_res:\n                    raise OSError(\"nfs-common is not found, please install it by execute: sudo apt install nfs-common\")\n                # manually mount\n                try:\n                    subprocess.run(mount_command, check=True, capture_output=True, text=True)\n                    LOG.info(\"Mount finished.\")\n                except subprocess.CalledProcessError as e:\n                    if e.returncode == 256:\n                        raise OSError(\"Mount failed: requires sudo or permission denied\") from e\n                    elif e.returncode == 32512:\n                        raise OSError(f\"mount {provider_uri} on {mount_path} error! Command error\") from e\n                    else:\n                        raise OSError(f\"Mount failed: {e.stderr}\") from e\n            else:\n                LOG.warning(f\"{_remote_uri} on {_mount_path} is already mounted\")\n\n\ndef init_from_yaml_conf(conf_path, **kwargs):\n    \"\"\"init_from_yaml_conf\n\n    :param conf_path: A path to the qlib config in yml format\n    \"\"\"\n\n    if conf_path is None:\n        config = {}\n    else:\n        with open(conf_path) as f:\n            yaml = YAML(typ=\"safe\", pure=True)\n            config = yaml.load(f)\n    config.update(kwargs)\n    default_conf = config.pop(\"default_conf\", \"client\")","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/__init__.py#L165-L201","documentation":"DatasetCache._uri (qlib/data/cache.py:423) is the abstract hook that maps (instruments, fields, start_time, end_time, freq) to a dataset cache file URI. The base DatasetCache provides no storage mechanism, so _uri raises NotImplementedError. Unlike _dataset, there is no automatic fallback for URI resolution — code paths like DatasetCache.dataset with disk_cache=1 or _dataset_uri call _uri directly.","triggerScenarios":"Using a DatasetCache subclass that overrides _dataset but not _uri (or the base class itself) and calling D.features(..., disk_cache=1) / DatasetCache.dataset, which resolves the cache URI before reading; also hit by cache-maintenance code calling uri().","commonSituations":"Custom dataset cache backends with partial overrides; the concrete implementation users should reach for is DiskDatasetCache (or SimpleDatasetCache/DatasetURICache) in the same module.","solutions":["Configure qlib.init(dataset_cache=DiskDatasetCache) for standard file-based dataset caching","In a custom subclass, override _uri(self, instruments, fields, start_time, end_time, freq, **kwargs) to return the cache file path string","Model the override on DiskDatasetCache._uri, which hashes the arguments to build the path"],"exampleFix":"# before\nqlib.init(dataset_cache=MyPartialCache)  # _uri missing -> D.features(disk_cache=1) fails\n\n# after\nfrom qlib.data.cache import DiskDatasetCache\nqlib.init(dataset_cache=DiskDatasetCache)","handlingStrategy":"type-guard","validationCode":"from qlib.data.cache import DatasetCache\n\nassert MyDSCache._uri is not DatasetCache._uri, \\\n    \"custom DatasetCache must override _uri before enabling disk_cache=1\"","typeGuard":"def is_usable_ds_cache(cls) -> bool:\n    return all(\n        getattr(cls, m) is not getattr(DatasetCache, m)\n        for m in (\"_uri\", \"_dataset\", \"_dataset_uri\", \"update\")\n    )","tryCatchPattern":null,"preventionTips":["Default to DiskDatasetCache; only subclass when you implement the full override set","Smoke-test D.features(disk_cache=1) after any cache config change","Keep a staging config to validate cache classes before production init"],"tags":["qlib","cache","custom-backend","not-implemented"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}