mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-12 15:28:21 +01:00
local: support remote:// syntax
Fixes #1451 Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
@@ -45,9 +45,8 @@ class DependencyLOCAL(DependencyBase):
|
||||
|
||||
@property
|
||||
def is_local(self):
|
||||
assert os.path.isabs(self.path)
|
||||
assert os.path.isabs(self.project.root_dir)
|
||||
return self.path.startswith(self.project.root_dir)
|
||||
return (urlparse(self.url).scheme != 'remote'
|
||||
and not os.path.isabs(self.url))
|
||||
|
||||
@property
|
||||
def sep(self):
|
||||
@@ -85,7 +84,7 @@ class DependencyLOCAL(DependencyBase):
|
||||
path = self.remote.unixpath(os.path.relpath(self.path,
|
||||
self.stage.cwd))
|
||||
else:
|
||||
path = self.path
|
||||
path = self.url
|
||||
|
||||
info = self.info.copy()
|
||||
info[self.PARAM_PATH] = path
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import yaml
|
||||
import time
|
||||
import shutil
|
||||
import filecmp
|
||||
@@ -8,6 +9,7 @@ from dvc.utils import file_md5
|
||||
from dvc.stage import Stage
|
||||
from dvc.exceptions import DvcException
|
||||
from dvc.output.base import OutputAlreadyTrackedError
|
||||
from dvc.project import Project
|
||||
|
||||
from tests.basic_env import TestDvc
|
||||
|
||||
@@ -149,6 +151,36 @@ class TestAddExternalLocalFile(TestDvc):
|
||||
self.assertTrue(filecmp.cmp(fname, 'foo', shallow=False))
|
||||
|
||||
|
||||
class TestAddLocalRemoteFile(TestDvc):
|
||||
def test(self):
|
||||
"""
|
||||
Making sure that 'remote' syntax is handled properly for local outs.
|
||||
"""
|
||||
cwd = os.getcwd()
|
||||
remote = 'myremote'
|
||||
|
||||
ret = main(['remote', 'add', remote, cwd])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
self.dvc = Project()
|
||||
|
||||
foo = 'remote://{}/{}'.format(remote, self.FOO)
|
||||
ret = main(['add', foo])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
with open('foo.dvc', 'r') as fobj:
|
||||
d = yaml.safe_load(fobj)
|
||||
self.assertEqual(d['outs'][0]['path'], foo)
|
||||
|
||||
bar = os.path.join(cwd, self.BAR)
|
||||
ret = main(['add', bar])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
with open('bar.dvc', 'r') as fobj:
|
||||
d = yaml.safe_load(fobj)
|
||||
self.assertEqual(d['outs'][0]['path'], bar)
|
||||
|
||||
|
||||
class TestCmdAdd(TestDvc):
|
||||
def test(self):
|
||||
ret = main(['add',
|
||||
|
||||
Reference in New Issue
Block a user