New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pipelinerefactor daily mode updates #2201
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for submitting this PR to the PR. It will be nice to have a unit test that covers the daily operating mode, and I know it was difficult to contrive the correct test environment to do that. I have requested some changes before we should merge to simplify things a bit.
For the record, this was all for a specific unit test, rather than features that will ever be needed in real-world usage. The existing code works in all circumstances on historic data whether --daily
is set or not, and on new data with --daily
set. The new features are only required if trying to trick the code into pretending today is a day in the past and where you want to pass data in slowly and watch what the code does.
Overview of the requested changes: I think the proc_night
code should be reverted back to run under if daily
and the input be converted to a standard boolean flag. There are a few more checks that could be done in the unit test.
bin/desi_proc_night
Outdated
@@ -102,6 +102,10 @@ def parse_args(): | |||
help="If set then the code will NOT raise an error " | |||
+ "if asked to link psfnight calibrations " | |||
+ "without fiberflatnight calibrations.") | |||
parser.add_argument("--still-acquiring", action=argparse.BooleanOptionalAction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be a normal boolean flag, i.e. I don't think we need a None state. If set, then it is true regardless of what the code thinks. If not set, it is False, which is the default assumption in the code unless specific criteria are met.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted this here and in desispec.scripts.proc_night.proc_night
. I agree that keeps the --daily options override more self contained. I originally went down this path because at the desi_proc(..., still_acquiring)
level I wanted to distinguish between "not set" (None) vs. "don't do it" (False), though admittedly I don't have a good reason why one would need to force it off. In the updated logic, still_acquiring=False
doen't really mean False, but rather "auto derive what to do". I've clarified that in the docstring, and added a log message when it gets overridden.
py/desispec/scripts/proc_night.py
Outdated
@@ -186,30 +190,32 @@ def proc_night(night=None, proc_obstypes=None, z_submit_types=None, | |||
elif dry_run_level > 0: | |||
dry_run = True | |||
|
|||
## What night are we running on? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should only be set automatically for --daily
mode, otherwise we want the night to be a required variable. This should be moved back to under --daily
. I also found the log.info()
relevant, so I'd prefer that to be restored as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this back under if daily
; see commentary on first desi_proc_night comment.
py/desispec/scripts/proc_night.py
Outdated
## Set a flag to determine whether to process the last tile in the exposure table | ||
## or not. This is used in daily mode when processing and exiting mid-night. | ||
still_acquiring = False | ||
|
||
if still_acquiring is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we change still_acquiring to a simple boolean argument then none of this logic is necessary. The old code would only set still_acquiring to True, it never set it to False (except for the initialization which would be removed since it is now an input)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done; see commentary on desi_proc_night comment
py/desispec/scripts/proc_night.py
Outdated
@@ -53,7 +53,8 @@ def proc_night(night=None, proc_obstypes=None, z_submit_types=None, | |||
path_to_data=None, exp_obstypes=None, camword=None, | |||
badcamword=None, badamps=None, exps_to_ignore=None, | |||
sub_wait_time=0.5, verbose=False, dont_require_cals=False, | |||
psf_linking_without_fflat=False): | |||
psf_linking_without_fflat=False, | |||
still_acquiring=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to False
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done; see commentary on desi_proc_night comment.
bin/desi_proc_night
Outdated
@@ -102,6 +102,10 @@ def parse_args(): | |||
help="If set then the code will NOT raise an error " | |||
+ "if asked to link psfnight calibrations " | |||
+ "without fiberflatnight calibrations.") | |||
parser.add_argument("--still-acquiring", action=argparse.BooleanOptionalAction, | |||
help="in --daily mode, assume more data is still coming even if " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please specify this flag is for testing purposes only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. I think I have addressed all comments and made updates.
bin/desi_proc_night
Outdated
@@ -102,6 +102,10 @@ def parse_args(): | |||
help="If set then the code will NOT raise an error " | |||
+ "if asked to link psfnight calibrations " | |||
+ "without fiberflatnight calibrations.") | |||
parser.add_argument("--still-acquiring", action=argparse.BooleanOptionalAction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted this here and in desispec.scripts.proc_night.proc_night
. I agree that keeps the --daily options override more self contained. I originally went down this path because at the desi_proc(..., still_acquiring)
level I wanted to distinguish between "not set" (None) vs. "don't do it" (False), though admittedly I don't have a good reason why one would need to force it off. In the updated logic, still_acquiring=False
doen't really mean False, but rather "auto derive what to do". I've clarified that in the docstring, and added a log message when it gets overridden.
bin/desi_proc_night
Outdated
@@ -102,6 +102,10 @@ def parse_args(): | |||
help="If set then the code will NOT raise an error " | |||
+ "if asked to link psfnight calibrations " | |||
+ "without fiberflatnight calibrations.") | |||
parser.add_argument("--still-acquiring", action=argparse.BooleanOptionalAction, | |||
help="in --daily mode, assume more data is still coming even if " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
py/desispec/scripts/proc_night.py
Outdated
@@ -53,7 +53,8 @@ def proc_night(night=None, proc_obstypes=None, z_submit_types=None, | |||
path_to_data=None, exp_obstypes=None, camword=None, | |||
badcamword=None, badamps=None, exps_to_ignore=None, | |||
sub_wait_time=0.5, verbose=False, dont_require_cals=False, | |||
psf_linking_without_fflat=False): | |||
psf_linking_without_fflat=False, | |||
still_acquiring=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done; see commentary on desi_proc_night comment.
py/desispec/scripts/proc_night.py
Outdated
@@ -186,30 +190,32 @@ def proc_night(night=None, proc_obstypes=None, z_submit_types=None, | |||
elif dry_run_level > 0: | |||
dry_run = True | |||
|
|||
## What night are we running on? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this back under if daily
; see commentary on first desi_proc_night comment.
py/desispec/test/test_proc_night.py
Outdated
|
||
|
||
etable = load_table(get_exposure_table_pathname(self.dailynight)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
py/desispec/test/test_proc_night.py
Outdated
## if 1sec flat has arrived, cals should be submitted | ||
# for jobdesc in ('ccdcalib', 'arc', 'psfnight', 'flat', 'nightlyflat'): | ||
# self.assertIn(jobdesc, proctable['JOBDESC']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This highlighted that I had accidentally left a commented test check that I had intended to actually run. The "linkcal OR other jobs" logic is a bit tricky, depending upon exactly what is being linked. I left this test as-is for a normal night. If we want to test daily ops on a night with an override, we should add a specific different test for that case. Though we might never do that in operations — anytime that we don't have cals and would want to do an override, we'd probably be waiting to see if we got cals in the morning anyway.
@@ -61,7 +61,7 @@ def determine_calibrations_to_proc(etable, do_cte_flats=True, | |||
## return nothing so that we swiftly exit and wait for more data. | |||
if np.sum(exptypes == 'dark') >= 1 and np.sum(exptypes == 'arc') >= 5 \ | |||
and np.sum(exptypes == 'flat') >= 12 \ | |||
and (np.sum(exptypes == 'cteflat') >= 3 or not do_cte_flats | |||
and ((np.sum(is_cte_1s) >= 1) or not do_cte_flats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. When we added the additional 3s and 10s flats, we purposefully put those before the 1s flat so that it could remain the "trigger" for launching the pipeline. If we added/removed other flats in the future, we should do the same (put them between the 120s fiberflats and the 1s CTE flat).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the extra pass
that no longer needs to be there after uncommenting code in the unit test. There are no further code changes, so I'm approving and merging.
This is a "PR on a PR" to document the changes I made to the pipelinerefactor branch in PR #2187 while testing daily mode, and to allow @akremin an opportunity to review them before they are added to that branch. Changes are:
log.log
->log.info
typodesi_proc_night --daily ...
when they are all piped to the same log.--still-acquiring
option to be able to test--daily
mode on nights other than the current night. If not specified, it defaults to previous logic based upon current night and observing hours.desi_proc_night --daily --dry-run-level 1 ...
multiple times as new data are staged. This test catches the BUGFIX and exercises the new FEATUREs added.desispec.test.util.link_rawdata
to facilitate the new test. That code is also useful for non-unittest interactive testing to stage links (I originally wrote it for interactive testing ofdesi_daily_proc --daily
and then ported the workflow intodesispec.test
).