Skip to content

Commit

Permalink
Revert "exp"
Browse files Browse the repository at this point in the history
This reverts commit 5410ba5.
  • Loading branch information
morsecodist committed Jul 5, 2024
1 parent 5410ba5 commit 903fe01
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lib/idseq_utils/idseq_utils/batch_run_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,15 @@ def __init__(self, bucket: str, prefix: str, inputs: Dict[str, str]):
self.prefix = prefix
self.inputs = inputs

def _cache_value(self, batch_args: Dict) -> str:
return json.dumps({"inputs": self.inputs, "batch_args": batch_args}, sort_keys=True)

def _key(self, batch_args: Dict) -> str:
hash = hashlib.sha256()
hash.update(self._cache_value(batch_args).encode())
cache_dict = {"inputs": self.inputs, "batch_args": batch_args}
hash.update(json.dumps(cache_dict, sort_keys=True).encode())
return os.path.join(self.prefix, hash.hexdigest())

def get(self, batch_args: Dict) -> Optional[str]:
key = self._key(batch_args)
log.info(f"cache_get ({key}): {self._cache_value(batch_args)}")
try:
resp = _s3_client.get_object(Bucket=self.bucket, Key=key)
resp = _s3_client.get_object(Bucket=self.bucket, Key=self._key(batch_args))
resp["Body"].read().decode()
except ClientError as e:
if e.response["Error"]["Code"] == "NoSuchKey":
Expand All @@ -122,11 +118,9 @@ def get(self, batch_args: Dict) -> Optional[str]:
raise e

def put(self, batch_args: Dict, job_id: str):
key = self._key(batch_args)
log.info(f"cache_put ({key}, {job_id}): {self._cache_value(batch_args)}")
_s3_client.put_object(
Bucket=self.bucket,
Key=key,
Key=self._key(batch_args),
Body=job_id.encode(),
Tagging="AlignmentCoordination=True",
)
Expand Down

0 comments on commit 903fe01

Please sign in to comment.