mmeval.fileio.get_file_backend¶
- mmeval.fileio.get_file_backend(uri: Optional[Union[str, pathlib.Path]] = None, *, backend_args: Optional[dict] = None, enable_singleton: bool = False)[source]¶
Return a file backend based on the prefix of uri or backend_args.
- Parameters
uri (str or Path) – Uri to be parsed that contains the file prefix.
backend_args (dict, optional) – Arguments to instantiate the corresponding backend. Defaults to None.
enable_singleton (bool) – Whether to enable the singleton pattern. If it is True, the backend created will be reused if the signature is same with the previous one. Defaults to False.
- Returns
Instantiated Backend object.
- Return type
Examples
>>> # get file backend based on the prefix of uri >>> uri = 's3://path/of/your/file' >>> backend = get_file_backend(uri) >>> # get file backend based on the backend_args >>> backend = get_file_backend(backend_args={'backend': 'petrel'}) >>> # backend name has a higher priority if 'backend' in backend_args >>> backend = get_file_backend(uri, backend_args={'backend': 'petrel'})