TheNeuralBit commented on a change in pull request #16641:
URL: https://github.com/apache/beam/pull/16641#discussion_r794970749



##########
File path: sdks/python/apache_beam/runners/dataflow/internal/apiclient.py
##########
@@ -421,10 +422,16 @@ def _build_default_job_name(user_name):
     user_name = re.sub('[^-a-z0-9]', '', user_name.lower())
     date_component = datetime.utcnow().strftime('%m%d%H%M%S-%f')
     app_user_name = 'beamapp-{}'.format(user_name)
-    job_name = '{}-{}'.format(app_user_name, date_component)
+    # append 8 random alphanumeric characters to avoid collisions.
+    random_component = ''.join(
+        random.choices(str(uuid.uuid4()).replace('-', ''), k=8))

Review comment:
       It's a bit odd to use `uuid` as the source for alphanumeric characters. 
I searched and found this solution which is nice: 
https://stackoverflow.com/questions/2511222/efficiently-generate-a-16-character-alphanumeric-string
   
   ```
   random.choices(string.ascii_lowercase + string.digits, k=8)
   ```
   
   What do you think?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to