Skip to content

Commit fe5e47d

Browse files
authored
Merge pull request #29 from FederatedAI/develop-1.1.1
Prepare to release 1.1.1 to replace 1.1.0 because it fix a bug of fate upgrade manager
2 parents 703ffff + c891336 commit fe5e47d

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

docker-build/modules/fate-upgrade-manager/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ COPY deploy.tar.gz .
88

99
RUN tar -xzf deploy.tar.gz;
1010

11-
FROM centos/python-36-centos7
11+
FROM python:3.8
1212

1313
WORKDIR /
1414
COPY --from=builder /data/projects/fate/deploy/upgrade/sql ./sql

docker-build/modules/fate-upgrade-manager/upgrade-mysql.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@
22
import sys
33
import os
44

5+
from functools import cmp_to_key
6+
7+
8+
def cmp_ver(a, b):
9+
for va, vb in zip(a.split('.'), b.split('.')):
10+
va, vb = int(va), int(vb)
11+
if va > vb:
12+
return 1
13+
if va < vb:
14+
return -1
15+
return 0
16+
17+
18+
def cmp_file_ver(a, b):
19+
return cmp_ver(a.split('-')[0], b.split('-')[0])
20+
521

622
def get_script_list(start_ver, target_ver):
723
sql_script_names = os.listdir("sql")
8-
sql_script_names.sort()
9-
res = []
10-
start_index = -1
11-
end_index = -1
12-
for i in range(len(sql_script_names)):
13-
if sql_script_names[i].startswith(start_ver):
14-
start_index = i
15-
if sql_script_names[i].replace(".sql", "").endswith(target_ver):
16-
end_index = i
17-
if start_index == -1 or end_index == -1 or start_index > end_index:
18-
return res
19-
res = sql_script_names[start_index:end_index+1]
20-
print("will run scripts:")
21-
print(res)
22-
return res
24+
print("FUM upgradeable sql list:", sql_script_names)
25+
inclusive_files = filter(lambda x: cmp_ver(
26+
x.split('-')[0], start_ver) >= 0 and cmp_ver(x.split('-')[1], target_ver) <= 0, sql_script_names)
27+
return sorted(inclusive_files, key=cmp_to_key(cmp_file_ver))
2328

2429

2530
def preprocess_script(script):
@@ -51,7 +56,9 @@ def run_script(script, cursor):
5156

5257
if __name__ == '__main__':
5358
_, user, password, start_ver, end_ver = sys.argv
59+
print("Version upgrade span:", start_ver, end_ver)
5460
scripts_to_run = get_script_list(start_ver, end_ver)
61+
print("Filtered sql list:", scripts_to_run)
5562
mydb = mysql.connector.connect(
5663
host="mysql",
5764
user=user,

0 commit comments

Comments
 (0)