Skip to content

Add HST bundle preview generation scripts and configuration files - #250

Draft
juzen2003 wants to merge 1 commit into
mainfrom
test_picmaker_for_hst_pipeline
Draft

Add HST bundle preview generation scripts and configuration files#250
juzen2003 wants to merge 1 commit into
mainfrom
test_picmaker_for_hst_pipeline

Conversation

@juzen2003

@juzen2003 juzen2003 commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator
  • Introduced hst_bundle_previews.sh for creating preview images from PDS4 HST bundle browse collections.
  • Added hst_bundle_browse_map.txt and hst_bundle_fits_map.txt to define browse and FITS fallback collection policies.
  • Included hst_bundle_fits_previews.txt for FITS image processing options.
  • Established structure for handling browse and FITS data collections in the preview generation process.

Here is the current logic flow and some questions:

  • Check if browse directory (browse files, jpg, jpeg, png from MAST) exists
    • If yes (like PDS3 COCIRS_1xxx or COISS_3xxx) , we use picmaker to resize the files in the browse directory, and put it in another collection directory, like "browse_previews_*" or some other name
      - Question:
      - for the bundle (like 16167) that has multiple browse directories (browse_wfc3_{raw,flt,flc,drz,drc}), do we apply picmaker to all of them? Or do we apply only to drz like PDS3 HSTI (raw tiff or drz jpeg, and since we only download jpg, jpeg, and png from MAST for browse, we won't have tiff file, we apply drz in this case)?
      - for the case like 13736, it has browse_stis_x1d, but it also has data_stis_x2d, should we apply picmaker on fits in data_stis_x2d instead of applying picmaker to resize files in browse_stis_x1d (becasue PDS3 HSTO apply picmaker on x2d jpeg)?
    • If no, we use picmaker on fits files in data collection, and put it in another collection directory.

Question:

  • Is the above flow correct? Or should we just apply picmaker on fits files in data collection?

* Introduced hst_bundle_previews.sh for creating preview images from PDS4 HST bundle browse collections.
* Added hst_bundle_browse_map.txt and hst_bundle_fits_map.txt to define browse and FITS fallback collection policies.
* Included hst_bundle_fits_previews.txt for FITS image processing options.
* Established structure for handling browse and FITS data collections in the preview generation process.
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds a new HST preview-generation script (hst_bundle_previews.sh) along with supporting text configuration files: browse and FITS fallback mapping files defining per-collection include/skip policies and strip suffixes, and picmaker option files specifying output sizes for thumbnail, small, medium, and full previews.

Changes

HST Bundle Previews

Layer / File(s) Summary
Browse and FITS fallback mapping definitions
previews/HST/hst_bundle_browse_map.txt, previews/HST/hst_bundle_fits_map.txt
Defines per-collection include/skip policies and strip suffixes for browse directories (WFC3, STIS, GHRS, FOS), plus a FITS fallback mapping entry for bundle hst_14930.
Picmaker output size options
previews/HST/hst_bundle_fits_previews.txt, previews/HST/hst_bundle_previews.txt
Defines picmaker CLI argument sets for _thumb, _small, _med, and _full output suffixes with frame sizes and percentile/JPEG settings.
Script setup and path resolution
previews/HST/hst_bundle_previews.sh
Adds script documentation, symlink-aware path resolution, working directory setup, and resolve_path/resolve_deliverable/preview_outpath helpers.
Map parsing helpers
previews/HST/hst_bundle_previews.sh
Adds awk-based helpers to read policy and strip-suffix values from the browse and FITS map files, plus bundle_id_from_deliverable.
FITS fallback and main preview loop
previews/HST/hst_bundle_previews.sh
Adds process_fits_fallback and the main control flow that iterates deliverables, processes browse_* collections with picmaker, and falls back to FITS processing when no browse collections exist.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Related PRs: None identified.

Suggested labels: enhancement, previews, HST

Suggested reviewers: None identified.

Poem
A rabbit hops through FITS and browse,
Mapping suffixes, house by house,
Thumb, small, med, and full arrayed,
Picmaker hums, the previews made,
Skip or include — the policy's set,
No browse collection? No need to fret! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding HST bundle preview generation scripts and config files.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@juzen2003
juzen2003 marked this pull request as draft July 6, 2026 01:22

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@previews/HST/hst_bundle_previews.sh`:
- Around line 18-19: The script currently overwrites HOME with the current
directory, which changes the environment for picmaker and any subprocesses it
starts. Update hst_bundle_previews.sh to keep HOME unchanged and store the
caller working directory in a separate variable instead, using the shell
variable assignment near the top of the script.
- Around line 156-164: The picmaker call sites in hst_bundle_previews.sh only
stop on exit status 2, so other non-zero failures are being ignored. Update both
invocations around the preview generation blocks to capture picmaker’s exit code
and exit immediately for any non-zero status except the intended 2-case, using
the existing picmaker command and its surrounding if checks as the place to fix
this.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 874a5764-730c-41c6-9ac8-a918c93fb3b1

📥 Commits

Reviewing files that changed from the base of the PR and between 11dbd7a and 87169b8.

📒 Files selected for processing (5)
  • previews/HST/hst_bundle_browse_map.txt
  • previews/HST/hst_bundle_fits_map.txt
  • previews/HST/hst_bundle_fits_previews.txt
  • previews/HST/hst_bundle_previews.sh
  • previews/HST/hst_bundle_previews.txt

Comment on lines +18 to +19
HOME=`pwd`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

sed -n '1,120p' previews/HST/hst_bundle_previews.sh

Repository: SETI/rms-data-projects

Length of output: 3203


🏁 Script executed:

rg -n '\bHOME\b|resolve_path|picmaker|export HOME' previews/HST/hst_bundle_previews.sh

Repository: SETI/rms-data-projects

Length of output: 412


🏁 Script executed:

bash -lc '
set -e
printf "parent: initial exported HOME? "; export -p | grep -q "declare -x HOME=" && echo yes || echo no
HOME="/tmp/fake-home"
printf "parent: after assignment exported HOME? "; export -p | grep -q "declare -x HOME=" && echo yes || echo no
printf "child sees HOME: "
bash -lc "printf %s \"\$HOME\""
printf "\n"
'

Repository: SETI/rms-data-projects

Length of output: 469


Avoid overwriting HOME previews/HST/hst_bundle_previews.sh:18

HOME=\pwd`changes the exported home directory forpicmakerand anything it spawns. Use a separate variable for the caller cwd and leaveHOME` untouched.

🧰 Tools
🪛 Shellcheck (0.11.0)

[style] 18-18: Use $(...) notation instead of legacy backticks ....

(SC2006)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@previews/HST/hst_bundle_previews.sh` around lines 18 - 19, The script
currently overwrites HOME with the current directory, which changes the
environment for picmaker and any subprocesses it starts. Update
hst_bundle_previews.sh to keep HOME unchanged and store the caller working
directory in a separate variable instead, using the shell variable assignment
near the top of the script.

Comment on lines +156 to +164
picmaker "$data_dir" \
--directory "$outpath/$data_collection" \
--recursive --pattern \*.fits \
--strip "$strip" --verbose=2 --proceed \
--versions hst_bundle_fits_previews.txt

if [ "$?" = "2" ]; then
exit 2
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Map the relevant script and search for picmaker usage/definition/docs.
git ls-files | rg '^(previews/HST/hst_bundle_previews\.sh|.*picmaker.*|.*Picmaker.*|.*README.*|.*docs?.*)$' || true

echo "---- hst_bundle_previews.sh (around the cited lines) ----"
sed -n '130,210p' previews/HST/hst_bundle_previews.sh

echo "---- search for picmaker references ----"
rg -n --hidden --no-messages '\bpicmaker\b|exit code 2|proceed' .

echo "---- locate picmaker file(s) if present ----"
fd -a -t f -H 'picmaker*' .

Repository: SETI/rms-data-projects

Length of output: 9358


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- HST preview script headers / shell options ----"
sed -n '1,80p' previews/HST/hst_bundle_previews.sh

echo "---- nearby HST preview scripts for exit handling patterns ----"
sed -n '1,90p' previews/HST/HSTO_previews.sh
printf '\n----\n'
sed -n '1,90p' previews/HST/HSTJ_previews.sh
printf '\n----\n'
sed -n '1,90p' previews/HST/HSTI_previews.sh
printf '\n----\n'
sed -n '1,90p' previews/HST/HSTN_previews.sh
printf '\n----\n'
sed -n '1,90p' previews/HST/HSTU_previews.sh

echo "---- repo docs mentioning picmaker or exit codes ----"
rg -n --hidden --no-messages 'picmaker|exit code 2|status 2|return 2|proceed' README.md previews vicar .github . || true

Repository: SETI/rms-data-projects

Length of output: 23647


🌐 Web query:

picmaker exit code 2 documentation preview generation

💡 Result:

There is no official documentation for a "Picmaker exit code 2" related to preview generation. Picmaker is a web-based graphic design and AI social media tool [1][2], and users typically interact with it through a browser interface rather than a command-line environment that would return specific exit codes [3][4]. If you are encountering an "exit code 2" error in the context of "preview generation," it is highly likely that this is related to a different software system, as this is a common generic error code across various platforms [5]. The following systems are often associated with preview generation issues and exit codes: 1. Nextcloud: The Nextcloud "previewgenerator" app frequently encounters errors during background preview generation tasks [6][7]. Users often debug these issues using the occ command-line tool [7][8]. 2. Ruby on Rails (ActiveStorage): Modern versions of Rails (7+) introduced a PreviewError when previewer child processes (such as those using the Poppler library) fail to generate a preview, often resulting in non-zero exit statuses [9][10]. 3. Compilation/Build Tools: Exit code 2 in many development environments (such as VEXcode or standard build systems) typically indicates a generic compilation or build failure [5]. If you are using a tool other than Picmaker, please verify the software name or check your system's error logs for more specific information. If you are experiencing issues with Picmaker, it is recommended to contact their official support team through their help center [11][4].

Citations:


Propagate non-2 picmaker failures previews/HST/hst_bundle_previews.sh:156-164,188-197 — both call sites only special-case exit 2; every other non-zero picmaker status is ignored, so preview generation can still succeed after renderer or input failures.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@previews/HST/hst_bundle_previews.sh` around lines 156 - 164, The picmaker
call sites in hst_bundle_previews.sh only stop on exit status 2, so other
non-zero failures are being ignored. Update both invocations around the preview
generation blocks to capture picmaker’s exit code and exit immediately for any
non-zero status except the intended 2-case, using the existing picmaker command
and its surrounding if checks as the place to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant