{"record":{"id":"536c29dcfffa86b8","repo":"open-mmlab/mmdetection","slug":"the-file-client-args-is-deprecated-please-use-536c29","errorCode":null,"errorMessage":"The `file_client_args` is deprecated, please use `backend_args` instead, please refer tohttps://github.com/open-mmlab/mmdetection/blob/main/configs/_base_/datasets/coco_detection.py","messagePattern":"The `file_client_args` is deprecated, please use `backend_args` instead, please refer tohttps://github\\.com/open-mmlab/mmdetection/blob/main/configs/_base_/datasets/coco_detection\\.py","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"mmdet/evaluation/metrics/coco_metric.py","lineNumber":119,"sourceCode":"        self.proposal_nums = list(proposal_nums)\n\n        # iou_thrs used to compute recall or precision.\n        if iou_thrs is None:\n            iou_thrs = np.linspace(\n                .5, 0.95, int(np.round((0.95 - .5) / .05)) + 1, endpoint=True)\n        self.iou_thrs = iou_thrs\n        self.metric_items = metric_items\n        self.format_only = format_only\n        if self.format_only:\n            assert outfile_prefix is not None, 'outfile_prefix must be not'\n            'None when format_only is True, otherwise the result files will'\n            'be saved to a temp directory which will be cleaned up at the end.'\n\n        self.outfile_prefix = outfile_prefix\n\n        self.backend_args = backend_args\n        if file_client_args is not None:\n            raise RuntimeError(\n                'The `file_client_args` is deprecated, '\n                'please use `backend_args` instead, please refer to'\n                'https://github.com/open-mmlab/mmdetection/blob/main/configs/_base_/datasets/coco_detection.py'  # noqa: E501\n            )\n\n        # if ann_file is not specified,\n        # initialize coco api with the converted dataset\n        if ann_file is not None:\n            with get_local_path(\n                    ann_file, backend_args=self.backend_args) as local_path:\n                self._coco_api = COCO(local_path)\n                if sort_categories:\n                    # 'categories' list in objects365_train.json and\n                    # objects365_val.json is inconsistent, need sort\n                    # list(or dict) before get cat_ids.\n                    cats = self._coco_api.cats\n                    sorted_cats = {i: cats[i] for i in sorted(cats)}\n                    self._coco_api.cats = sorted_cats","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/evaluation/metrics/coco_metric.py#L101-L137","documentation":"CocoMetric.__init__ rejects the legacy `file_client_args` parameter that mmengine file clients used before the 'backend_args' migration. Since mmdetection 3.x, file I/O goes through mmcv/filelock-style backends configured via `backend_args`, so passing file_client_args is a hard RuntimeError pointing at the migration doc. It exists to break silently-wrong old configs early.","triggerScenarios":"Calling CocoMetric(..., file_client_args={'backend':'disk'}) or running a config that still carries a file_client_args key in val_evaluator / test_evaluator after upgrading mmdetection to 3.x.","commonSituations":"Upgrading from mmdet 2.x / early 3.x configs; copy-pasting an old custom evaluator config that specified a petl/ceph client via file_client_args.","solutions":["Remove file_client_args and pass backend_args instead, e.g. backend_args=dict(backend='local') for local files","For remote storage use backend_args=dict(backend='petrel', path_mapping=...)","Diff your config against configs/_base_/datasets/coco_detection.py referenced in the message"],"exampleFix":"# before\nval_evaluator = dict(type='CocoMetric', ann_file=..., metric='bbox', file_client_args=dict(backend='disk'))\n# after\nval_evaluator = dict(type='CocoMetric', ann_file=..., metric='bbox', backend_args=dict(backend='local'))","handlingStrategy":"validation","validationCode":"def sanitize_evaluator(cfg):\n    ev = cfg.get('val_evaluator', cfg.get('test_evaluator', {}))\n    if 'file_client_args' in ev:\n        raise ValueError('file_client_args removed; migrate to backend_args')\n    return cfg","typeGuard":"def uses_backend_args(eval_cfg: dict) -> bool:\n    return 'file_client_args' not in eval_cfg and (\n        'backend_args' not in eval_cfg or isinstance(eval_cfg['backend_args'], dict))","tryCatchPattern":"try:\n    CocoMetric(..., file_client_args=fca)\nexcept RuntimeError as e:\n    if 'file_client_args' in str(e):\n        raise ValueError('migrate config: replace file_client_args with backend_args') from e\n    raise","preventionTips":["Grep configs for file_client_args after upgrading mmdetection","Prefer omitting backend_args entirely for local files (it defaults correctly)","Pin mmdetection major version in requirements to avoid surprise API breaks"],"tags":["mmdetection","deprecation","file-client","migration"],"backgroundTag":"deprecated-parameter-removed","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}