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

Append filename to destination if source is file #121

Merged
merged 10 commits into from
Feb 15, 2021

Conversation

genziano
Copy link
Contributor

@genziano genziano commented Feb 13, 2021

Fixes #74.

The CloudPath.download_to method adds the filename to the destination path if the cloud source is a file and the destination is a folder.

@genziano genziano marked this pull request as draft February 13, 2021 10:14
@jayqi
Copy link
Member

jayqi commented Feb 14, 2021

The change itself looks good! For the tests, I would recommend adding a new test instead of adding to test_file_read_writes. test_file_read_writes is a bit big and unwieldy, and having a more targeted unit test is probably better for maintainability anyways.

@jayqi
Copy link
Member

jayqi commented Feb 14, 2021

By the way, if you write something like "Fixes #74" in your PR description, GitHub has special functionality to link this PR to that issue and will close the issue automatically when the PR is merged. If it's working, you'd see that the keyword has a dotted underline. The mechanics and triggering keywords are documented here:

https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword

@genziano
Copy link
Contributor Author

By the way, if you write something like "Fixes #74" in your PR description, GitHub has special functionality to link this PR to that issue and will close the issue automatically when the PR is merged. If it's working, you'd see that the keyword has a dotted underline. The mechanics and triggering keywords are documented here:

https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword

Nice one!

@genziano
Copy link
Contributor Author

The change itself looks good! For the tests, I would recommend adding a new test instead of adding to test_file_read_writes. test_file_read_writes is a bit big and unwieldy, and having a more targeted unit test is probably better for maintainability anyways.

Good idea, I will separate that test. What do you think about having a class for testing, say TestCloudPath, where its methods implement tests for CloudPath methods?

@jayqi
Copy link
Member

jayqi commented Feb 14, 2021

What do you think about having a class for testing, say TestCloudPath, where its methods implement tests for CloudPath methods?

For this project, we're using test modules (e.g., test_cloudpath_file_io) and descriptive test names for organizing our tests. From that regard, I don't think it's necessary to add test classes as another layer of organization. For parameterizing tests for the different types of cloud paths and handling setup/teardown, we're using fixtures—specifically the rig fixture. You can see how the rigs are set up on conftest.py. So, unless you have a compelling idea for how a test class could further simplify our testing code, I'm not in favor of using test classes.

@genziano
Copy link
Contributor Author

What do you think about having a class for testing, say TestCloudPath, where its methods implement tests for CloudPath methods?

For this project, we're using test modules (e.g., test_cloudpath_file_io) and descriptive test names for organizing our tests. From that regard, I don't think it's necessary to add test classes as another layer of organization. For parameterizing tests for the different types of cloud paths and handling setup/teardown, we're using fixtures—specifically the rig fixture. You can see how the rigs are set up on conftest.py. So, unless you have a compelling idea for how a test class could further simplify our testing code, I'm not in favor of using test classes.

I never used test classes myself, but I was curious to hear if you thought it could be a good idea.

I see that most live tests are failing, does it have anything to do with the fact that this is a PR from a forked repository, for which there are no credentials?

Copy link
Member

@jayqi jayqi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few requested revisions.

I see that most live tests are failing, does it have anything to do with the fact that this is a PR from a forked repository, for which there are no credentials?

Yes, that's the case. Sorry for the inconvenience—I'll think about how we can make this process better. What we did for a previous PR was for one of us (the maintainers) to copy the fork's branch over to the main repository so that the CI can run with the necessary credentials. For now, let's continue development in this PR until we're happy with the changes (using the CI steps before the live tests as a quality check). When it's ready, we can do the same approach of copying the branch to the main repo.

cloudpathlib/cloudpath.py Outdated Show resolved Hide resolved
tests/test_cloudpath_file_io.py Outdated Show resolved Hide resolved
tests/test_cloudpath_file_io.py Outdated Show resolved Hide resolved
@genziano genziano requested a review from jayqi February 15, 2021 09:25
@jayqi jayqi changed the base branch from master to 74-download-to-dir February 15, 2021 18:13
@jayqi jayqi marked this pull request as ready for review February 15, 2021 18:14
@jayqi jayqi merged commit b0a8953 into drivendataorg:74-download-to-dir Feb 15, 2021
jayqi added a commit that referenced this pull request Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CloudPath.download_to doesn't work if src is file and destination is directory
2 participants