message.py 386 Bytes
Newer Older
BO ZHANG's avatar
BO ZHANG committed
1
2
3
4
5
from astropy import time
import numpy as np
import string


BO ZHANG's avatar
BO ZHANG committed
6
def gen_dag_run_id(digits=6):
BO ZHANG's avatar
BO ZHANG committed
7
8
9
10
    """
    Generate a unique run_id for a dag.
    """
    now = time.Time.now()
BO ZHANG's avatar
BO ZHANG committed
11
    dag_run_id = now.strftime("%Y%m%d-%H%M%S-")
BO ZHANG's avatar
BO ZHANG committed
12
13
14
15
16

    n = len(string.ascii_lowercase)
    for i in range(digits):
        dag_run_id += string.ascii_lowercase[np.random.randint(low=0, high=n)]
    return dag_run_id