Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Fixed:

Changed:

- [SpectrometerCalibration][extra.gui.jupyter.SpectrometerCalibration] no longer
saves loaded data to cache if `user_cache=False`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
saves loaded data to cache if `user_cache=False`.
saves loaded data to cache if `use_cache=False`.

- `extra.recipes` package renamed to `extra.applications`
- [XGM.pulse_energy()][extra.components.XGM.pulse_energy] will now insert NaNs
instead of zeros as a fill value for runs with a varying number of pulses
Expand Down
12 changes: 8 additions & 4 deletions src/extra/gui/jupyter/spectrometer_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ def __init__(
run (int): run number
source (tuple[str, str]): data source
image_data (np.ndarray): 2D array
use_cache (bool): try loading data from cache if True (default)
use_cache (bool): try loading data from cache if True (default).
Additionally, if it is set to False, loaded data will not be
cached.
Comment thread
fadybishara marked this conversation as resolved.
Outdated
"""
self.image_data = image_data
if image_data is None:
Expand Down Expand Up @@ -359,9 +361,11 @@ def _load_data(proposal: int, run: int, source: tuple[str, str], use_cache: bool
data = kd.xarray().squeeze()
mean_data = data.mean(dim="trainId")

# cache data for faster loading
cache_path.mkdir(mode=666, exist_ok=True, parents=True)
np.save(cache_path / fname, mean_data)
# cache data for faster loading unless use_cache=False
if use_cache:
cache_path.mkdir(mode=666, exist_ok=True, parents=True)
np.save(cache_path / fname, mean_data)
Comment on lines +365 to +366

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're changing this, I might be inclined to catch and ignore PermissionError here, so you don't need to pass use_cache=False for XMPL proposals.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean something like this? Inside the if use_cache or do you want to get rid of the use_cache=False option altogether?

Suggested change
cache_path.mkdir(mode=666, exist_ok=True, parents=True)
np.save(cache_path / fname, mean_data)
try:
cache_path.mkdir(mode=666, exist_ok=True, parents=True)
np.save(cache_path / fname, mean_data)
except PermissionError:
pass

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that's what I was thinking. I'd leave the use_cache option around as well - you might want to skip using the cache even if it works, e.g. if you suspect it might be outdated.


return mean_data

# Widget Initialization Methods
Expand Down