lsst-sqre / times-square

A Rubin Science Platform service for hosting parametrized Jupyter notebooks as webpages
MIT License
2 stars 0 forks source link

Option to default to today's date #77

Open jrmullaney opened 4 months ago

jrmullaney commented 4 months ago

If one is using Times SQuaRE to check nightly processing, it would be really useful if there was some way to get the date to default to today's date.

I was thinking along the lines of the developer being able to have something along the lines of:

parameters:
  day_obs:
    type: string
    description: Observation Night (YYYY-MM-DD)
    default: "{today}"

should they want to default to today's date. I guess the format of the returned value may have to be fixed, with any necessary re-formatting happening in the notebook.

mfisherlevine commented 4 months ago

Just noting some useful functions here:

from lsst.summit.utils.utils import getCurrentDayObs_int, getCurrentDayObs_humanStr
from lsst.summit.utils.efdUtils import offsetDayObs, calcPreviousDay

dayObs = getCurrentDayObs_int()
dayObsStr = getCurrentDayObs_humanStr()
previousDayObs = calcPreviousDay(dayObs)
aYearAgo = offsetDayObs(dayObs, -365)
print(f"Today's dayObs is {dayObs} which looks like {dayObsStr}, and previously it was {previousDayObs}, 365 days ago it was {aYearAgo}")
>>> Today's dayObs is 20240630 which looks like 2024-06-30, and previously it was 20240629, 365 days ago it was 20230701

I'm aware that a) these should probably all be in the same file, and that b) the mixing of camel and snake case is super gross, so expect some minor API changes there, but I figured I'd still drop these here as they're useful in this context, partly because working with dates is annoying and partly because of the subtleties of the definition of the dayObs.