Replace Output with a local copy and remove all unused code

This commit is contained in:
Ronan Lamy
2022-10-04 14:37:29 +03:00
committed by Ruslan Kuprieiev
parent 71734a3d09
commit c27125d9c0
+32 -3
View File
@@ -1,10 +1,39 @@
from dvc.exceptions import URLMissingError
from dvc.output import Output
from dvc.fs import get_cloud_fs
from dvc.output import OutputIsStageFileError
class Output:
def __init__(
self,
path,
fs_config=None,
):
fs_config = fs_config or {}
fs_cls, _fs_config, fs_path = get_cloud_fs(None, url=path, **fs_config)
self.fs = fs_cls(**_fs_config)
_validate_output_path(path)
self.fs_path = _parse_path(self.fs, fs_path)
def _parse_path(fs, fs_path):
return fs.path.abspath(fs.path.normpath(fs_path))
def _validate_output_path(path):
from dvc.dvcfile import is_valid_filename
if is_valid_filename(path):
raise OutputIsStageFileError(path)
def get_external_fs(url, fs_config=None):
out = Output(url, fs_config)
return out.fs, out.fs_path
def ls_url(url):
out = Output(None, url)
fs, fs_path = out.fs, out.fs_path
fs, fs_path = get_external_fs(url)
try:
info = fs.info(fs_path)