Skip to content

chore: track scaffolding and ignore local TLS test artifacts#27

Merged
jpdeleon merged 8 commits into
mainfrom
upgrade
May 20, 2026
Merged

chore: track scaffolding and ignore local TLS test artifacts#27
jpdeleon merged 8 commits into
mainfrom
upgrade

Conversation

@jpdeleon

Copy link
Copy Markdown
Owner

Resolve untracked-file ambiguity flagged in B3 of the refactor plan:

  • Track check_pyproject_deps.py and document its purpose in README_DEV.md
  • Track notebook/window_length.ipynb alongside the existing notebooks
  • Track tests/test_tglc.py (network-marked regression test for commit efbe476)
  • Ignore tests/*.h5 - stray TLS output from manual runs, not a fixture

jpdeleon added 8 commits May 19, 2026 15:10
Resolve untracked-file ambiguity flagged in B3 of the refactor plan:
- Track check_pyproject_deps.py and document its purpose in README_DEV.md
- Track notebook/window_length.ipynb alongside the existing notebooks
- Track tests/test_tglc.py (network-marked regression test for commit efbe476)
- Ignore tests/*.h5 - stray TLS output from manual runs, not a fixture
Replace print() with logger.info / logger.warning / logger.debug in
quicklook/{inject,utils,plot,tql}.py so all in-process job output flows
through the loguru sink that the GUI already attaches in app/app.py.
Multi-line dataframe dumps are pre-stringified so each log record stays
one structured event.

Skipped intentionally:
- quicklook/gls.py — vendored verbatim from mzechmeister/GLS upstream
- quicklook/cli/*.py — intentional terminal output for CLI tools

This keeps the thread-local stdout shim as a belt-and-suspenders catch
for 3rd-party prints (astroquery, lightkurve) but unblocks moving the
GUI to a pure-loguru sink in a later commit.
Adds quicklook/app/templates/base.html that owns the common chrome
(DOCTYPE, head meta, favicon, shared CSS link, topbar include, shared
JS link, body close) so each page template only carries its own
content.

Each page now overrides four blocks:
- {% block title %}            page title
- {% block head %}             page-specific <style>
- {% block before_topbar %}    optional content above the nav
                               (toast container, running-jobs banner)
- {% block content %}          main page content
- {% block scripts %}          page-specific <script> + overlays
- {% block topbar_current %}   active-nav key (home/gallery/compare/summary)

Smoke-rendered all four routes; status, topbar, aria-current, shared
JS link all preserved. No styling change — the inline <style>/<script>
blocks still ship from the page templates (F1 will extract them later).
Single source of truth for ALL_TESS_PIPELINES,
FULL_FRAME_TESS_PIPELINES, and HLSP_PIPELINES. Previously the first
two lived in tql.py and the third was a hardcoded duplicate inside a
function in app.py - invisible drift waiting to happen.

quicklook/tql.py re-exports the FFI/all lists so existing callers
(including notebooks) keep working.

The docstring captures the orthogonality the old code only knew
implicitly: HLSP_PIPELINES is a filename-convention set (TASOC is in
because its stems use the HLSP pattern even though TASOC is not FFI),
FULL_FRAME_TESS_PIPELINES is an analysis-path set. Both live next to
each other now so the next added pipeline is one append, not three.
quicklook/app/templates/partials/_components.html now hosts a single
page_loading(title, subtitle, subtitle_id) macro. The four page
templates that previously copy-pasted the 9-line overlay now call
the macro with their own title/subtitle.

Verified by rendering all four routes: each still emits the
#pageLoading element with role=status, and the tls_summary variant
keeps its #pageLoadingPath subtitle id that the JS relies on.

Empty states stay as inline <p class="empty-state">…</p> for now —
the markup is one line per site and not worth a macro yet.
quicklook/app/jobs_db.py owns the SQLite schema, the PRAGMA
user_version, and the three CRUD calls the GUI needs (save, recent
step times, delete). app.py keeps a single module-level JobsDB
instance and the four inline sqlite3.connect/execute/close blocks
are gone.

The user_version-based migration scaffolding lets the next schema
change ship as a forward-only branch in _migrate; downgrading or
running against an unknown future version is refused loudly instead
of corrupting silently.

Verified against the existing jobs.db: save/recent/delete round-trip
clean, _get_avg_step_times() still returns the same shape, home and
gallery render 200.
… fixes

Improve quicklook/tglc.py and wire its outputs through the web GUI.

Light-curve type selection
- Add `photometry` arg to get_tglc_lc ("auto" | "aperture" | "psf").
- New _choose_photometry(): deterministic aperture-vs-PSF decision via
  edge/validity elimination, contamination ratio, point-to-point
  scatter, then a brightness soft-default (aperture, matching upstream).
- New _point_to_point_scatter(): MAD of successive flux differences, a
  white-noise estimate that is not inflated by real astrophysical
  variability, so it is safe for picking the less-noisy light curve.
- get_tglc_lc now attaches all four flux columns (cal_aper_flux,
  cal_psf_flux, aperture_flux, psf_flux) and records the decision in
  meta (FLUX_ORIGIN, PHOT_SEL, PHOT_RSN, CONTAMRT, APER_P2P, PSF_P2P).

GUI integration
- Reuse the "Flux Type" dropdown as a pipeline-aware "Flux / LC Type"
  control: PDCSAP/SAP for SPOC/TESS-SPOC, APERTURE/PSF for TGLC,
  disabled otherwise. Options swap on pipeline change (FLUXTYPE_OPTIONS
  + syncFluxtypeOptions in index.html).
- tql.py: map flux_type -> photometry in the local TGLC fallback, and
  add a TGLC branch to the MAST flux-selection block so the choice
  applies to both MAST HLSP and locally-extracted light curves.

Performance
- Cache the Source_cut pickle and e_psf array (cache_dir / use_cache),
  keyed by target/sector/size, so repeat runs skip the download and
  the ePSF fit; cached arrays are shape-validated with graceful
  fallback to a fresh fit.
- Raise the astroquery MAST connection timeout 600s -> 3600s; the
  default 10-minute limit aborted large TESScut cutout downloads
  ("Timeout limit of 600 exceeded").
- get_tglc_lc(sector=None) now passes "first" to Source_cut so TESScut
  downloads a single sector's cutout instead of one per observed
  sector (the docstring already promised "first available sector").

Progress reporting
- New _fit_epsf_series(): keeps the tqdm status bar and additionally
  emits a loguru progress line every 5% of cadences, so ePSF progress
  is visible in captured logs (e.g. the web GUI job log) where tqdm
  does not render. Used by both epsf() and get_tglc_lc().

Bug fixes
- Fix isinstance(Source_cut, source) -> isinstance(source, Source_cut)
  in epsf() (2x); the reversed arguments raised TypeError and broke
  epsf() unconditionally (regression vs upstream's type() check).
- Fix the broken __main__ block: exists() called with no argument,
  unexpanded "~", and missing path separators.
Bug fixes
- Replace np.NaN with np.nan (2x in tglc.py); np.NaN was removed in
  NumPy 2.0 and crashed any run whose target landed near a cutout edge.
- fit_lc: reshape target_5x5/field_stars_5x5 to the actual cut-region
  shape before padding to 5x5. The hardcoded reshape(5, 5) raised
  "cannot reshape array of size 20 into shape (5,5)" for edge-clipped
  stars, and the pad-to-5x5 block below it was unreachable.

Sector semantics
- get_tglc_lc: sector=-1 now selects the latest available sector (was
  treated as "first"), matching the GUI's "-1 = latest" help text;
  None still means first and a positive int selects that sector.
  tql.py's _get_tglc_lc_fallback passes the request through unchanged
  instead of collapsing -1 to None.

GUI
- app.py: add an "Extracting ePSF light curve" pipeline step and
  interpolate the progress bar within it from the "ePSF fitting: N/M
  (X%)" log lines, so the bar advances during local ePSF extraction
  instead of freezing on "Downloading data".
- index.html: the Cancel button now updates the GUI from the /cancel
  HTTP response rather than relying solely on a websocket 'finish'
  message, which never arrives if the socket dropped during a long
  job. It also closes the stale socket to avoid double-handling.

Docs
- README: document the TGLC aperture/PSF flux_type options and the
  local ePSF fallback.
@jpdeleon jpdeleon merged commit 03a03a3 into main May 20, 2026
5 checks passed
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