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

Let the user define the decompressed file name. #203

Merged
merged 17 commits into from
Oct 7, 2020

Conversation

horta
Copy link
Contributor

@horta horta commented Aug 5, 2020

I don't like the decompressed file name as it is. I would like to define my own custom naming.
In particular, I want files like "foo.csv.gz" to become "foo.csv" when decompressed.

The changes I'm proposing is backward compatible and are minimal, in my opinion.

Let me know what you think and thanks a lot for this amazing package!

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 and the base __init__.py file for the package.
  • Write detailed docstrings for all functions/classes/methods. It often helps to design better code if you write the docstrings first.
  • If adding new functionality, add an example to the docstring, gallery, and/or tutorials.
  • Add your full name, affiliation, and ORCID (optional) to the AUTHORS.md file (if you haven't already) in case you'd like to be listed as an author on the Zenodo archive of the next release.

@welcome
Copy link

welcome bot commented Aug 5, 2020

💖 Thanks for opening your first pull request! 💖

Please make sure you read the following:

  • Authorship Guidelines: Our rules for giving you credit for your contributions, including authorship on publications and Zenodo archives.
  • Contributing Guide: What the review process is like and our infrastructure for testing and documentation.
  • Code of Conduct: How we expect people to interact in our projects.

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! ⭐

Copy link
Member

@santisoler santisoler left a comment

Choose a reason for hiding this comment

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

Hi @horta!
Thanks for the contribution.

I understand your discomfort with the default uncompressed file names.
Nevertheless I'm a little bit worried about possible unwanted scenarios that might appear by letting users to change the uncompressed filenames.

I think the main reason behind hard-coding the default uncompressed filename as fname + ".decomp" was to have unique filenames for the uncompressed files.
So letting users to change that might generate situations where files are overwritten or redownloaded, just because the would share the same filename.

Nevertheless maybe I'm being overcautious and such situations would be rare and easy to fix. And taking into account that renaming files won't be the default behavior of Decompress, maybe it would be fine to incorporate this feature.

I would like to hear @leouieda opinion on this, but it's very likely we would need to wait until mid September.

I leave some small changes on your code. Feel free to apply them.

doc/usage.rst Outdated Show resolved Hide resolved
doc/usage.rst Outdated Show resolved Hide resolved
pooch/processors.py Outdated Show resolved Hide resolved
pooch/tests/test_processors.py Outdated Show resolved Hide resolved
pooch/tests/test_processors.py Outdated Show resolved Hide resolved
pooch/tests/test_processors.py Outdated Show resolved Hide resolved
pooch/tests/test_processors.py Outdated Show resolved Hide resolved
pooch/tests/test_processors.py Outdated Show resolved Hide resolved
horta and others added 8 commits August 25, 2020 11:11
Co-authored-by: Santiago Soler <santiago.r.soler@gmail.com>
Co-authored-by: Santiago Soler <santiago.r.soler@gmail.com>
Co-authored-by: Santiago Soler <santiago.r.soler@gmail.com>
Co-authored-by: Santiago Soler <santiago.r.soler@gmail.com>
Co-authored-by: Santiago Soler <santiago.r.soler@gmail.com>
Co-authored-by: Santiago Soler <santiago.r.soler@gmail.com>
Co-authored-by: Santiago Soler <santiago.r.soler@gmail.com>
Co-authored-by: Santiago Soler <santiago.r.soler@gmail.com>
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.

@horta thanks for implementing this! I confess that I have the same fears as @santisoler but I agree that we might be overly paranoid. There is also nothing to guarantee that the .decomp file doesn’t conflict as well. I’m in favor of adding this to Decompress.

We should also open an issue to add checks to the processors if the file already exists and the action is “download” (meaning that the file shouldn’t be there already). This is a good indicator of a conflicting file name and we should issue a warning or exception.

A few comments on this PR:

  1. The order of authors is alphabetical by last name, so you’d come right after Mathias :-)
  2. Why not just pass in the desired file name instead of a callback? It would be a lot simpler (to code and test) and likely cover all desired use cases. Remember “simple is better than complex”.
  3. We recently completely restructured the docs (Refactor the documentation into separate pages #202) so you have a conflict there. This could probably go in doc/processors.rst instead.

@leouieda
Copy link
Member

Hi @horta I'm just getting back from holidays and trying to catch up on OSS work. Any updates on this? Let me know if you need/want any help moving this forward.

@leouieda leouieda added this to the 1.3.0 milestone Sep 10, 2020
@horta
Copy link
Contributor Author

horta commented Sep 10, 2020

Lets move forward. Is that looking better? I agree with the simplicity of giving a string instead of a callback.

Move the new documentation to the appropriate page.
Add the warning about overwriting files and clarify that the name
shouldn't have the path.
@leouieda
Copy link
Member

leouieda commented Oct 6, 2020

@horta sorry for dropping this. This looks good! I merged in the latest changes from the master branch (basically moved the docs to docs/processors.rst instead of docs/usage.rst). I added a warning to the docs to be careful not to overwrite existing files. I also realized that we could merge the test with the previous one since they are pretty much the same code. If CIs pass, I'll happily merge this in 🙂

@leouieda leouieda merged commit 16ee864 into fatiando:master Oct 7, 2020
@welcome
Copy link

welcome bot commented Oct 7, 2020

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

If you would like to be added as a author on the Zenodo archive of the next release, make sure that you have added your full name, affiliation, and ORCID (optional) to the AUTHORS.md file of this repository.

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

leouieda commented Oct 7, 2020

@horta thank you for adding this new feature! Hope to see you around the project in the future as wel 🙂

@horta
Copy link
Contributor Author

horta commented Oct 7, 2020

Well done! Thanks!

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.

3 participants