-
Notifications
You must be signed in to change notification settings - Fork 1
/
look_up_dir.py
87 lines (63 loc) · 1.93 KB
/
look_up_dir.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import os
import collections
PATH = os.path.dirname(os.path.abspath(__file__))
# In [2]: os.listdir('./update-model-1/model0.8/model/')
# Out[2]: ['ckpt_0.data-00000-of-00001', 'ckpt_0.meta', 'checkpoint', 'ckpt_0.index']
def get_max_model_index(cnt: int = 1):
model_path = "tmp-model-3/model/"
if cnt != 1:
model_path = "update-model-1/model/"
num = -1
#ckpt_0 0
for i in os.listdir(os.path.join(PATH, model_path)):
o = i.split(".")[0]
try:
a = int(o.split("_")[1])
if a > num:
num = a
except:
pass
return num
def get_max_serving_index(cnt: int = 1):
model_path = "tmp-model-3/serving/"
if cnt != 1:
model_path = "update-model-1/serving/"
num = -1
for i in os.listdir(os.path.join(PATH, model_path)):
o = i.split(".")[0]
try:
a = int(o)
if a > num:
num = a
except:
pass
return num
def get_last_day_fmt():
import datetime
day = datetime.datetime.today()
yes = day + datetime.timedelta(days=-1)
#'2019-07-23'
return yes.strftime("%Y-%m-%d")
def get_now_day_fmt():
import datetime
day = datetime.datetime.today()
return day.strftime("%Y-%m-%d")
def get_some_day_fmt(start,num):
'''
'Feb 28, 2018'
number 包括当天
'''
import datetime
start = datetime.datetime.strptime(start, '%b %d, %Y')
dates = []
for i in range(num):
tmp = start + datetime.timedelta(days=i)
dates.append(tmp.strftime("%Y-%m-%d"))
index = [i for i in range(num)]
rst = collections.OrderedDict(zip(index,dates))
return rst
if __name__ == "__main__":
print(get_max_model_index())
print(get_max_serving_index())
print(get_last_day_fmt())
# 2019-04-%02