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

File not found error when calling exotethys the first time with new library #25

Open
jeroenbouwman opened this issue Aug 27, 2021 · 2 comments

Comments

@jeroenbouwman
Copy link

jeroenbouwman commented Aug 27, 2021

I have have run into the following error:

"/home/bouwman/anaconda3/envs/cascade/lib/python3.8/site-packages/exotethys/_database.py", line 114, in
"Phoenix_2018":Database('Phoenix_2018', date_to_update='200412', vital=True), "Atlas_2000":Database('Atlas_2000', date_to_update='200403', vital=True), "Stagger_2015":Database('Stagger_2015', date_to_update='201001', vital=True)
File "/home/bouwman/anaconda3/envs/cascade/lib/python3.8/site-packages/exotethys/_database.py", line 59, in init
shutil.rmtree(self.directory_path)
File "/home/bouwman/anaconda3/envs/cascade/lib/python3.8/shutil.py", line 709, in rmtree
onerror(os.lstat, path, sys.exc_info())
File "/home/bouwman/anaconda3/envs/cascade/lib/python3.8/shutil.py", line 707, in rmtree
orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: '/home/bouwman/.exotethys/Stagger_2015'

which indicates that if the data base module is called the first time with new stellar models available and the corresponding directory in the .exotethys user directory is not present, a file not found error is raised. The sub directory is created at some point as after the error is thrown the subdirectory is there and running the exotethys package a second time works. So it is not a big problem but probably means that is somebody runs the package for the very first time they will get an error for each model library.
At least I think that is the problem.

A related problem I run into is the following:

File "/home/bouwman/python_projects/CASCADe/cascade/exoplanet_tools/exoplanet_tools.py", line 1490, in define_exotethys_model
from exotethys import sail
File "/home/bouwman/anaconda3/envs/cascade/lib/python3.8/site-packages/exotethys/init.py", line 7, in
from .sail import *
File "/home/bouwman/anaconda3/envs/cascade/lib/python3.8/site-packages/exotethys/sail.py", line 25, in
from ._database import Database, databases, sys, urlretrieve, glob, time, shutil
File "/home/bouwman/anaconda3/envs/cascade/lib/python3.8/site-packages/exotethys/_database.py", line 114, in
"Phoenix_2018":Database('Phoenix_2018', date_to_update='200412', vital=True), "Atlas_2000":Database('Atlas_2000', date_to_update='200403', vital=True), "Stagger_2015":Database('Stagger_2015', date_to_update='201001', vital=True)
File "/home/bouwman/anaconda3/envs/cascade/lib/python3.8/site-packages/exotethys/_database.py", line 70, in init
os.mkdir(self.directory_path)
FileExistsError: [Errno 17] File exists: '/home/bouwman/.exotethys/Stagger_2015'

So where the code thinks there is no directory and tries to create it but it already exists. perhaps using os.makedirs with exist_ok=True could solve this issue.

@jeroenbouwman
Copy link
Author

As an additional note, I think the above problems occur if the library directories are empty i.e. you never downloaded a file for that specific stellar model library.

@gmorello
Copy link
Contributor

gmorello commented Aug 28, 2021

Hi again,

This error is more subtle.
When I import exotethys or a subpackage for the first time, it creates automatically all database folders, even if they are empty. I get no errors running an example.
If then I remove a database folder, e.g. Stagger_2015, and run sail.ldc_calculate('PATH/sail_example9.txt'), I get the error you noted. This is not solved even if I import exotethys again.
However closing and reopening the python session, then reimporting exotethys or a subpackage the deleted folder is recreated automatically and there is no error. Something similar should happen when using notebooks.
Not sure how this can be avoided.

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

No branches or pull requests

2 participants