Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle GS progress for push & pull #2810

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions dvc/remote/gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import logging
from datetime import timedelta
from functools import wraps
import io

from funcy import cached_property

from dvc.config import Config
from dvc.exceptions import DvcException
from dvc.path_info import CloudURLInfo
from dvc.progress import Tqdm
from dvc.remote.base import RemoteBASE
from dvc.scheme import Schemes
from dvc.utils.compat import FileNotFoundError # skipcq: PYL-W0622
Expand Down Expand Up @@ -46,9 +48,20 @@ def wrapper(*args, **kwargs):


@dynamic_chunk_size
def _upload_to_bucket(bucket, from_file, to_info, **kwargs):
blob = bucket.blob(to_info.path, **kwargs)
blob.upload_from_filename(from_file)
def _upload_to_bucket(bucket, from_file, to_info, chunk_size=None, **kwargs):
blob = bucket.blob(to_info.path, chunk_size=chunk_size, **kwargs)
with Tqdm() as pbar:
with io.open(from_file, mode="rb", buffering=chunk_size or -1) as fd:
raw_read = fd.read

def read(self, size=chunk_size):
res = raw_read(size)
if res:
pbar.update(len(res))
return res

fd.read = read
blob.upload_from_file(fd)


class RemoteGS(RemoteBASE):
Expand Down