momentoscope / hextof-processor

Code for preprocessing data from the HEXTOF instrument at FLASH, DESY in Hamburg (DE)
https://hextof-processor.readthedocs.io/en/latest/
GNU General Public License v3.0
7 stars 4 forks source link

Error reading settings files when package installed via pypi #72

Closed zain-sohail closed 3 years ago

zain-sohail commented 3 years ago

The DldProcessor Class assumes a root folder of root_folder = os.path.dirname(os.path.dirname(processor.__file__))

However, if one installs the package in a certain environment, this would lead to it searching in an incorrect folder. Perhaps this should be user customisable in that case? or is there already a way?

steinnymir commented 3 years ago

The "root_folder" defined as it is there, should work anywhere you install your package, as it looks for the imported processor and goes up one folder. It will be easy to see if this breaks however, as the whole settings (required for almost every step) depends on it...

zain-sohail commented 3 years ago

If I look in my conda env location cd .conda/envs/<MY_ENV>/lib/python3.7/site-packages/processor I am listed these files/dirs cscripts DldFlashDataframeCreator.py DldProcessor.py __init__.py legacy pah.py __pycache__ utilities

There is no settings folder, which explains why I get the exception Exception: Failed loading main settings!

We're only packaging what's in the processor folder. So there needs to be another way to search for settings files which exist on user computer.

steinnymir commented 3 years ago

Packaging only what is in the processor folder will not work. The way it works now, is that there are settings stored in the settings folder, and these are necessary, but I agree not exactly "package" material.

Do you have a SETTINGS.ini somewhere? it usually appears in the root folder of the repo, but I don't know what happens with the packaged version... If also this is not possible, we might need to restructure the whole settings system.

zain-sohail commented 3 years ago

Packaging only what is in the processor folder will not work. The way it works now, is that there are settings stored in the settings folder, and these are necessary, but I agree not exactly "package" material.

Do you have a SETTINGS.ini somewhere? it usually appears in the root folder of the repo, but I don't know what happens with the packaged version... If also this is not possible, we might need to restructure the whole settings system.

Yes I understand but since every folder becomes it's own package (e.g. import processor), then one would have a settings package, which doesn't make sense to have as package.

Settings.ini is not initialized when I create an object of the class. I am guessing that's due to the directory being restricted. Perhaps we could allow the user to define a settings folder path for the pip installed hextof-processor

zain-sohail commented 3 years ago

We can come back to this once we want to package again.