|
27 | 27 | import six |
28 | 28 |
|
29 | 29 |
|
30 | | -AIRFLOW_TIME_MACRO = "{{ execution_date.strftime('%Y-%m-%d-%H-%M-%S') }}" |
31 | | -AIRFLOW_TIME_MACRO_LEN = 19 |
32 | | -AIRFLOW_TIME_MACRO_SHORT = "{{ execution_date.strftime('%y%m%d-%H%M') }}" |
33 | | -AIRFLOW_TIME_MACRO_SHORT_LEN = 11 |
34 | | - |
35 | | - |
36 | 30 | # Use the base name of the image as the job name if the user doesn't give us one |
37 | 31 | def name_from_image(image): |
38 | 32 | """Create a training job name based on the image name and a timestamp. |
@@ -73,25 +67,6 @@ def unique_name_from_base(base, max_length=63): |
73 | 67 | return '{}-{}-{}'.format(trimmed, ts, unique) |
74 | 68 |
|
75 | 69 |
|
76 | | -def airflow_name_from_base(base, max_length=63, short=False): |
77 | | - """Append airflow execution_date macro (https://airflow.apache.org/code.html?#macros) |
78 | | - to the provided string. The macro will beevaluated in Airflow operator runtime. |
79 | | - This guarantees that different operators will have same name returned by this function. |
80 | | -
|
81 | | - Args: |
82 | | - base (str): String used as prefix to generate the unique name. |
83 | | - max_length (int): Maximum length for the resulting string. |
84 | | - short (bool): Whether or not to use a truncated timestamp. |
85 | | -
|
86 | | - Returns: |
87 | | - str: Input parameter with appended macro. |
88 | | - """ |
89 | | - macro = AIRFLOW_TIME_MACRO_SHORT if short else AIRFLOW_TIME_MACRO |
90 | | - length = AIRFLOW_TIME_MACRO_SHORT_LEN if short else AIRFLOW_TIME_MACRO_LEN |
91 | | - trimmed_base = base[:max_length - length - 1] |
92 | | - return "{}-{}".format(trimmed_base, macro) |
93 | | - |
94 | | - |
95 | 70 | def base_name_from_image(image): |
96 | 71 | """Extract the base name of the image to use as the 'algorithm name' for the job. |
97 | 72 |
|
|
0 commit comments