Open
Conversation
…available alert files for each event and ingest them. Also document how to use this utility in the README.
…ng in production or locally.
swyatt7
requested changes
Nov 17, 2025
Collaborator
swyatt7
left a comment
There was a problem hiding this comment.
Everything lgtm.
Should probably use datetime.datetime.fromisoformat(self.gwalert_dict["time_of_signal"]) instead of the custom time. It's pretty robust.
That's it.
Comment on lines
+17
to
+35
| def parse_datetime_flexible(datetime_str): | ||
| """ | ||
| Parse datetime string with or without fractional seconds. | ||
| Handles both formats: '2023-01-01T12:34:56.123456' and '2023-01-01T12:34:56' | ||
| """ | ||
| formats = [ | ||
| "%Y-%m-%dT%H:%M:%S.%f", # With fractional seconds | ||
| "%Y-%m-%dT%H:%M:%S", # Without fractional seconds | ||
| ] | ||
|
|
||
| for fmt in formats: | ||
| try: | ||
| return datetime.datetime.strptime(datetime_str, fmt) | ||
| except ValueError: | ||
| continue | ||
|
|
||
| # If none work, raise the error | ||
| raise ValueError(f"Unable to parse datetime string: {datetime_str}") | ||
|
|
Collaborator
There was a problem hiding this comment.
There has been a function added to datetime api that does this:
mydate = datetime.datetime.fromisoformat(date_string)
|
|
||
| try: | ||
| tos = datetime.datetime.strptime(self.gwalert_dict["time_of_signal"], "%Y-%m-%dT%H:%M:%S.%f") | ||
| tos = parse_datetime_flexible(self.gwalert_dict["time_of_signal"]) |
Collaborator
There was a problem hiding this comment.
datetime.datetime.fromisoformat(self.gwalert_dict["time_of_signal"])
| print('Calculating LAT contours') | ||
|
|
||
| tos = datetime.datetime.strptime(self.gwalert_dict["time_of_signal"], "%Y-%m-%dT%H:%M:%S.%f") | ||
| tos = parse_datetime_flexible(self.gwalert_dict["time_of_signal"]) |
Collaborator
There was a problem hiding this comment.
datetime.datetime.fromisoformat(self.gwalert_dict["time_of_signal"])
sfoale
added a commit
that referenced
this pull request
Dec 8, 2025
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 PR adds a new selective ingestion tool.
The selective ingestion tool (selective_ingest.py) adds a script for catching up on historical alerts with three modes: list, ingest and GraceDB. Supports dry-run and is documented in the README.
Listener Improvements
Configuration
All changes are designed to be backwards compatible with existing production deployments.