Skip to content

Commit

Permalink
Merge pull request #1 from SocialTensor/Dylan-Nov-21
Browse files Browse the repository at this point in the history
Handle, no credentials in hash manager
  • Loading branch information
Dhubbs authored Nov 21, 2024
2 parents 2e74148 + a949011 commit 22bd415
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Binary file removed my_proof.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions my_proof/hash_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_remote_hashes(self):
return self._initialize_empty_hash_file()
except Exception as e:
logging.error(f"Error fetching remote hashes: {str(e)}")
raise
return []

def update_remote_hashes(self, new_hashes):
"""Update remote JSON file with new hashes"""
Expand All @@ -62,7 +62,7 @@ def update_remote_hashes(self, new_hashes):
return True
except Exception as e:
logging.error(f"Error updating remote hashes: {str(e)}")
raise


def add_hash(self, new_hash):
"""Add a single hash to the remote file"""
Expand Down
7 changes: 4 additions & 3 deletions my_proof/proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ def Quality(data_list: List[Dict[str, Any]], aws_access_key_id: str, aws_secret_

def Uniqueness(data_list: List[Dict[str, Any]], aws_access_key_id: str, aws_secret_access_key: str) -> float:
hash_manager = HashManager(bucket_name="vanatensordlp", remote_file_key="verified_hashes/hashes.json", aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)
hash_exists = hash_manager.generate_hash(data_list) in hash_manager.get_remote_hashes()
if hash_exists:
generated_hash = hash_manager.generate_hash(data_list)
existing_hashes = hash_manager.get_remote_hashes()
if generated_hash in existing_hashes or generated_hash == []:
return 0.0
else:
hash_manager.add_hash(hash_manager.generate_hash(data_list))
hash_manager.update_remote_hashes(generated_hash)
return 1.0

def display_report(report: dict) -> None:
Expand Down

0 comments on commit 22bd415

Please sign in to comment.