Repository navigation
Conversation
With overwrite, an existing L0.5 CDF file was deleted before the new one was created, so if filling the new one failed or was interrupted, no file was left for that APID. A run that was interrupted while writing also left an incomplete file with the final name. Each L0.5 CDF file is now written at a temporary path in the same directory and renamed over the final path only once it is complete. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (68.57%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #150 +/- ##
==========================================
- Coverage 76.19% 75.97% -0.23%
==========================================
Files 15 15
Lines 1420 1440 +20
Branches 200 201 +1
==========================================
+ Hits 1082 1094 +12
- Misses 298 305 +7
- Partials 40 41 +1
🚀 New features to boost your workflow:
|
namurphy
commented
Nov 19, 2026
Comment on lines
+571
to
+574
| except BaseException: | ||
| # Such as KeyboardInterrupt | ||
| _discard_partial_cdf(cdf, tmp_path) | ||
| raise |
Member
Author
There was a problem hiding this comment.
I should start doing this in all of my other projects. 😅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the decommutator counterpart of #149, which makes the same change for
l05_to_l1.Problem
With
overwrite=True(or--overwrite),l0_to_l05deleted an existing L0.5 CDF file before creating the new one. If filling the new file then failed, the partial file was deleted too, so no L0.5 file was left for that APID. If the run was interrupted (for example, by Ctrl-C) or killed while writing, an incomplete file was left at the final path, where it could be mistaken for a complete one.Change
.0523462910_4_EA_APID352_L1.<random hex>.tmp.cdf. It's moved over the final path withPath.replaceonly once it has been filled and closed. That means:KeyboardInterrupt, the temporary file is closed and deleted, and the exception is still recorded or raised as before._discard_partial_cdflogs any error from closing or deleting it rather than letting that error replace the original one.temporary_pathis added topyfaradaycup.utils._cdf, next toclose_cdf.(deleted). The partial file is now only ever the temporary one, and any existing file is kept.The CDF contents are unchanged. The tests that compare the output with the IDL L0.5 files pass.
Testing
nox -s tests-3.9,nox -s tests-3.14,nox -s dagster_with_coverage,nox -s typecheck,nox -s lint, andnox -s docspass.overwrite, a fill that fails, and a fill interrupted byKeyboardInterrupt, both leave the existing CDF unchanged byte for byte, with no temporary files left behind.temporary_pathreturns a hidden path in the same directory that ends in.cdfand is different each time.Notes
l05_to_l1to the sharedtemporary_pathhelper. Keep existing L1 files when replacing them fails #149 currently has its own private_temporary_path.SIGKILLcan still leave a hidden.tmp.cdffile behind, but never an incomplete file with the final name.overwrite, the existence check and the rename aren't one atomic step, so a file created by another process in between would be replaced.🤖 Generated with Claude Code