Skip to content

[int] Add cleanDirectory utility function for general directory clean-up#8584

Draft
sfayer wants to merge 1 commit into
DIRACGrid:integrationfrom
sfayer:tidy_htc_clean
Draft

[int] Add cleanDirectory utility function for general directory clean-up#8584
sfayer wants to merge 1 commit into
DIRACGrid:integrationfrom
sfayer:tidy_htc_clean

Conversation

@sfayer

@sfayer sfayer commented Jun 8, 2026

Copy link
Copy Markdown
Member

Hi,

Here is the reworked version of this to create a new cleanDirectory utility function and use it in a few places where it makes sense (including the HTCondorCE cleanup).

Regards,
Simon

BEGINRELEASENOTES
*Core
CHANGE: Add cleanDirectory utility function for general directory clean-up
ENDRELEASENOTES

@sfayer sfayer marked this pull request as ready for review June 8, 2026 21:58
@sfayer sfayer requested review from atsareg and fstagni as code owners June 8, 2026 21:58
return S_OK(outputs)

@staticmethod
def __cleanDir(workDir, maxMins, filePatterns, maxDepth=0):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I asked copilot if it could identify similar patterns. Answer in https://github.com/copilot/share/081500a8-01a0-88f7-b801-0801e4c80916

Snippet from the above:

There are multiple locations that could benefit from a generic file cleanup utility like __cleanDir:

PilotLoggingAgent.clearOldPilotLogs() – Lines 200-221

Currently manually iterates files and checks st_mtime
Could use __cleanDir with appropriate pattern matching

SecurityFileLog.__walkOldLogs() – Lines 86-104

Recursively walks directories and deletes files older than a threshold
Uses regex patterns for file matching
Very similar logic to __cleanDir – could be refactored

TransformationAgent.cleanOldTransformationCache() – Lines 172-186

Deletes cache files older than 60 days based on st_mtime
Could use __cleanDir with glob pattern *.pkl

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given you are on it, could you propose the following changes?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hi,

Just to clarify this before I go off in the wrong direction:: I think you're asking me to make a general utility function for this and then use it in these places (wherever it makes sense); is that correct?

Regards,
Simon

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, correct.

@aldbr

aldbr commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

For my education, what are you trying to solve here exactly?

@sfayer sfayer marked this pull request as draft June 11, 2026 18:42
@sfayer sfayer changed the title [int] Use python native for HTCondorCE cleanup rather than running find [int] Add cleanDirectory utility function for general directory clean-up Jun 11, 2026
@sfayer

sfayer commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

Here is my draft for this: We're testing it on one of our test servers before I'll mark it for review. Please feel free to have a quick look and let me know if it needs any major changes before we finish testing it!

It didn't make sense for the TransformationAgent.cleanOldTransformationCache case: This would need an extra filter (to check for files that are still being used) and the whole thing would be much more complicated that the existing code.

Regards,
Simon

@sfayer sfayer force-pushed the tidy_htc_clean branch 4 times, most recently from f62baed to 8ec8390 Compare June 11, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants