fix: Skip output directory cleanup when --skip_workflow is set#1627
Conversation
When running `nat eval --skip_workflow`, the output directory was being cleaned up before the dataset was loaded, destroying the workflow_output.json that the user intended to evaluate. The --skip_workflow flag exists to reuse previous output, so cleaning it up is contradictory. Skip cleanup when --skip_workflow is set and log an info message so the user knows why cleanup was skipped. Closes NVIDIA#1587 Signed-off-by: Blake Ledden <bledden@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 WalkthroughOutput directory cleanup in run_and_evaluate() is now conditional: cleanup_output_directory() is invoked only when self.eval_config.general.output is truthy and self.config.skip_workflow is False; if skip_workflow is True, cleanup is skipped and a log message is emitted. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/nvidia_nat_eval/src/nat/plugins/eval/runtime/evaluate.py (1)
588-592: Misleading log whenoutputconfig is absent.The
elif self.config.skip_workflow:branch fires wheneverskip_workflowisTrue, regardless of whetherself.eval_config.general.outputis set. Whenoutputis falsy, cleanup would have been skipped anyway, so the log message "Skipping output directory cleanup because --skip_workflow is set" is misleading — it implies cleanup was about to happen.Tighten the guard so the log only emits when cleanup would have actually been performed:
♻️ Proposed fix
- # Cleanup the output directory (skip when reusing existing workflow output) - if self.eval_config.general.output and not self.config.skip_workflow: - self.cleanup_output_directory() - elif self.config.skip_workflow: - logger.info("Skipping output directory cleanup because --skip_workflow is set") + # Cleanup the output directory (skip when reusing existing workflow output) + if self.eval_config.general.output: + if self.config.skip_workflow: + logger.info("Skipping output directory cleanup because --skip_workflow is set") + else: + self.cleanup_output_directory()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/nvidia_nat_eval/src/nat/plugins/eval/runtime/evaluate.py` around lines 588 - 592, The log is emitted even when output is falsy, which is misleading; change the conditional so the "Skipping output directory cleanup because --skip_workflow is set" message only appears when cleanup would have happened (i.e., when self.eval_config.general.output is truthy) — update the branches around cleanup_output_directory(), referencing self.eval_config.general.output and self.config.skip_workflow (and the cleanup_output_directory() call and logger.info) to check output && skip_workflow for the log path and output && !skip_workflow for performing cleanup.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/nvidia_nat_eval/src/nat/plugins/eval/runtime/evaluate.py`:
- Around line 588-592: The log is emitted even when output is falsy, which is
misleading; change the conditional so the "Skipping output directory cleanup
because --skip_workflow is set" message only appears when cleanup would have
happened (i.e., when self.eval_config.general.output is truthy) — update the
branches around cleanup_output_directory(), referencing
self.eval_config.general.output and self.config.skip_workflow (and the
cleanup_output_directory() call and logger.info) to check output &&
skip_workflow for the log path and output && !skip_workflow for performing
cleanup.
ValidationI wrote a targeted test to both reproduce the bug and validate the fix: Bug reproduction (reverted fix):
Fix validation (with the change):
Also ran the full eval test suite ( |
packages/nvidia_nat_eval/src/nat/plugins/eval/runtime/evaluate.py
Outdated
Show resolved
Hide resolved
Use nested conditional for clearer logic flow. Signed-off-by: Blake Ledden <bledden@users.noreply.github.com>
|
/ok to test 7e86fde |
|
/merge |
Summary
Fixes #1587
I ran into this while testing eval workflows: running
nat eval --skip_workflowwithout--datasetwas silently deleting theworkflow_output.jsonfrom a previous run. The cleanup step inrun_and_evaluate()runs before the dataset is loaded, so by the time the code tries to load the previous output, it's already been wiped byshutil.rmtree().Since
--skip_workflowexists specifically to reuse existing workflow output, it doesn't make sense to clean up the output directory when that flag is set. This change skips cleanup when--skip_workflowis active and logs an info message explaining why.Normal eval behavior (without
--skip_workflow) is unchanged.Test plan
nat evalnormally, confirm output directory cleanup still worksnat eval --skip_workflowafter a previous run, confirmworkflow_output.jsonis preservedSummary by CodeRabbit