Skip to content

Commit

Permalink
Merge pull request #7 from convect-ai/fix-md5-bug
Browse files Browse the repository at this point in the history
fix md5 bug
  • Loading branch information
convect-bot authored Jan 9, 2024
2 parents ed80883 + b645c55 commit 5ec1e50
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion convect_flow_sdk/flow_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ def compress_to_tar_gz(source_folder, target_file):
tarinfo = tar.gettarinfo(full_path, arcname=arcname)
with open(full_path, "rb") as fileobj:
tar.addfile(tarinfo, fileobj)
fileobj.seek(0)
file_md5.append(hashlib.md5(fileobj.read()).hexdigest())
# sort file_md5 to make sure the order is consistent
file_md5 = file_md5.sort()
file_md5.sort()
return hashlib.md5(json.dumps(file_md5).encode()).hexdigest()

def generate_run_hash(
Expand Down Expand Up @@ -312,9 +313,11 @@ def submit(self, algo_id, command, config, input_path):
with tempfile.TemporaryDirectory() as temp_dir:
input_tar_gz_file = os.path.join(temp_dir, "input.tar.gz")
input_file_md5 = compress_to_tar_gz(input_path, input_tar_gz_file)
# print(f"algo run input file md5: {input_file_md5}")
run_hash = generate_run_hash(
self.flow_host_url, self.flow_workspace_id, algo_id, command, config, input_file_md5
)
# print(f"algo run hash: {run_hash}")
# check if run_hash exists
_run_hash_file_name = os.path.join(self.local_cache_dir,f"algo-run-{run_hash}.json")
if os.path.exists(_run_hash_file_name):
Expand Down

0 comments on commit 5ec1e50

Please sign in to comment.