config: schema: support windows paths

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-04-07 04:41:59 +03:00
parent e8b5af6cd9
commit 8d8af0518e
3 changed files with 8 additions and 10 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ class DataCloudBase(object):
if path:
Logger.warn('Using obsoleted config format. Consider updating.')
else:
path = re.match(Config.SECTION_REMOTE_URL_REGEX, url).group(2)
path = re.match(Config.SECTION_REMOTE_URL_REGEX, url).group('storagepath')
return path
+6 -8
View File
@@ -1,10 +1,4 @@
import re
try:
from urlparse import urlparse
except ImportError:
from urllib.parse import urlparse
from multiprocessing.pool import ThreadPool
from dvc.cloud.instance_manager import CloudSettings
@@ -32,7 +26,7 @@ class DataCloud(object):
SCHEME_MAP = {
's3' : 'aws',
'gs' : 'gcp',
'' : 'local',
None : 'local',
}
def __init__(self, cache, config):
@@ -58,7 +52,11 @@ class DataCloud(object):
raise ConfigError("Can't find remote section '{}' in config".format(section))
url = cloud_config[Config.SECTION_REMOTE_URL]
scheme = urlparse(url).scheme
res = re.match(Config.SECTION_REMOTE_URL_REGEX, url)
if not res:
raise ConfigError("Unknown format of url '{}'".format(url))
scheme = res.group('scheme')
cloud_type = self.SCHEME_MAP.get(scheme, None)
if not cloud_type:
raise ConfigError("Unsupported scheme '{}' in '{}'".format(scheme, url))
+1 -1
View File
@@ -69,7 +69,7 @@ class Config(object):
SECTION_REMOTE_REGEX = r'^\s*remote\s*"(.*)"\s*$'
SECTION_REMOTE_FMT = 'remote "{}"'
SECTION_REMOTE_URL = 'url'
SECTION_REMOTE_URL_REGEX = r'^\s*(s3://|gs://|/)?(.*)\s*$'
SECTION_REMOTE_URL_REGEX = r'^\s*(((?P<scheme>s3|gs|..+):/*)|/*|.\\*)?(?P<storagepath>.*)\s*$'
SECTION_REMOTE_SCHEMA = {
SECTION_REMOTE_URL: schema.Regex(SECTION_REMOTE_URL_REGEX),
schema.Optional(SECTION_AWS_REGION): str,