Skip to content

Catch spherex read errors#269

Merged
troyraen merged 9 commits intomainfrom
raen/issues/165/spherex-bad-gateway
Mar 6, 2026
Merged

Catch spherex read errors#269
troyraen merged 9 commits intomainfrom
raen/issues/165/spherex-bad-gateway

Conversation

@troyraen
Copy link
Copy Markdown
Contributor

@troyraen troyraen commented Feb 27, 2026

Closes #165

For SPHEREx Intro and PSF notebooks, this catches the three errors seen in #165 and retries a few times. The notebooks can't continue without the data, so need to retry rather than just pass.

For SPHEREx Cutouts notebook, this adds a wrapper function that catches the three errors seen in #165 and just passes. The notebook gets a bunch of cutouts, so passing a few should be fine. This notebook also sometimes fails later on after cutouts have been retrieved with a TypeError: 'NoneType' object is not iterable (seen in builds linked from #165 but weren't copied directly into the issue). I'm pretty sure that's happening for the same reasons, it's just that the errors are getting lost in the background during the parallel processing. In any case, this PR handles them by dropping Nones from the table.

These changes aren't guaranteed to make the notebooks run if, for example, the service is having an extra hard time. We can increase the number of retries and/or add more error codes to catch in the future if needed.

@troyraen troyraen added bug Something isn't working content: spherex Content related issues/PRs for notebooks with SPHEREx relevance labels Feb 27, 2026
@troyraen troyraen force-pushed the raen/issues/165/spherex-bad-gateway branch from 77e3238 to 9d3bbe1 Compare March 3, 2026 00:11
@troyraen troyraen marked this pull request as ready for review March 3, 2026 01:31
@troyraen troyraen requested review from bsipocz and jkrick March 3, 2026 01:31
Copy link
Copy Markdown
Contributor

@jkrick jkrick left a comment

Choose a reason for hiding this comment

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

Thanks for putting this in. The only comment I have is to please update the dates at the bottom of each file touched.

Copy link
Copy Markdown
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

Minor code cleanup suggestion, otherwise looks good to go.

Comment thread tutorials/spherex/spherex_cutouts.md Outdated
print("Time to create cutouts in serial mode: {:2.2f} minutes.".format((time.time() - t1) / 60))

# Drop rows that failed to download.
results_table_serial = results_table_serial[[r["hdus"] is not None for r in results_table_serial]]
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.

It maybe useful to keep a tally for the unsuccessful ones, so it's readily available for a retry? (which is not part of the notebook of course)

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.

good idea

Comment thread tutorials/spherex/spherex_cutouts.md Outdated
Comment thread tutorials/spherex/spherex_cutouts.md Outdated
## About this notebook

**Updated:** 24 October 2025
**Updated:** 5 March 2026
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.

Thanks!

Getting this done automatically with a plugin is on my mind.

@troyraen troyraen merged commit 071a25e into main Mar 6, 2026
8 checks passed
@troyraen troyraen deleted the raen/issues/165/spherex-bad-gateway branch March 6, 2026 01:36
@troyraen troyraen linked an issue Mar 6, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working content: spherex Content related issues/PRs for notebooks with SPHEREx relevance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SPHEREx Bad Gateway error Failure to retrieve data for SPHEREx cutouts

3 participants