MaterialsGalaxy / larch-tools

Galaxy tool wrappers for Larch analysis tools for X-ray spectroscopy
MIT License
2 stars 0 forks source link

Error early when selected path does not exist #74

Closed patrick-austin closed 3 weeks ago

patrick-austin commented 1 month ago

Currently this results in:

Traceback (most recent call last):
  File "/home/kez92691/larch-tools/larch_artemis/larch_artemis.py", line 348, in <module>
    main(prj_file, gds_file, sp_file, fit_vars, plot_graph)
  File "/home/kez92691/larch-tools/larch_artemis/larch_artemis.py", line 211, in main
    dset, out = run_fit(data_group, gds, selected_paths, fit_vars)
  File "/home/kez92691/larch-tools/larch_artemis/larch_artemis.py", line 182, in run_fit
    dset = FeffitDataSet(
  File "/home/kez92691/muon-galaxy/.venv/lib/python3.8/site-packages/larch/xafs/feffit.py", line 250, in __init__
    self.paths = {path.label: copy(path) for path in paths}
  File "/home/kez92691/muon-galaxy/.venv/lib/python3.8/site-packages/larch/xafs/feffit.py", line 250, in <dictcomp>
    self.paths = {path.label: copy(path) for path in paths}
  File "/usr/local/lib/python3.8/copy.py", line 84, in copy
    return copier(x)
  File "/home/kez92691/muon-galaxy/.venv/lib/python3.8/site-packages/larch/xafs/feffdat.py", line 335, in __copy__
    newpath.__setstate__(self.__getstate__())
  File "/home/kez92691/muon-galaxy/.venv/lib/python3.8/site-packages/larch/xafs/feffdat.py", line 285, in __getstate__
    _feffdat_state = self._feffdat.__getstate__()
AttributeError: 'NoneType' object has no attribute '__getstate__'

When iterating over the rows in the parsed selected paths, we should check these paths against the results of listing the local directory and error if that path cannot be found, preventing the above, opaque traceback.