-
Notifications
You must be signed in to change notification settings - Fork 1.2k
gdrive: add open #3916
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
gdrive: add open #3916
Conversation
@@ -393,6 +396,23 @@ def _gdrive_download_file( | |||
) as pbar: | |||
gdrive_file.GetContentFile(to_file, callback=pbar.update_to) | |||
|
|||
@contextmanager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to double check - do we properly pass close
down to the PyDrive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pydrive2 doesn't expose any close()
methods anywhere. I think the underlying httplib2
closes connections before raising errors; so no special handling needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should close if just return
from the block ... we should check the logic carefully here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upstream issue: iterative/PyDrive2#44
hmm tests failing with
|
Codecov Report
@@ Coverage Diff @@
## master #3916 +/- ##
==========================================
- Coverage 92.32% 92.13% -0.19%
==========================================
Files 160 161 +1
Lines 11107 11121 +14
==========================================
- Hits 10254 10246 -8
- Misses 853 875 +22
Continue to review full report at Codecov.
|
tests/remotes.py
Outdated
@@ -141,10 +142,13 @@ class GDrive: | |||
def should_test(): | |||
return os.getenv(GDriveRemote.GDRIVE_CREDENTIALS_DATA) is not None | |||
|
|||
def get_url(self): | |||
if not getattr(self, "_remote_url", None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing this will break TestGDriveRemoteCLI
most likely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in general I believe we should probably introduce caching of get_url in for other remotes as well - it is strange to return different values within one test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shcheklein It actually shouldn't, because other remotes do that too and just reuse the results. Need to check maybe there is something wrong or special about gdrive...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@efiop I think they just call it once, in case of GDrive it just happened that we need it in multiple places. And in general, it's def not a good and safe interface - this value should be cached one way or another and stay the same during the test.
|
||
remote_params = [S3, GCP, Azure, OSS, SSH, HDFS] | ||
remote_params = [S3, GCP, Azure, GDrive, OSS, SSH, HDFS] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a lot of tests for functions besides open here - do we expect all of them to pass? we'll need to implement more stuff then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shcheklein All the tests should work, there is nothing new required from GdriveRemotes. There might be some issues with Gdrive itself though (creds or something), that differentiates it from other remotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even it works out of the box, some things do not make much sense - e.g. what will dvc.api.url
return for the object? Some URL that no tool (except DVC) can work with?
Re credentials - should be fine (we use an env var to set them, so I would expect external repo to pick it up as well). As I mentioned though, GDrive remote requires some special setup (e.g. it does not create a directory for you).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shcheklein is this comment outdated since rebasing on master? Or does tests/remotes.py
still need updating?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@casperdcl Could do that, sure. Will require some work to make it do that without first passing it a dvc instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well the only other way I see is to rework the current pytest fixture (currently it hides the GDrive
object so there's no way to call create_dir
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@casperdcl Both work. Choose the easiest one, we'll be revisiting this later anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried a simple change along the same lines as setup_remote
but still failing with the same credentials error https://travis-ci.com/github/iterative/dvc/jobs/348374056#L7952
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@casperdcl does it work locally with your creds?
This makes `GDrive.get_url` behaviour consistent with the rest of the test remotes. Related to #3916
This makes `GDrive.get_url` behaviour consistent with the rest of the test remotes. Related to #3916
Adjusted GDrive to have a |
Fixes iterative#3408 Related iterative#2865 Fixes iterative#3897
This reverts commit fd33326.
@@ -72,6 +122,7 @@ def test_open(remote_url, tmp_dir, dvc): | |||
@pytest.mark.parametrize("remote_url", all_remote_params, indirect=True) | |||
def test_open_external(remote_url, erepo_dir, setup_remote): | |||
setup_remote(erepo_dir.dvc, url=remote_url) | |||
ensure_dir_scm(erepo_dir.dvc, remote_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@efiop I've added ensure_dir_scm
here based off setup_remote
.
- Using
ensure_dir
instead ofensure_dir_scm
, there's
ERROR: configuration error - config file error: remote 'upstream' doesn't exists.
- Using
run_dvc("remote", "add", ...)
results in
ERROR: configuration error - config file error: remote 'upstream' already exists. Use
-f|--forceto overwrite it.
Thanks @casperdcl ! For the record: s3 test is failing for unrelated reasons. |
@casperdcl Please don't forget about the docs 🙂 |
open()
forgdrive
remotedepends add len(MediaIoReadable) PyDrive2#40master