labscript-suite-temp-2 / lyse

lyse is an analysis framework. It coordinates the running of python analysis scripts on experiment data as it becomes availiable, updating plots in real time.
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Configuration file not created if it does not exist #43

Closed philipstarkey closed 5 years ago

philipstarkey commented 5 years ago

Original report (archived issue) by Shaun Johnstone (Bitbucket: shjohnst, GitHub: shjohnst).


On a fresh install of the labscript suite on Windows, lyse thinks that its configuration file should be at C:\labscript_suite\userlib\app_saved_configs\example_experiment\lyse however this lyse folder does not exist (i.e. is not created by the installer). This results in the following message being printed to the lyse output on startup:

#!python

Loading default config file C:\labscript_suite\userlib\app_saved_configs\example_experiment\lyse\lyse.ini...
Could not load config file: WindowsError: [Error 3] The system cannot find the path specified: 'C:\\labscript_suite\\userlib\\app_saved_configs\\example_experiment\\lyse'

If you then click the "Save configuration" button in the File menu, the following traceback occurs:

#!python

Traceback (most recent call last):
  File "C:\labscript_suite\lyse\__main__.py", line 1969, in on_save_configuration_triggered
    self.save_configuration(self.last_save_config_file)
  File "C:\labscript_suite\lyse\__main__.py", line 2047, in save_configuration
    lyse_config = LabConfig(save_file)
  File "C:\labscript_suite\labscript_utils\labconfig.py", line 72, in __init__
    os.mkdir(os.path.dirname(self.config_path))
WindowsError: [Error 3] The system cannot find the path specified: 'C:\\labscript_suite\\userlib\\app_saved_configs\\example_experiment\\lyse'

Perhaps we should have lyse check if the file listed in the labconfig file exists, and if not, create it on startup? We probably should also have default app configurations created by the installer.

philipstarkey commented 5 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


If the file does not exist at startup lyse should not try to load it, it should just act as if it was not told to load a configuration.

And, upon saving, the issue is that mkdir() isn't recursive. Lyse is trying to make the directory, but the parent directory doesn't exist. Lyse needs a function like mkdir_p from the install script, which does create parent directories if they do not exist.

It's not a good solution to create default configurations because the filepath to them is specific to the experiment name, which may change at any time after installation. Apps should treat the lack of existence of a config file as 'do the default thing', and then create the folder hierarchy if necessary upon saving.

I'll deal with this!

philipstarkey commented 5 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


labscript_utils pull request #60 should fix both issues.

If you could let me know if it works, I will merge that pull request, stamp labscript_utils as version 2.9.1, and then add a hotfix to lyse to rely on that version.

Since you are locking down version numbers for the data submission for your paper, do you want lyse to be tagged with a new version number once it has the fix?

philipstarkey commented 5 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Should be fixed in commit 78eac759d0779386c66f623f6fba1cba7a4d7438, please reopen if there is still a problem.

philipstarkey commented 5 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).