Skip to content

Commit 620bb4e

Browse files
committed
remote: implement Google Drive
1 parent 688bcaa commit 620bb4e

17 files changed

+1160
-5
lines changed

.appveyor.yml

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ environment:
1818
secure: 96fJ3r2i2GohbXHwnSs5N4EplQ7q8YmLpPWM0AC+f4s=
1919
CODECOV_TOKEN:
2020
secure: XN4jRtmGE5Bqg8pPZkwNs7kn3UEI73Rkldqc0MGsQISZBm5TNJZOPofDMc1QnUsf
21+
OAUTH2_TOKEN_FILE_KEY:
22+
secure: cL2KgINnnWhfNVy+lEI/QmA31cKwYojGhFRFs1x0PAkA5QRvZxYTlBX+XpjQYF8k2A6tqYMUWztZt0dXlMKqLVf5aCtg7z2I5AWW5dhGeTY=
23+
OAUTH2_TOKEN_FILE_IV:
24+
secure: 6lKZF5KNCpP80lFZ7a8yFkvcwllt2eoEC7LpSS5Mlwg4ilFsjFVSm+zw2GqA7NKw
2125
AZURE_STORAGE_CONTAINER_NAME: appveyor-tests
2226
AZURE_STORAGE_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;
2327
OSS_ENDPOINT: localhost:50004

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include dvc/remote/gdrive/google-dvc-client-id.json

dvc/config.py

+9
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ class Config(object): # pylint: disable=too-many-instance-attributes
221221
Optional(SECTION_GCP_PROJECTNAME): str,
222222
}
223223

224+
SECTION_GDRIVE_SCOPES = "gdrive_scopes"
225+
SECTION_GDRIVE_CREDENTIALPATH = SECTION_AWS_CREDENTIALPATH
226+
224227
# backward compatibility
225228
SECTION_LOCAL = "local"
226229
SECTION_LOCAL_STORAGEPATH = SECTION_AWS_STORAGEPATH
@@ -250,6 +253,7 @@ class Config(object): # pylint: disable=too-many-instance-attributes
250253
Optional(SECTION_AWS_LIST_OBJECTS, default=False): BOOL_SCHEMA,
251254
Optional(SECTION_AWS_USE_SSL, default=True): BOOL_SCHEMA,
252255
Optional(SECTION_GCP_PROJECTNAME): str,
256+
Optional(SECTION_GDRIVE_SCOPES): str,
253257
Optional(SECTION_CACHE_TYPE): SECTION_CACHE_TYPE_SCHEMA,
254258
Optional(SECTION_CACHE_PROTECTED, default=False): BOOL_SCHEMA,
255259
Optional(SECTION_REMOTE_USER): str,
@@ -273,11 +277,16 @@ class Config(object): # pylint: disable=too-many-instance-attributes
273277
Optional(SECTION_STATE_ROW_CLEANUP_QUOTA): And(Use(int), is_percent),
274278
}
275279

280+
SECTION_OAUTH2 = "oauth2"
281+
SECTION_OAUTH2_FLOW_RUNNER = "flow_runner"
282+
SECTION_OAUTH2_SCHEMA = {Optional(SECTION_OAUTH2_FLOW_RUNNER): str}
283+
276284
SCHEMA = {
277285
Optional(SECTION_CORE, default={}): SECTION_CORE_SCHEMA,
278286
Optional(Regex(SECTION_REMOTE_REGEX)): SECTION_REMOTE_SCHEMA,
279287
Optional(SECTION_CACHE, default={}): SECTION_CACHE_SCHEMA,
280288
Optional(SECTION_STATE, default={}): SECTION_STATE_SCHEMA,
289+
Optional(SECTION_OAUTH2, default={}): SECTION_OAUTH2_SCHEMA,
281290
# backward compatibility
282291
Optional(SECTION_AWS, default={}): SECTION_AWS_SCHEMA,
283292
Optional(SECTION_GCP, default={}): SECTION_GCP_SCHEMA,

dvc/data_cloud.py

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from dvc.remote import Remote
99
from dvc.remote.s3 import RemoteS3
1010
from dvc.remote.gs import RemoteGS
11+
from dvc.remote.gdrive import RemoteGDrive
1112
from dvc.remote.azure import RemoteAZURE
1213
from dvc.remote.oss import RemoteOSS
1314
from dvc.remote.ssh import RemoteSSH
@@ -34,6 +35,7 @@ class DataCloud(object):
3435
CLOUD_MAP = {
3536
"aws": RemoteS3,
3637
"gcp": RemoteGS,
38+
"gdrive": RemoteGDrive,
3739
"azure": RemoteAZURE,
3840
"oss": RemoteOSS,
3941
"ssh": RemoteSSH,

dvc/path/gdrive.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from dvc.scheme import Schemes
2+
from .base import PathBASE
3+
4+
5+
class PathGDrive(PathBASE):
6+
scheme = Schemes.GDRIVE
7+
8+
def __init__(self, root, url=None, path=None):
9+
super(PathGDrive, self).__init__(url, path)
10+
self.root = root

dvc/remote/__init__.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
from __future__ import unicode_literals
22

33
from dvc.remote.azure import RemoteAZURE
4+
from dvc.remote.gdrive import RemoteGDrive
45
from dvc.remote.gs import RemoteGS
56
from dvc.remote.hdfs import RemoteHDFS
6-
from dvc.remote.local import RemoteLOCAL
7-
from dvc.remote.s3 import RemoteS3
8-
from dvc.remote.ssh import RemoteSSH
97
from dvc.remote.http import RemoteHTTP
108
from dvc.remote.https import RemoteHTTPS
9+
from dvc.remote.local import RemoteLOCAL
1110
from dvc.remote.oss import RemoteOSS
11+
from dvc.remote.s3 import RemoteS3
12+
from dvc.remote.ssh import RemoteSSH
1213

1314

1415
REMOTES = [
1516
RemoteAZURE,
17+
RemoteGDrive,
1618
RemoteGS,
1719
RemoteHDFS,
1820
RemoteHTTP,
1921
RemoteHTTPS,
22+
RemoteOSS,
2023
RemoteS3,
2124
RemoteSSH,
22-
RemoteOSS,
2325
# NOTE: RemoteLOCAL is the default
2426
]
2527

dvc/remote/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def download(
415415
from_infos,
416416
to_infos,
417417
no_progress_bar=False,
418-
name=None,
418+
names=None,
419419
resume=False,
420420
):
421421
raise RemoteActionNotImplemented("download", self.scheme)

0 commit comments

Comments
 (0)