From 1cca0ca69bd96825502dbef3e472aaadf12f6a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Trifir=C3=B2?= Date: Mon, 6 Jun 2022 17:43:03 +0200 Subject: [PATCH] gs: add {_strip,unstrip}_protocol fixes resolution of relative paths fixes https://github.com/iterative/dvc/issues/7638 --- src/dvc_objects/fs/implementations/gs.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/dvc_objects/fs/implementations/gs.py b/src/dvc_objects/fs/implementations/gs.py index 334a2bb..e797be1 100644 --- a/src/dvc_objects/fs/implementations/gs.py +++ b/src/dvc_objects/fs/implementations/gs.py @@ -23,3 +23,12 @@ def fs(self): from gcsfs import GCSFileSystem return GCSFileSystem(**self.fs_args) + + @classmethod + def _strip_protocol(cls, path: str) -> str: + from fsspec.utils import infer_storage_options + + return infer_storage_options(path)["path"] + + def unstrip_protocol(self, path: str) -> str: + return "gs://" + path.lstrip("/")