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

Add FTP downloader #118

Merged
merged 42 commits into from Nov 19, 2019
Merged

Add FTP downloader #118

merged 42 commits into from Nov 19, 2019

Conversation

andersy005
Copy link
Member

@andersy005 andersy005 commented Nov 5, 2019

This PR adds support for downloading files over FTP. The downloader uses the ftplib module from the standard library.

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to the docstring, gallery, and/or tutorials.

@welcome
Copy link

welcome bot commented Nov 5, 2019

💖 Thanks for opening this pull request! 💖

Please make sure you read our contributing guidelines and abide by our code of conduct.

A few things to keep in mind:

  • Remember to run make format to make sure your code follows our style guide.
  • If you need help writing tests, take a look at the existing ones for inspiration. If you don't know where to start, let us know and we'll walk you through it.
  • All new features should be documented. It helps to write the docstrings for your functions/classes before writing the code. This will help you think about your code design and results in better code.
  • No matter what, we are really grateful that you put in the effort to do this! 🎉

pooch/utils.py Outdated Show resolved Hide resolved
pooch/utils.py Outdated Show resolved Hide resolved
@andersy005 andersy005 marked this pull request as ready for review November 6, 2019 04:35
@leouieda
Copy link
Member

leouieda commented Nov 7, 2019

@andersy005 thank you for your contribution! It's much appreciated!

Copy link
Member

@leouieda leouieda left a comment

Choose a reason for hiding this comment

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

@andersy005 thanks for taking the time to do this! I have some comments on the code and a few things that need to be done before merging.

My main concern here is with adding requests-ftp as a dependency. From their README:

Many corners have been cut in my rush to get this code finished. The most obvious problem is that this code does not have any tests. This is my highest priority for fixing.

Also, there haven't been any commits to the repository since 2017. So making this a mandatory dependency seems risky. Instead, I'd rather make it optional. This can be done the same way we do with tqdm. Then the user can decide if they want to take requests-ftp on as a dependency. Remember that if we add it to Pooch, projects relying on Pooch will automatically have it as a dependency too.

Would you mind making these changes? Let me know if you need any help or orientation.

pooch/utils.py Outdated Show resolved Hide resolved
pooch/utils.py Outdated Show resolved Hide resolved
pooch/utils.py Outdated Show resolved Hide resolved
pooch/utils.py Outdated Show resolved Hide resolved
pooch/utils.py Outdated Show resolved Hide resolved
pooch/core.py Outdated Show resolved Hide resolved
pooch/core.py Outdated Show resolved Hide resolved
pooch/core.py Outdated Show resolved Hide resolved
pooch/core.py Outdated Show resolved Hide resolved
pooch/core.py Outdated Show resolved Hide resolved
@andersy005
Copy link
Member Author

My main concern here is with adding requests-ftp as a dependency

@leouieda, I had the same concern as well. I think that it would be straightforward to use the FTP protocol client from the ftplib module instead of request-ftp. By using requests-ftp, I was just being lazy :)

Let me know what your thoughts on using the ftplib module are, and I will update the PR (and will address the changes you requested).

@andersy005 andersy005 changed the title Add FTP downloader (uses requests-ftp library) Add FTP downloader Nov 7, 2019
pooch/tests/test_core.py Outdated Show resolved Hide resolved
pooch/tests/test_core.py Outdated Show resolved Hide resolved
pooch/tests/test_core.py Outdated Show resolved Hide resolved
pooch/tests/test_core.py Outdated Show resolved Hide resolved
pooch/utils.py Outdated Show resolved Hide resolved
@leouieda
Copy link
Member

leouieda commented Nov 8, 2019

By using requests-ftp, I was just being lazy :)

I completely understand 😆

Let me know what your thoughts on using the ftplib module are, and I will update the PR (and will address the changes you requested).

That would actually be great! One less dependency and it will be easier to test. I hope it's not a lot of work for you. Too bad it messes up that nice class inheritance...

Copy link
Member

@leouieda leouieda left a comment

Choose a reason for hiding this comment

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

My speculation is that there is some strange network translation going on inside TravisCI and I don't know how to address it yet.

Yep, Travis doesn't allow FTP connections: https://docs.travis-ci.com/user/common-build-problems/?utm_source=blog&utm_medium=web&utm_campaign=ftp_blog#ftpsmtpother-protocol-do-not-work

I see you've disabled the FTP tests in Travis, which is what I would recommend. The coverage is reported as low because Azure wasn't uploading coverage for PRs. I just applied a fix to Azure and lets see if it works.

A few more comments on the code. Thanks for taking the time to rewrite things with ftplib! 👍

pooch/tests/test_core.py Outdated Show resolved Hide resolved
pooch/tests/test_core.py Outdated Show resolved Hide resolved
pooch/tests/test_core.py Outdated Show resolved Hide resolved
pooch/tests/test_core.py Outdated Show resolved Hide resolved
pooch/tests/test_core.py Show resolved Hide resolved
pooch/downloaders.py Outdated Show resolved Hide resolved
pooch/downloaders.py Outdated Show resolved Hide resolved
pooch/downloaders.py Outdated Show resolved Hide resolved
pooch/downloaders.py Outdated Show resolved Hide resolved
pooch/downloaders.py Show resolved Hide resolved
@leouieda
Copy link
Member

@andersy005 please merge in the changes from the master branch. You might have to reformat some docstrings following #123.

pooch/downloaders.py Outdated Show resolved Hide resolved
@leouieda
Copy link
Member

@andersy005 this is looking good! There are some conflicts because of #123 but I'll resolve those locally and push to your branch. Thanks for making all these changes! I really appreciate it.

Add the try: except: block to close connections and the output file in
case of exceptions. Use the same defaults for credentials as ftplib.
@leouieda
Copy link
Member

👋 @andersy005 I made a few modifications to the code:

  • Added a progress bar test
  • Refactored the code to simplify it a bit and add some try: ... finally: blocks
  • Added a section to the usage docs

Please see what you think and if you're OK with the changes, I'd be happy to merge this in 🙂 Feel free to make any changes you find necessary.

@andersy005
Copy link
Member Author

@leouieda,

Thank you for your help and review! Glad to see this brought to completion. I took a look at the changes you made, and everything looks good to me! Feel free to merge this at your earliest convenience!

@leouieda leouieda merged commit 870320d into fatiando:master Nov 19, 2019
@welcome
Copy link

welcome bot commented Nov 19, 2019

🎉🎉🎉 Congrats on merging your first pull request and welcome to the team! 🎉🎉🎉

Please open a new pull request to add yourself to the AUTHORS.md file. We hope that this was a good experience for you. Let us know if there is any way that the contributing process could be improved.

@leouieda
Copy link
Member

Thank you for your contribution @andersy005! Please add yourself to our AUTHORS.md file.

We're also in the midst of writing a paper for JOSS (#112) and with this contribution you are eligible for authorship (see the criteria in #112). It would be a pleasure to have you on board!

@andersy005
Copy link
Member Author

Please add yourself to our AUTHORS.md file.

Done in #125

We're also in the midst of writing a paper for JOSS (#112) and with this contribution you are eligible for authorship (see the criteria in #112). It would be a pleasure to have you on board!

Awesome :) Thank you! See #112 (comment)

@andersy005 andersy005 deleted the ftp-downloader branch November 19, 2019 16:29
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.

None yet

3 participants