microsoft/qlib · error · NotImplementedError
Please implement the `remove` method
Error message
Please implement the `remove` method
What it means
remove(fname=None) is the deletion method of the abstract ObjManager interface: with fname it deletes one object, without it deletes everything. The base stub raises NotImplementedError, so any delete on the abstract base or a subclass without a remove override fails immediately.
Source
Thrown at qlib/utils/objm.py:88
list the objects
Returns
-------
list:
the list of returned objects
"""
raise NotImplementedError(f"Please implement the `list` method")
def remove(self, fname=None):
"""remove.
Parameters
----------
fname :
if file name is provided. specific file is removed
otherwise, The all the objects will be removed.
"""
raise NotImplementedError(f"Please implement the `remove` method")
class FileManager(ObjManager):
"""
Use file system to manage objects
"""
def __init__(self, path=None):
if path is None:
self.path = Path(self.create_path())
else:
self.path = Path(path).resolve()
def create_path(self) -> str:
try:
return tempfile.mkdtemp(prefix=str(C["file_manager_path"]) + os.sep)
except AttributeError as attribute_e:
raise NotImplementedError(View on GitHub (pinned to 79633dd950)
Solutions
- Use FileManager, whose remove() deletes one file or clears its directory.
- Implement remove(self, fname=None) in your subclass mapping to your backend's delete API.
- Careful with the no-argument form: it purges ALL objects — prefer passing fname for targeted deletion.
Example fix
// before
ObjManager().remove('model_v1') # NotImplementedError
// after
FileManager(path='./objs').remove('model_v1') Defensive patterns
Strategy: try-catch
Validate before calling
from qlib.utils.objm import ObjManager
if type(mgr).remove is ObjManager.remove:
raise RuntimeError('manager cannot remove objects; implement remove()') Type guard
def supports_remove(mgr) -> bool:
return type(mgr).remove is not ObjManager.remove Try / catch
try:
mgr.remove(fname)
except NotImplementedError:
(Path(backup_dir) / fname).unlink(missing_ok=True) Prevention
- Implement remove() (single and purge-all forms) in custom managers; retention policies always arrive later.
- Guard purge-all (fname=None) behind an explicit confirmation flag in your code.
When it happens
Trigger: ObjManager().remove('model_v1') or ObjManager().remove() (purge-all); calling mgr.remove(...) on a custom manager that never implemented deletion.
Common situations: Cache-cleanup jobs at the end of experiments; CI steps purging artifact directories; custom cloud-storage managers where deletion was deemed unnecessary until a retention policy arrived.
Related errors
- Please implement `save_obj`
- Please implement the `save_objs` method
- Please implement the `load_obj` method
- Please implement the `exists` method
- Please implement the `list` method
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/2d5c55bc640a8aae.
Report an issue: GitHub.