Skip to content

Commit a998c28

Browse files
yury-intelAsyaPronina
authored andcommitted
[Commit Slider] AC / e2e compatibility (openvinotoolkit#24410)
### Details: - *tool - specific substitutions moved to config*
1 parent 9e59bf7 commit a998c28

File tree

6 files changed

+281
-18
lines changed

6 files changed

+281
-18
lines changed

src/plugins/intel_cpu/tools/commit_slider/tests/commit_slider_test.py

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def testBmSteppedBreak2(self):
142142
)
143143

144144
@skip_commit_slider_devtest
145-
def testForsubstitutionRule(self):
145+
def testForMapSubstitutionRule(self):
146146
from utils.helpers import applySubstitutionRules
147147
cfg = {
148148
"serviceConfig": {
@@ -228,6 +228,74 @@ def applyByRef(cfg: map, rules: list, substitution: str):
228228
"{commitHash1} is unchanged"
229229
)
230230

231+
@skip_commit_slider_devtest
232+
def testForStaticSubstitutionRule(self):
233+
from utils.helpers import applySubstitutionRules
234+
cfg = {
235+
"serviceConfig": {
236+
"previousKey": "previousValue"
237+
},
238+
"wrongDst": "{pathOne} is unchanged",
239+
"dst": {
240+
"complex": {
241+
"path": [
242+
"{pathOne} is natural number",
243+
"{pathTwo} is natural number",
244+
"{pathOne} is not {pathTwo}"
245+
]
246+
}
247+
},
248+
"src": {
249+
"complex": {
250+
"path": {
251+
"one": "1",
252+
"two": "2"
253+
}
254+
}
255+
}
256+
}
257+
rules = [
258+
{
259+
"name": "testRule1",
260+
"enabled": True,
261+
"type": "static",
262+
"placeholder": "pathOne",
263+
"from": "$.src.complex.path.one",
264+
"to": "$.dst.complex.path"
265+
},
266+
{
267+
"name": "testRule2",
268+
"enabled": True,
269+
"type": "static",
270+
"placeholder": "pathTwo",
271+
"from": "$.src.complex.path.two",
272+
"to": "$.dst.complex.path"
273+
}
274+
]
275+
def applyByRef(cfg: map, rules: list, substitution: str):
276+
applySubstitutionRules(cfg, rules, substitution)
277+
278+
applyByRef(cfg, rules, "mustBeIgnored")
279+
280+
# assert substitutions
281+
self.assertEqual(
282+
cfg["dst"]["complex"]["path"][0],
283+
"1 is natural number"
284+
)
285+
286+
self.assertEqual(
287+
cfg["dst"]["complex"]["path"][1],
288+
"2 is natural number"
289+
)
290+
self.assertEqual(
291+
cfg["dst"]["complex"]["path"][2],
292+
"1 is not 2"
293+
)
294+
self.assertEqual(
295+
cfg["wrongDst"],
296+
"{pathOne} is unchanged"
297+
)
298+
231299
@skip_commit_slider_devtest
232300
def testForDeepUpdate(self):
233301
from utils.helpers import deepMapUpdate

src/plugins/intel_cpu/tools/commit_slider/utils/cfg_manager.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,26 @@ class CfgManager():
99
def __init__(self, cfg) -> None:
1010
self.cfg = cfg
1111

12+
@staticmethod
13+
def multistepStrFormat(input: str, placeholder: str, substitution: str):
14+
return input.replace(
15+
'{}{}{}'.format('{', placeholder, '}'),
16+
substitution
17+
)
18+
1219
def applyTemplate(self):
1320
if not "template" in self.cfg:
1421
return self.cfg
1522
logPath = self.cfg["logPath"]
1623
tmplName = self.cfg["template"]["name"]
1724
fullCfg = {}
25+
# todo: generalize tmplcfg generator
1826
if tmplName == "bm_simple":
1927
fullCfg = self.generatebmSimpleTemplate()
28+
elif tmplName == "e2e":
29+
fullCfg = self.generateE2ETemplate()
30+
elif tmplName == "bm_functional":
31+
fullCfg = self.generatebmFunctionalTemplate()
2032
else:
2133
raise Exception(
2234
"Unknown template '{}'".format(tmplName)
@@ -32,6 +44,45 @@ def readJsonTmpl(self, tmplFileName: str):
3244
tmplJSON = json.load(cfgFile)
3345
return tmplJSON
3446

47+
def generateE2ETemplate(self):
48+
tmpl = self.cfg["template"]
49+
tmpJSON = self.readJsonTmpl("e2e_for_CI.json")
50+
51+
if "errorPattern" in tmpl and\
52+
"precommitPath" in tmpl and\
53+
"testCmd" in tmpl:
54+
tmpJSON["runConfig"]["stopPattern"] = tmpl["errorPattern"]
55+
tmpJSON["dlbConfig"]["commonPath"] = tmpl["precommitPath"]
56+
tmpJSON["cachedPathConfig"]["commonPath"] = tmpl["precommitPath"]
57+
tmpJSON["appCmd"] = CfgManager.multistepStrFormat(
58+
tmpJSON["appCmd"],
59+
tmpl["appCmd"],
60+
"testCmd"
61+
)
62+
else:
63+
raise("Template is incomplete.")
64+
subPath = "private_linux_manylinux2014_release/"
65+
if "subPath" in tmpl:
66+
subPath = tmpl["subPath"]
67+
tmpJSON["dlbConfig"]["subPath"] = subPath
68+
tmpJSON["cachedPathConfig"]["subPath"] = subPath
69+
70+
return tmpJSON
71+
72+
def generatebmFunctionalTemplate(self):
73+
tmpl = self.cfg["template"]
74+
tmpJSON = self.readJsonTmpl("bm_output.json")
75+
stopPattern = "stopPattern"
76+
if "appCmd" in tmpl:
77+
tmpJSON["appCmd"] = tmpl["appCmd"]
78+
else:
79+
raise("No 'appcmd' in template")
80+
if stopPattern in tmpl:
81+
tmpJSON["runConfig"][stopPattern] = tmpl[stopPattern]
82+
else:
83+
raise("No 'stopPattern' in template")
84+
return tmpJSON
85+
3586
def generatebmSimpleTemplate(self):
3687
tmpl = self.cfg["template"]
3788
tmpJSON = self.readJsonTmpl("bm_perf_for_CI.json")
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"appCmd":"source {venvName}/bin/activate && cd {appPath} && {py} -m pip install --upgrade pip && {py} -m pip install openvino-dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=={wheelVersion} --find-links={precommitPath}wheels/ && {py} -m pip install -r requirements_dev.txt && {testCmd}",
3+
"venvCfg":{
4+
"venvEnabled":true,
5+
"venvDir":"{workPath}/venv/",
6+
"venvName":"tempVenv"
7+
},
8+
"commandList":[
9+
10+
],
11+
"runConfig":{
12+
"mode":"checkOutput",
13+
"traversal":"firstFailedVersion",
14+
"stopPattern":"{ErrorPattern}"
15+
},
16+
"dlbConfig":{
17+
"launchedAsJob":true,
18+
"toolName":"ac",
19+
"wheelVersionsMap":{
20+
21+
},
22+
"commonPath":"{precommitPath}",
23+
"subPath":"{subPath}",
24+
"appPath":"",
25+
"appCmd":""
26+
},
27+
"cachedPathConfig":{
28+
"enabled":true,
29+
"scheme":"mandatory",
30+
"passCmdList":false,
31+
"changeAppPath":false,
32+
"commonPath":"{precommitPath}",
33+
"subPath":"{subPath}",
34+
"cashMap":{
35+
36+
}
37+
},
38+
"substitutionRules":[
39+
{
40+
"name":"precommitPath",
41+
"enabled":true,
42+
"type":"map",
43+
"placeholder":"precommitPath",
44+
"from":"$.cachedPathConfig.cashMap",
45+
"to":"$.appCmd"
46+
},
47+
{
48+
"name":"wheelVersion",
49+
"enabled":true,
50+
"type":"map",
51+
"placeholder":"wheelVersion",
52+
"from":"$.dlbConfig.wheelVersionsMap",
53+
"to":"$.appCmd"
54+
},
55+
{
56+
"name":"command line for client application",
57+
"enabled":true,
58+
"type":"static",
59+
"placeholder":"appCmd",
60+
"from":"$.dlbConfig.appCmd",
61+
"to":"$.appCmd"
62+
},
63+
{
64+
"name":"path to AC requirements",
65+
"enabled":true,
66+
"type":"static",
67+
"placeholder":"toolPath",
68+
"from":"$.dlbConfig.toolPath",
69+
"to":"$.appCmd"
70+
}
71+
],
72+
"subscriptions":[
73+
{
74+
"name":"wheelPathsMap",
75+
"enabled":true
76+
},
77+
{
78+
"name":"wheelVersionsMap",
79+
"enabled":true
80+
}
81+
],
82+
"verboseOutput":false
83+
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
2-
"appCmd" : "./benchmark_app -m <model_path> -d CPU -t 10",
2+
"appCmd" : "{appCmd}",
33
"makeCmd" : "cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=OFF -DTHREADING=TBB -DENABLE_INTEL_GPU=OFF -DENABLE_SAMPLES=ON -DENABLE_TESTS=OFF -DENABLE_HETERO=OFF -DENABLE_TEMPLATE=OFF -DENABLE_CPU_DEBUG_CAPS=OFF -DENABLE_DEBUG_CAPS=OFF -DENABLE_OPENVINO_DEBUG=OFF -DCMAKE_CXX_FLAGS=-Wno-deprecated -DCMAKE_C_FLAGS=-Wno-deprecated -DCMAKE_CXX_FLAGS=-Wno-deprecated-declarations -DCMAKE_C_FLAGS=-Wno-deprecated-declarations ..",
44
"runConfig" : {
55
"commitList" : {
66
"getCommitListCmd" : "git log <start_commit>..<end_commit> --boundary --pretty=\"%h\""
77
},
88
"mode" : "checkOutput",
99
"traversal" : "firstFailedVersion",
10-
"stopPattern" : "(.)*<bm_error_message>(.)*"
11-
}
10+
"stopPattern" : "(.)*{bm_error_message}(.)*"
11+
},
12+
"extendBuildCommand":true
1213
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"appCmd":"source {venvName}/bin/activate && cd {appPath} && {py} -m pip install --upgrade pip && {py} -m pip install openvino-dev[caffe,kaldi,mxnet,onnx,pytorch,tensorflow2]=={wheelVersion} --find-links={precommitPath}wheels/ && {py} -m pip install -r requirements_dev.txt && {testCmd}",
3+
"venvCfg":{
4+
"venvEnabled":true,
5+
"venvDir":"{workPath}/venv/",
6+
"venvName":"tempVenv"
7+
},
8+
"commandList":[
9+
10+
],
11+
"runConfig":{
12+
"mode":"checkOutput",
13+
"traversal":"firstFailedVersion",
14+
"stopPattern":"{ErrorPattern}"
15+
},
16+
"dlbConfig":{
17+
"launchedAsJob":true,
18+
"toolName":"e2e",
19+
"wheelVersionsMap":{
20+
21+
},
22+
"commonPath":"{precommitPath}",
23+
"subPath":"{subPath}",
24+
"appPath":"",
25+
"appCmd":""
26+
},
27+
"cachedPathConfig":{
28+
"enabled":true,
29+
"scheme":"mandatory",
30+
"passCmdList":false,
31+
"changeAppPath":false,
32+
"commonPath":"{precommitPath}",
33+
"subPath":"{subPath}",
34+
"cashMap":{
35+
36+
}
37+
},
38+
"substitutionRules":[
39+
{
40+
"name":"precommitPath",
41+
"enabled":true,
42+
"type":"map",
43+
"placeholder":"precommitPath",
44+
"from":"$.cachedPathConfig.cashMap",
45+
"to":"$.appCmd"
46+
},
47+
{
48+
"name":"wheelVersion",
49+
"enabled":true,
50+
"type":"map",
51+
"placeholder":"wheelVersion",
52+
"from":"$.dlbConfig.wheelVersionsMap",
53+
"to":"$.appCmd"
54+
}
55+
],
56+
"subscriptions":[
57+
{
58+
"name":"wheelPathsMap",
59+
"enabled":true
60+
},
61+
{
62+
"name":"wheelVersionsMap",
63+
"enabled":true
64+
}
65+
],
66+
"verboseOutput":false
67+
}

src/plugins/intel_cpu/tools/commit_slider/utils/helpers.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,9 @@ def fetchAppOutput(cfg, commit):
290290
for item in [
291291
{"src": cfg["venvCfg"]["venvName"], "dst": "venvName"},
292292
{"src": cfg["appPath"], "dst": "appPath"},
293-
{"src": sys.executable, "dst": "py"},
294-
# for AC case
295-
{"src": cfg["dlbConfig"]["appCmd"], "dst": "appCmd"},
296-
{"src": cfg["dlbConfig"]["toolPath"], "dst": "toolPath"}
293+
{"src": sys.executable, "dst": "py"}
297294
]:
298-
appCmd = multistepStrFormat(
295+
appCmd = CfgManager.multistepStrFormat(
299296
appCmd,
300297
item["dst"],
301298
item["src"]
@@ -646,7 +643,8 @@ def formatJSON(content, formatLambda):
646643
return content
647644

648645
def applySubstitutionRules(cfg: map, rules: list, commit: str=None):
649-
# if commit is None, the rule is considered as static,
646+
# if commit is None or rule['type'] == 'static',
647+
# the rule is considered as static,
650648
# substitution proceeds as simple string replacing
651649

652650
serviceCfg = cfg["serviceConfig"]
@@ -682,14 +680,15 @@ def applySubstitutionRules(cfg: map, rules: list, commit: str=None):
682680
srcPos = srcPos[item]
683681
for item in pathToDst:
684682
dstPos = dstPos[item]
683+
ruleIsStatic = True if rule["type"] == "static" else False
685684
dstPos = formatJSON(
686685
dstPos,
687686
lambda content:
688-
multistepStrFormat(
687+
CfgManager.multistepStrFormat(
689688
content,
690689
rule["placeholder"],
691690
getMapValueByShortHash(srcPos, commit)\
692-
if commit is not None\
691+
if commit is not None and not ruleIsStatic\
693692
else srcPos
694693
)
695694
)
@@ -704,12 +703,6 @@ def getMapValueByShortHash(map: dict, commit: str):
704703
commit, map.keys()
705704
))
706705

707-
def multistepStrFormat(input: str, placeholder: str, substitution: str):
708-
return input.replace(
709-
'{}{}{}'.format('{', placeholder, '}'),
710-
substitution
711-
)
712-
713706
def deepMapUpdate(content: map, path: list, substitution):
714707
if not path:
715708
return substitution

0 commit comments

Comments
 (0)