Skip to content
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

Filter rootnames and filenames before calling the filename_parser in archive_database_update #1657

Conversation

bhilbert4
Copy link
Collaborator

The motivation for this PR is to reduce the size of the log files from archive_database_update. After #1651 the filename_parser creates a log message for files that it cannot parse. But the relevant lines are also inside a try/except. So each time a non-parsable file is used, 4-5 lines of log messages are created. In WFSS observations, there can be thousands of filenames that can't be parsed. Plus the filename_parser is actually called twice on all the files as part of archive_database_update. This was resulting in log files that were ~350MB each, once per hour.

This PR filters out those filenames before calling the filename_parser, so we should end up not having all of those logging lines added.

@bhilbert4 bhilbert4 self-assigned this Oct 30, 2024
@pep8speaks
Copy link

pep8speaks commented Oct 30, 2024

Hello @bhilbert4, Thank you for updating !

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated at 2025-01-15 17:12:29 UTC

@bhilbert4 bhilbert4 requested a review from mfixstsci October 30, 2024 18:42
Copy link
Collaborator

@mfixstsci mfixstsci left a comment

Choose a reason for hiding this comment

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

@bhilbert4 whipping out the re dark arts here. I think this is best way to handle this problem, thanks for submitting this.

@mfixstsci
Copy link
Collaborator

Oh! @bhilbert4 one last thing. I am trying to be better about this in my reviews... Would you mind submitting a test or two for this new function.

It doesn't have to be too complex

def test_filter_rootnames():
    good_rootname = ['jw_good_rootname']
    bad_rootname=['jw_bad_rootname']
    
    good_result = filter_rootnames(good_rootname)
    bad_result = filter_rootnames(bad_rootname)
    
    assert good_rootname == good_rootname  # since it should return something
    asset bad_rootname is None  # since this should return None

If you want to parameterize it or do something fancy I support that too.

@bhilbert4
Copy link
Collaborator Author

New test added! It's pretty simple, but shows that the correct level 2 files are being filtered out. Let me know if you want anything more complex.

Copy link
Collaborator

@mfixstsci mfixstsci left a comment

Choose a reason for hiding this comment

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

Nice there is a failure now, going to check on that real quick

@bhilbert4
Copy link
Collaborator Author

@mfixstsci the failures have been resolved with some shuffling of the import statements in archive_database_update

@mfixstsci mfixstsci merged commit e9669fd into spacetelescope:develop Jan 15, 2025
11 checks passed
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