nanograv / pint_pal

A long-lived repository for NANOGrav Pulsar Timing workflows and analysis.
MIT License
6 stars 16 forks source link

Move around par files automatically; exclude date in write_par #24

Closed rossjjennings closed 1 year ago

rossjjennings commented 1 year ago

This changes the logic in the write_par() function so that it doesn't include the date in the par file name by default (to avoid cluttering the "archive" directory; we can always look at older versions in the git history).

Additionally, it adds a function pp.checkin.shuffle_pars() to the notebook which automatically copies the new par file to the par directory and archives the old one, then stages the changes in Git. This should make things easier on timers who want to check in par files, compared to the NANOGrav 15-year dataset workflow.

rossjjennings commented 1 year ago

CI is currently failing because staging the changes relies on the gitpython package, which is not in the environment yet.

rossjjennings commented 1 year ago

Maybe I just need to add gitpython to the setup.py requirements.

rossjjennings commented 1 year ago

Hmm, I guess we'd also like this to update the timing-model and compare-model fields in the YAML. I'll see if I can add that.

rossjjennings commented 1 year ago

There are some significant changes in these last commits: the par shuffler now logs what it does (using Astropy logging for now, but we should eventually try to move to loguru to mach PINT), and it updates the timing-model and compare-model fields in the YAML config file.

rossjjennings commented 1 year ago

Also, it tries to delete the old timing-model par file after making a copy in the archive directory, but it only if it's already tracked. And if the file is tracked but there are uncommitted changes, it stops in its tracks and prints a warning.

Having coded this up, though, I'm now not sure it's the behavior we really want. Typically in my workflow for the 15-year, I would make changes to the par file when adding or removing parameters, but then not commit those changes because I didn't really want them in the archived par file, which would trip this up.

rossjjennings commented 1 year ago

OK, I've taken out the bit that warns you if there are uncommitted changes to the old timing_model. It was a bit misguided as a mechanism for protecting against losing work anyway. The new behavior (copy if the file isn't tracked, and move if it is) is easier to understand, and the only way it can make you can lose work is if you have uncommitted changes to the file in the archive directory that gets overwritten, which seems pretty unlikely, and wasn't what I was checking for anyway.