Skip to content

Conversation

@opotowsky
Copy link
Member

@opotowsky opotowsky commented Dec 30, 2025

What is the change? Why is it being made?

Update: I'm marking this as a feature request instead of a bug for the SCR because although I'm calling it a bug, it wasn't hurting anyone. It's just super unclear behavior we are now correcting.

See #2401 for a full description of the non-ideal behavior.

  1. The DO_NOT_CLEAN_PATHS check is removed entirely as it is not needed. It was doing the opposite of what was indicated--it was greenlighting those deletions. We don't need any greenlit deletions other than (2) and (3) below.
  2. The APP_DATA check is replaced with a check that the path for deletion is under _FAST_PATH. _FAST_PATH is amended often (e.g. if the code changes directory) and is not guaranteed to be under APP_DATA, but _FAST_PATH and therefore anything in it is always safe to delete.
  3. The TemporaryDirectoryChanger root is not guaranteed to be under _FAST_PATH, so an argument is added to indicate to cleanPath the dir slated for deletion comes from a tempDir instance (and this was also applied to output caches as well).

This work exposed some confusion with cleanTempDirs, so we made a ticket for that: #2408. I'm resolving that here because it was found during the course of this work.

SCR Information

Change Type: features

One-Sentence Rationale: cleanPath is not behaving like the variable names would indicate, so issues with naming were corrected in cleanPath as well as in cleanTempDirs.

One-line Impact on Requirements: NA


Checklist

@opotowsky opotowsky added bug Something is wrong: Highest Priority feature request Smaller user request labels Dec 30, 2025
@opotowsky opotowsky linked an issue Dec 30, 2025 that may be closed by this pull request
@opotowsky
Copy link
Member Author

@john-science this is a feature addition that exposed a bug, so I'm treating it as a bug ticket. I could separate the feature addition into a different PR if you prefer for SCR clarity. The feature is just this:
image

Also I see a bunch of CI failed. I'll look into that later today....bodes well for my downstream testing 🙃

@john-science john-science changed the title Edit cleanPath and TempDirChanger behavior Modifying cleanPath and TempDirChanger behavior Jan 5, 2026
@john-science
Copy link
Member

this is a feature addition that exposed a bug,

Except all changes to this feature to cause massive trauma downstream. People use this feature A LOT, and some people use it in surprising and unexpected ways.

Since I am constantly surprised HOW this is being used, it's hard to know what changes would make this feature more stable.

@john-science
Copy link
Member

@opotowsky

One-Sentence Rationale: cleanPath is not behaving properly,

I mean, I don't agree with that. You have need to use this old feature in a new setting it's never been used in before. This is new feature or enhancement at best.

Comment on lines 215 to 223
# Deletions are not immediate, so wait for it to finish.
maxLoops = 6
waitTime = 0.5
loopCounter = 0
while os.path.exists(path):
loopCounter += 1
if loopCounter > maxLoops:
break
sleep(waitTime)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@john-science will check on if this can be deleted. Could be cruft from the old days.

Does shutil only return once it's complete? If yes, can delete

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm:

  • This is cruft from the ancient past.
  • Their docs do not say that shutil.rmtree() is blocking. But digging around the code for a while convinces me it is.

@opotowsky opotowsky changed the title Modifying cleanPath and TempDirChanger behavior Modifying unclear cleanPath behavior Jan 7, 2026
@opotowsky opotowsky linked an issue Jan 7, 2026 that may be closed by this pull request
@opotowsky opotowsky removed the bug Something is wrong: Highest Priority label Jan 7, 2026
@john-science john-science self-requested a review January 7, 2026 21:02
@john-science
Copy link
Member

I love your re-design of the PR description. Thank you!

at the same time. Always check filenames for some special flag when calling this, especially
with full permissions on the cluster. You could accidentally delete everyone's work with one
misplaced line! This doesn't ask questions.
def cleanPath(path, mpiRank=0, tempDir=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm 50/50 on this. Should this new parameter be called tempDir, or something like force?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yea, I'm very willing to go over ideas here (see comment reply here #2402 (comment))

Really, as reviewer you can tell me what to do here.

force
forceDelete
forceClean
allowDelete
yesIHaveAPermit
AUTHORIZED
clearedForDeletion
blessedBeTheDeletion
outputCacheOrTempDirDeletionONLY
hallPassForDestruction

ok wow I need to stop

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go with force or forceClean, if I was picking from your list. #shrug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request Smaller user request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Does context.cleanTempDirs need a rename? cleanPath behavior has troubling issues

3 participants