Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Commit ba39ef2

Browse files
committed
fix bugs
1 parent 6ea1b17 commit ba39ef2

File tree

8 files changed

+70
-16
lines changed

8 files changed

+70
-16
lines changed

core.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,21 @@ def __register__(factor):
5353
class GreaterWorseFactor(Factor):
5454
''' Evaluator for any factors that large value is bad, trainning cost for example. '''
5555

56-
def __init__(self, name, diff_thre):
56+
def __init__(self, name, diff_thre, skip_head=2):
5757
'''
5858
diff_thre: difference threshold.
5959
'''
6060
super(GreaterWorseFactor, self).__init__(out_file='%s_factor.txt' %
6161
name)
62+
self.skip_head = skip_head
6263
self.name = name
6364
self.diff_thre = diff_thre
6465

6566
def evaluate(self, root):
66-
cur_data = load_records_from(pjoin(root, self.out_file))
67-
his_data = load_records_from(pjoin(root, self.his_file))
67+
cur_data = load_records_from(
68+
pjoin(root, self.out_file))[self.skip_head:]
69+
his_data = load_records_from(
70+
pjoin(root, self.his_file))[self.skip_head:]
6871
diff = cur_data - his_data
6972
larger = diff > 0
7073
self.ratios = diff[larger] / his_data[larger]

gstate.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def set(key, value):
1313
if not os.path.isdir(gstate.root):
1414
os.mkdir(gstate.root)
1515
with open(pjoin(gstate.root, key), 'w') as f:
16-
f.write(value)
16+
f.write(str(value))
1717

1818
@staticmethod
1919
def get(key):
@@ -67,3 +67,14 @@ def update_baseline_history(history):
6767
@staticmethod
6868
def get_baseline_history():
6969
return gstate.get(gstate.baseline_history)
70+
71+
source_code_updated = 'source_code_updated'
72+
73+
@staticmethod
74+
def set_source_code_updated(updated):
75+
''' updated: bool, yes/no '''
76+
gstate.set(gstate.source_code_updated, 'yes' if updated else 'no')
77+
78+
@staticmethod
79+
def get_source_code_updated():
80+
return gstate.get(gstate.source_code_updated) == 'yes'

main.xsh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $XONSH_SHOW_TRACEBACK = True
44

55
import os
66
import sys; sys.path.insert(0, '')
7+
import time
78

89
import prepare
910
import config
@@ -26,6 +27,7 @@ def test_latest_source():
2627
baseline.strategy.refresh_workspace()
2728
write_init_models_factors_to_gstate()
2829
write_init_progress_to_gstate()
30+
write_history_to_gstate()
2931
# update_model_factors_status('prepare', 'update_baseline', 'pass')
3032

3133
log.warn('init local paddle repo %s' % config.local_repo_path())
@@ -38,6 +40,8 @@ def test_latest_source():
3840
prepare.compile()
3941
prepare.install_whl()
4042
test_models()
43+
# update baseline
44+
baseline.strategy()
4145

4246
def test_models():
4347
cd @(config.workspace)
@@ -59,8 +63,6 @@ def test_models():
5963
update_evaluation_status(evaluate_status)
6064

6165
log.warn('evaluation result:\n%s' % gstate.get_evaluation_result())
62-
baseline.strategy()
63-
6466
if evaluation_succeed():
6567
update_success_commit_to_gstate()
6668
else:
@@ -109,10 +111,13 @@ def source_code_updated():
109111
cur_commit = repo.get_paddle_commit()
110112
last_commit = gstate.get(config._state_paddle_code_commit_)
111113
updated = last_commit is None or cur_commit != last_commit
114+
gstate.set_source_code_updated(updated)
112115
if not updated:
113116
log.info("paddle source code is not changed, skip test, commitid %s" % cur_commit)
114-
return updated
115-
gstate.set(config._state_paddle_code_commit_, cur_commit)
117+
else:
118+
gstate.set(config._state_paddle_code_commit_, cur_commit)
116119
return updated
117120

118-
test_latest_source()
121+
for i in range(5000):
122+
test_latest_source()
123+
time.sleep(60)

utils.xsh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ def write_history_to_gstate():
118118
spliter = '__'
119119
history = $(git log --pretty=format:">>>%H__%ai__%s__%B")
120120
records = []
121-
print('history', repr(history))
122121
for line in history.split('\n'):
123-
if line.startswith('"'): line = line[1:-1]
124-
print('line', repr(line))
122+
if line.startswith('"'): line = line[1:]
123+
if line.endswith('"'): line = line[:-1]
125124
if not line: continue
126125
if line.startswith('>>>'):
127126
fields = line.strip().split(spliter)
@@ -130,7 +129,6 @@ def write_history_to_gstate():
130129
body = fields[3]
131130
records.append([commitid, date, subject, body])
132131
else:
133-
print('records', records)
134132
# append body
135133
records[-1][3] += '\n' + line
136134
gstate.update_baseline_history(json.dumps(records))
@@ -139,7 +137,8 @@ def update_fail_commit_to_gstate():
139137
commit = gstate.get(config._state_paddle_code_commit_)
140138
gstate.set(config._fail_commit_, commit)
141139

142-
def update_success_commit_to_gstate(commit):
140+
def update_success_commit_to_gstate():
141+
commit = gstate.get(config._state_paddle_code_commit_)
143142
gstate.set(config._success_commit_, commit)
144143

145144

web/logics.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def current_working_on_commit():
3939

4040

4141
def current_progress():
42+
if not source_code_updated(): return 0
4243
progresses = json.loads(gstate.get_progress_list())
4344
progress = gstate.get_current_progress()
4445
if progress:
@@ -64,3 +65,7 @@ def model_evaluation_status():
6465
def baseline_history():
6566
history = json.loads(gstate.get_baseline_history())
6667
return history
68+
69+
70+
def source_code_updated():
71+
return gstate.get_source_code_updated()

web/main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111
"modelce", static_url_path=STATIC_DIR, template_folder=TEMPLATE_DIR)
1212

1313
baseline_commit_url = "https://github.com/Superjomn/paddle-modelci-baseline/commit"
14+
paddle_commit_url = "https://github.com/PaddlePaddle/Paddle/commit"
1415

1516

1617
@app.route('/')
1718
def index():
1819
return render_template(
1920
'dashboard.html',
21+
current_module='dashboard',
22+
paddle_commit_url=paddle_commit_url,
23+
source_code_updated=logics.source_code_updated(),
2024
baseline_commit_url=baseline_commit_url,
2125
last_success_commit=logics.last_success_commit(),
2226
last_fail_commit=logics.last_fail_commit(),
@@ -29,6 +33,7 @@ def index():
2933
def history():
3034
return render_template(
3135
'history.html',
36+
current_module='history',
3237
baseline_commit_url=baseline_commit_url,
3338
baseline_history=logics.baseline_history())
3439

@@ -41,4 +46,4 @@ def serve_static(path):
4146
if __name__ == '__main__':
4247
host = '0.0.0.0'
4348
port = 8080
44-
app.run(debug=True, host=host, port=port)
49+
app.run(debug=False, host=host, port=port)

web/template/base.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE HTML>
22
<html>
3+
<meta http-equiv="refresh" content="6">
34
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
45
<head>
56
<title>PaddlePaddle Model Continuous Evaluation</title>
@@ -117,7 +118,9 @@
117118

118119
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0">
119120
<a class="navbar-brand col-sm-3 col-md-2 mr-0" href="/">ModelCE</a>
121+
<!--
120122
<input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search">
123+
-->
121124
</nav>
122125

123126
<div class="container-fluid">
@@ -126,7 +129,11 @@
126129
<div class="sidebar-sticky">
127130
<ul class="nav flex-column">
128131
<li class="nav-item"> <!-- the main page -->
132+
{% if current_module == "dashboard" %}
129133
<a class="nav-link active" href="/">
134+
{% else %}
135+
<a class="nav-link" href="/">
136+
{% endif %}
130137
<span data-feather="home"></span>
131138
Dashboard
132139
<span class="sr-only">(current)</span>
@@ -142,9 +149,14 @@
142149
-->
143150

144151
<li class="nav-item">
152+
{% if current_module == "history" %}
153+
<a class="nav-link active" href="/history">
154+
{% else %}
145155
<a class="nav-link" href="/history">
156+
{% endif %}
146157
<span data-feather="book"></span>
147158
History
159+
<span class="sr-only">(current)</span>
148160
</a>
149161
</li>
150162
</ul>

web/template/dashboard.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,31 @@ <h1 class="h2">Dashboard</h1>
99
<div class="container-fluid border-bottom">
1010
<div class="row">
1111
<div class="col-sm">
12+
{% if last_success_commit == "none" %}
1213
<span class="badge badge-success">Last success</span> <a href="#" class="alert-link">{{ last_success_commit }}</a>
14+
{% else %}
15+
<span class="badge badge-success">Last success</span> <a href="{{ paddle_commit_url }}/{{ last_success_commit }}" class="alert-link">{{ last_success_commit }}</a>
16+
{% endif %}
1317
</div>
1418
<div class="col-sm">
19+
{% if last_fail_commit == "none" %}
1520
<span class="badge badge-danger">Last fail</span> <a href="#" class="alert-link">{{ last_fail_commit }}</a>
21+
{% else %}
22+
<span class="badge badge-danger">Last fail</span> <a href="{{ paddle_commit_url }}/{{ last_fail_commit }}" class="alert-link">{{ last_fail_commit }}</a>
23+
{% endif %}
1624
</div>
1725
<hr/>
1826
</div>
1927

28+
{%if source_code_updated %}
2029
<div class="row alert alert-primary">
21-
Currently working on &nbsp;<a href="#" class="alert-link">{{ current_working_on_commit }}</a>
30+
Currently working on Paddle version: &nbsp;<a href="#" class="alert-link">{{ current_working_on_commit }}</a>
2231
</div>
32+
{% else %}
33+
<div class="row alert alert-secondary">
34+
Hold, waiting for new source update.
35+
</div>
36+
{% endif %}
2337

2438
<div class="row progress modelce-row">
2539
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="{{ current_progress }}" aria-valuemin=0" aria-valuemax="100" style="width:{{ current_progress }}%">

0 commit comments

Comments
 (0)