message.py 408 Bytes
Newer Older
BO ZHANG's avatar
BO ZHANG committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import json
from astropy import time
import numpy as np
import string
import os


def gen_dag_run_id(digits=10):
    """
    Generate a unique run_id for a dag.
    """
    now = time.Time.now()
    dag_run_id = now.iso[:10].replace("-", "")

    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