-
-
Notifications
You must be signed in to change notification settings - Fork 573
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
Data directory should not be created on import #2019
Conversation
Hello @nitinkgp23! Thanks for updating the PR.
Comment last updated on March 21, 2017 at 16:04 Hours UTC |
Hey @Cadair, Can you please review the PR? |
Thanks for the PR! It's not only the sample data that uses the |
Yeah, I thought so. But, I checked it by directly downloading a file using jsoc client, after deleting the download directory at $HOME and the directory got automatically created and download was successful. |
It seems that some of the travis errors here are due to the directory not existing: https://travis-ci.org/sunpy/sunpy/jobs/208183122#L2488 Seems that it's in lightcurve? |
Ahh :( . So what's the best way out? Make a through search, and add the command of creating directory everywhere? Or, is there any shortcut, that I am missing? |
I would make a function in |
Okkay, I will make the changes :). Thanks. |
sunpy/instr/goes.py
Outdated
@@ -88,6 +89,7 @@ | |||
GOES_REMOTE_PATH = "http://{0}/ssw/gen/idl/synoptic/goes/".format(HOST) | |||
# Define location where data files should be downloaded to. | |||
DATA_PATH = config.get("downloads", "download_dir") | |||
create_download_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.
There is no need for two function calls here (get default directory and create it) this can be done in one call.
Also, this is still to early to create the directory. We only want to be creating it upon use, so if the functions are called with the default data dir we should make the directory then, rather than on import of this submodule.
To give you an example for this file you want to replace every occurrence of DATA_PATH
with sunpy.config.get_and_create_download_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.
This is the same for the other files as well.
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.
@Cadair I will modify other files too, if this is okay.
@@ -377,7 +374,7 @@ def _goes_chianti_tem(longflux, shortflux, satellite=8, | |||
|
|||
""" | |||
if not download_dir: | |||
download_dir = DATA_PATH | |||
download_dir = get_and_create_download_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.
Is this what we want?
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.
looks good!
@@ -76,6 +76,10 @@ def download_sample_data(progress=True, overwrite=True, timeout=None): | |||
------- | |||
None | |||
""" | |||
# Creating the directory for sample files to be downloaded |
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.
This can use the function.
also @nitinkgp23 if you merge master in or rebase the build should pass. |
@nabobalis Your first backport. |
Fixes issue2018
@kbj Will this fix your concerns? |
Fixes #2018
Before:
Upon doing
import sunpy
, a directory was created on/home/sunpy/data
, irrespective of whether we download data or not.After:
Upon doing
import sunpy
, the path is saved in the config file but the directory is not created. The directory is first created when we try downloading any data.