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

KeyError: 'MANDATORY' #1

Open
gokhannY opened this issue Nov 21, 2024 · 5 comments
Open

KeyError: 'MANDATORY' #1

gokhannY opened this issue Nov 21, 2024 · 5 comments

Comments

@gokhannY
Copy link

Hey there,

I just wanted to try your code and got an error. I did not change any config file except that

change import PRF to import prf

in the "TESS-cont.py" file. When I tried to use, got an error as;

@|---------------------@|
        TESS-cont       
@|---------------------@|

Traceback (most recent call last):
  File "/home/gokhan/Downloads/TESS-cont.py", line 84, in <module>
    MANDATORY = config_object['MANDATORY']
  File "/usr/lib/python3.10/configparser.py", line 965, in __getitem__
    raise KeyError(key)
KeyError: 'MANDATORY'

All I did was as you suggested;

python TESS-cont.py TOI-5005_S65.ini

Both files, "TESS-cont.py" and "TOI-5005_S65.ini" are in the same directory.
What might be the problem?

@gokhannY
Copy link
Author

gokhannY commented Nov 21, 2024

Oops, my bad. I have just checked the TESS-cont.py. config file should be in the config directory.
Fixed now.

But the problem is now with the PRF module, which is installed but cannot call it since prf =/= PRF. Did you use any specific module for "PRF" ?

I tried reinstallation via pip as in pip3 install PRF but it keeps installing prf not PRF. Any suggestions?

@castro-gzlz
Copy link
Owner

Hi @gokhannY !

Exactly, the config.ini file needs to be inside the config directory.

Regarding the PRF/prf issue, it should be written in capital letters since it imports the module PRF (i.e., the PRF folder) inside the TESS-cont repository.

Could you try simply importing 'PRF' (without installing anything) and tell me if the problem is solved?

@gokhannY
Copy link
Author

Hey @castro-gzlz,

It works like a charm. I guess I did something wrong while placing PRF directory at first. Now there is no problem.

A quick suggestion;

I just used your code for a different star, but since there was no specific output directory for that star, I had to do a reanalysis since I needed to create one for manually. I guess you can add some lines to your code that if there is no output for such a directory, it should create one automatically.

@castro-gzlz
Copy link
Owner

Hi @gokhannY,

I'm glad you solved it :)

Thanks a lot for your suggestion! But it should already be implemented (I'm a bit surprised it did not worked for you):

#@|############################
#@|we create the output folder
#@|############################
try:
    os.mkdir('output/'+target_name)
except:
    pass

The user can define target_name as an optional argument. Alternatively, TESS-cont will assign the target mandatory argument.

Please let me know if you still find problems with the automatic generation of the output folders, and do not hesitate to make any other suggestions and/or pull requests. TESS-cont is open to contributors!

@gokhannY
Copy link
Author

gokhannY commented Nov 21, 2024

I believe the problem occurs if there is no 'output' folder. That would not be a problem if one downloads the repository as a whole instead of downloading files one by one, as I did previously. :)

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