-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds validation checksum management and model
- Loading branch information
Janson Bunce
committed
Feb 20, 2025
1 parent
b4e096a
commit 2970d5b
Showing
5 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Validation utilities for syncing operations.""" | ||
|
||
# Standard Python Libraries | ||
from datetime import datetime | ||
|
||
# Third-Party Libraries | ||
from xfd_mini_dl.models import SyncChecksum | ||
|
||
|
||
def save_validation_checksum(checksum: str, type: str) -> bool: | ||
""" | ||
Save a validation checksum to the data lake. | ||
This function attempts to create a new SyncChecksum record in the database | ||
with the provided checksum and sync type. If the operation is successful, | ||
it returns True. If an exception occurs, it logs the error and returns False. | ||
Args: | ||
checksum (str): The checksum value to store. | ||
type (str): The type of sync operation associated with the checksum. | ||
Returns: | ||
bool: True if the checksum was successfully saved, False otherwise. | ||
""" | ||
try: | ||
SyncChecksum.objects.create( | ||
checksum=checksum, sync_type=type, sync_date=datetime.now() | ||
) | ||
return True | ||
except Exception as e: | ||
# Optionally, log the exception if needed | ||
print(f"Error saving checksum: {e}") | ||
return False |
This file contains 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