Skip to content

Commit

Permalink
fix(api): add time to filenames (for #55)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 15, 2023
1 parent df6b071 commit 16108ae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/onnx_web/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

import json
import numpy as np
import time

# paths
bundle_path = environ.get('ONNX_WEB_BUNDLE_PATH',
Expand Down Expand Up @@ -163,8 +164,10 @@ def serve_bundle_file(filename='index.html'):


def make_output_path(mode: str, seed: int, params: Tuple[Union[str, int, float]]):
now = int(time.time())
sha = sha256()
sha.update(mode.encode('utf-8'))

for param in params:
if param is None:
continue
Expand All @@ -177,7 +180,7 @@ def make_output_path(mode: str, seed: int, params: Tuple[Union[str, int, float]]
else:
print('cannot hash param: %s, %s' % (param, type(param)))

output_file = '%s_%s_%s.png' % (mode, seed, sha.hexdigest())
output_file = '%s_%s_%s_%s.png' % (mode, seed, sha.hexdigest(), now)
output_full = safer_join(output_path, output_file)

return (output_file, output_full)
Expand Down

0 comments on commit 16108ae

Please sign in to comment.