Skip to content

Commit

Permalink
lengthen randomly generated program id (#2599)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsung authored Nov 26, 2019
1 parent 993fa1e commit 690b5f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions cirq/google/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"""

import base64
import datetime
import enum
import json
import random
Expand Down Expand Up @@ -87,12 +88,13 @@ def request_builder(*args, **kwargs):
return request_builder


def _make_random_id(prefix: str, length: int = 6):
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')
return '%s%s' % (prefix, suffix)


Expand Down Expand Up @@ -241,7 +243,8 @@ def run(
program_id: A user-provided identifier for the program. This must
be unique within the Google Cloud project being used. If this
parameter is not provided, a random id of the format
'prog-######' will be generated.
'prog-################YYMMDD' will be generated, where # is
alphanumeric and YYMMDD is the current year, month, and day.
job_config: Configures the names and properties of jobs.
param_resolver: Parameters to run with the program.
repetitions: The number of repetitions to simulate.
Expand Down Expand Up @@ -289,7 +292,8 @@ def run_sweep(
program_id: A user-provided identifier for the program. This must
be unique within the Google Cloud project being used. If this
parameter is not provided, a random id of the format
'prog-######' will be generated.
'prog-################YYMMDD' will be generated, where # is
alphanumeric and YYMMDD is the current year, month, and day.
job_config: Configures the names and properties of jobs.
params: Parameters to run with the program.
repetitions: The number of circuit repetitions to run.
Expand Down Expand Up @@ -462,7 +466,8 @@ def create_program(
program_id: A user-provided identifier for the program. This must be
unique within the Google Cloud project being used. If this
parameter is not provided, a random id of the format
'prog-######' will be generated.
'prog-################YYMMDD' will be generated, where # is
alphanumeric and YYMMDD is the current year, month, and day.
gate_set: The gate set used to serialize the circuit. The gate set
must be supported by the selected processor
"""
Expand Down
2 changes: 1 addition & 1 deletion cirq/google/engine/engine_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ def test_implied_job_config(build):
# Infer all from project id.
implied = eng.implied_job_config(cg.JobConfig())
assert implied.job_id.startswith('job-')
assert len(implied.job_id) == 10
assert len(implied.job_id) == 26
assert implied.gcs_prefix == 'gs://gqe-project_id/'
assert re.match(r'gs://gqe-project_id/jobs/job-', implied.gcs_results)

Expand Down

0 comments on commit 690b5f7

Please sign in to comment.