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

Custom file name for file download #891

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

nkorinek
Copy link
Member

Added the argument file_name that can be used with custom url downloads in earthpy.data.get_data(). Allows users to change the name of the final file downloaded. Can't be used with key downloads.

@codecov
Copy link

codecov bot commented Jul 13, 2023

Codecov Report

Merging #891 (4ff96db) into main (b625aae) will decrease coverage by 0.90%.
The diff coverage is 53.84%.

@@            Coverage Diff             @@
##             main     #891      +/-   ##
==========================================
- Coverage   93.91%   93.01%   -0.90%     
==========================================
  Files          26       26              
  Lines        1708     1746      +38     
==========================================
+ Hits         1604     1624      +20     
- Misses        104      122      +18     
Flag Coverage Δ
unittests 93.01% <53.84%> (-0.90%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
earthpy/io.py 50.00% <30.00%> (-2.75%) ⬇️
earthpy/tests/test_io.py 72.09% <62.06%> (-2.04%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@nkorinek
Copy link
Member Author

@eculler if you can check this out and see if it does what you expect it too that would be appreciated!

@nkorinek nkorinek requested a review from eculler July 14, 2023 02:46
@eculler
Copy link
Contributor

eculler commented Aug 21, 2023

This looks good to me! I will try running it with one of our NCEI downloads, too.

@nkorinek
Copy link
Member Author

@eculler let me know the results of that!

@eculler
Copy link
Contributor

eculler commented Aug 22, 2023

Ok @nkorinek , so this looks like the design is what I was looking for, but currently the http parameters remain in the filename (the base file name is what I specified.):

>>> import earthpy as et
>>> et.data.get_data(url="https://www.ncei.noaa.gov/access/monitoring/climate-at-a-glance/city/time-series/USW00013876/tmax/12/1/1895-2023.csv?base_prd=true&begbaseyear=1991&endbaseyear=2020", file_name='birmingham_max_temperature')
Downloading from https://www.ncei.noaa.gov/access/monitoring/climate-at-a-glance/city/time-series/USW00013876/tmax/12/1/1895-2023.csv?base_prd=true&begbaseyear=1991&endbaseyear=2020
'/Users/elsa/earth-analytics/data/earthpy-downloads/birmingham_max_temperature.csv?base_prd=true&begbaseyear=1991&endbaseyear=2020'
>>> 

Copy link
Contributor

@eculler eculler left a comment

Choose a reason for hiding this comment

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

This feature isn't working quite right - it still tacks on http parameters to the file name. See my comment on the Conversation thread.

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.

2 participants