Skip to content

Commit

Permalink
Fix calibration API timestamp (#3931)
Browse files Browse the repository at this point in the history
- today() does not have hours, minutes, seconds
- Switch to use now().
  • Loading branch information
dstrain115 committed Mar 19, 2021
1 parent f49ab35 commit 0baadeb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cirq/google/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ProtoVersion(enum.Enum):
def _make_random_id(prefix: str, length: int = 16):
random_digits = [random.choice(string.ascii_uppercase + string.digits) for _ in range(length)]
suffix = ''.join(random_digits)
suffix += datetime.date.today().strftime('%y%m%d-%H%M%S')
suffix += datetime.datetime.now().strftime('%y%m%d-%H%M%S')
return f'{prefix}{suffix}'


Expand Down
2 changes: 2 additions & 0 deletions cirq/google/engine/engine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ def test_make_random_id():
random_id = cg.engine.engine._make_random_id('prefix-')
time.sleep(1)
random_id2 = cg.engine.engine._make_random_id('prefix-')
# Verify %H%M%S is populated
assert random_id[-7:] != '-000000' or random_id2[-7:] != '-000000'
# Verify program id generate distinct even if random is seeded
assert random_id != random_id2

Expand Down

0 comments on commit 0baadeb

Please sign in to comment.