turbaszek commented on a change in pull request #8430: Improve idempodency in
CloudDataTransferServiceCreateJobOperator
URL: https://github.com/apache/airflow/pull/8430#discussion_r410337665
##########
File path:
airflow/providers/google/cloud/hooks/cloud_storage_transfer_service.py
##########
@@ -98,6 +105,22 @@ class GcpTransferOperationStatus:
NEGATIVE_STATUSES = {GcpTransferOperationStatus.FAILED,
GcpTransferOperationStatus.ABORTED}
+def gen_job_name(job_name: str) -> str:
+ """
+ Adds unique suffix to job name. If suffix already exists, updates it.
+ Suffix — current timestamp
+ :param job_name:
+ :rtype job_name: str
+ :return:
+ """
+ split = job_name.split("_")
+ uniq = str(int(time.time()))
+ if len(split) > 1 and re.compile("^[0-9]{10}$").match(split[-1]):
+ split[-1] = uniq
+ return "_".join(split)
+ return "_".join([job_name, uniq])
Review comment:
Can't we just return `return f"{job_name}_{uniq}`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services