Skip to content

Commit 606950d

Browse files
authored
[COMMIT SLIDER]Preparation for e2e job (openvinotoolkit#23135)
### Details: - *item1* - *...* ### Tickets: - *ticket-id*
1 parent 6270a59 commit 606950d

13 files changed

+512
-53
lines changed

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import shutil
77
import sys
88
from distutils.dir_util import copy_tree
9+
from distutils.errors import DistutilsFileError
910
from utils.helpers import safeClearDir, getParams
1011

1112
args, cfgData, customCfgPath = getParams()
@@ -21,7 +22,10 @@
2122
from utils.helpers import checkArgAndGetCommits
2223

2324
commitList = []
24-
if args.commitSeq is None:
25+
if "commitList" in cfgData["runConfig"] and\
26+
"explicitList" in cfgData["runConfig"]["commitList"]:
27+
commitList = cfgData["runConfig"]["commitList"]["explicitList"]
28+
elif args.commitSeq is None:
2529
if "getCommitListCmd" in cfgData["runConfig"]["commitList"]:
2630
commitListCmd = cfgData["runConfig"]["commitList"]
2731
commitListCmd = commitListCmd["getCommitListCmd"]
@@ -69,7 +73,11 @@
6973
tempCachePath = cfgData["cachePath"].format(workPath=workPath)
7074
permCachePath = cfgData["cachePath"].format(workPath=curPath)
7175
safeClearDir(permCachePath, cfgData)
72-
copy_tree(tempCachePath, permCachePath)
76+
try:
77+
copy_tree(tempCachePath, permCachePath)
78+
except DistutilsFileError:
79+
# prevent exception raising while cache is empty
80+
pass
7381

7482
try:
7583
shutil.copyfile(

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

+110
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,113 @@ def testBmSteppedBreak2(self):
140140
e.exception.errType,
141141
BmValidationError.BmValErrType.LOW_LOCAL_GAP
142142
)
143+
144+
@skip_commit_slider_devtest
145+
def testForsubstitutionRule(self):
146+
from utils.helpers import applySubstitutionRules
147+
cfg = {
148+
"serviceConfig": {
149+
"previousKey": "previousValue"
150+
},
151+
"wrongDst": "{commitHash1} is unchanged",
152+
"dst": {
153+
"complex": {
154+
"path": [
155+
"{commitHash1} is natural number",
156+
"{commitHash2} is natural number",
157+
"{commitHash1} is {commitHash2}"
158+
]
159+
}
160+
},
161+
"src": {
162+
"complex": {
163+
"path": {
164+
"one": "1",
165+
"two": "2"
166+
}
167+
}
168+
}
169+
}
170+
rules = [
171+
{
172+
"name": "testRule1",
173+
"enabled": True,
174+
"type": "map",
175+
"placeholder": "commitHash1",
176+
"from": "$.src.complex.path",
177+
"to": "$.dst.complex.path"
178+
},
179+
{
180+
"name": "testRule2",
181+
"enabled": True,
182+
"type": "map",
183+
"placeholder": "commitHash2",
184+
"from": "$.src.complex.path",
185+
"to": "$.dst.complex.path"
186+
}
187+
]
188+
def applyByRef(cfg: map, rules: list, substitution: str):
189+
applySubstitutionRules(cfg, rules, substitution)
190+
191+
applyByRef(cfg, rules, "one")
192+
193+
# assert first substitution
194+
self.assertEqual(
195+
cfg["dst"]["complex"]["path"][0],
196+
"1 is natural number"
197+
)
198+
self.assertEqual(
199+
cfg["dst"]["complex"]["path"][1],
200+
"1 is natural number"
201+
)
202+
self.assertEqual(
203+
cfg["dst"]["complex"]["path"][2],
204+
"1 is 1"
205+
)
206+
self.assertEqual(
207+
cfg["wrongDst"],
208+
"{commitHash1} is unchanged"
209+
)
210+
211+
applyByRef(cfg, rules, "two")
212+
213+
# assert second substitution
214+
self.assertEqual(
215+
cfg["dst"]["complex"]["path"][0],
216+
"2 is natural number"
217+
)
218+
self.assertEqual(
219+
cfg["dst"]["complex"]["path"][1],
220+
"2 is natural number"
221+
)
222+
self.assertEqual(
223+
cfg["dst"]["complex"]["path"][2],
224+
"2 is 2"
225+
)
226+
self.assertEqual(
227+
cfg["wrongDst"],
228+
"{commitHash1} is unchanged"
229+
)
230+
231+
@skip_commit_slider_devtest
232+
def testForDeepUpdate(self):
233+
from utils.helpers import deepMapUpdate
234+
cfg = {
235+
"another": {
236+
"path": "not updated"
237+
},
238+
"path": {
239+
"to": {
240+
"placeholder": "not updated"
241+
}
242+
}
243+
}
244+
cfg = deepMapUpdate(cfg, ["path", "to", "placeholder"], "updated")
245+
self.assertEqual(
246+
cfg["path"]["to"]["placeholder"],
247+
"updated"
248+
)
249+
self.assertEqual(
250+
cfg["another"]["path"],
251+
"not updated"
252+
)

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

+2-18
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from os import path
1111
from test_data import TestData
1212
from test_data import TestError
13+
from utils.helpers import formatJSON
1314

1415
sys.path.append('../')
1516
from utils.helpers import getMeaningfullCommitTail
@@ -55,7 +56,6 @@ def makeRepoContent(td: TestData):
5556

5657
td.repoStructure['files'] = formatJSON(
5758
td.repoStructure['files'],
58-
td,
5959
lambda content: content.format(
6060
repoName=td.repoName,
6161
mainFile=td.mainFile)
@@ -92,22 +92,6 @@ def runCmd(cmd, cwd, verbose=False):
9292
proc.communicate()
9393
return output
9494

95-
96-
def formatJSON(content, td: TestData, formatLambda):
97-
if isinstance(content, dict):
98-
for k, value in content.items():
99-
content[k] = formatJSON(value, td, formatLambda)
100-
elif isinstance(content, list):
101-
for id, item in enumerate(content):
102-
content[id] = formatJSON(item, td, formatLambda)
103-
elif isinstance(content, str):
104-
content = formatLambda(content)
105-
else:
106-
# bool or digit object
107-
pass
108-
return content
109-
110-
11195
def createRepo(td: TestData):
11296
repoName = td.repoName
11397
repoPath = td.repoPath
@@ -169,7 +153,7 @@ def getActualCommit(td: TestData):
169153
raise TestError("Running actual commit before expected.")
170154

171155
# prepare config
172-
cfg = formatJSON(td.testCfg, td, td.formatConfig)
156+
cfg = formatJSON(td.testCfg, td.formatConfig)
173157
testCfg = "test_cfg.json"
174158

175159
with open(testCfg, "w+") as customCfg:

src/plugins/intel_cpu/tools/commit_slider/utils/cfg.json

+33-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"utilMap" : {
1515
"map_builder" : "printMap",
1616
"log_parser" : "logParser",
17-
"break_validator": "breakValidator"
17+
"break_validator": "breakValidator",
18+
"e2e_preparator": "getWheelMap"
1819
},
1920
"extendBuildCommand" : false,
2021
"commandList" : [
@@ -77,6 +78,11 @@
7778
"printCSV" : true,
7879
"usePrevRunCache" : false,
7980
"verboseOutput": false,
81+
"venvCfg": {
82+
"venvEnabled": false,
83+
"venvDir": "{workPath}/venv/",
84+
"venvName": "tempVenv"
85+
},
8086
"preliminaryCheckCfg": {
8187
"leftCheck": true,
8288
"rightCheck": false,
@@ -89,17 +95,40 @@
8995
"dlbConfig" : {
9096
"launchedAsJob" : false,
9197
"toolName" : "{e2e|ac} - specified outside tool, supposed to be downloaded by job",
92-
"appPath" : "path, substituted by job"
98+
"wheelVersionsMap": {},
99+
"commonPath": "",
100+
"subPath": "",
101+
"appPath" : "path, substituted by job",
102+
"appCmd": ""
93103
},
94104
"cachedPathConfig": {
95105
"enabled" : false,
96106
"scheme" : "optional | mandatory",
97107
"comment" : "'mandatory' skips lacking hash-appPath pair for given key, 'optional' tries to handle it by building",
98108
"passCmdList": true,
99109
"changeAppPath": true,
100-
"generateMap": false,
101110
"commonPath": "",
102111
"subPath": "",
103112
"cashMap" : {}
104-
}
113+
},
114+
"subscriptions" : [
115+
{
116+
"name": "wheelPathsMap",
117+
"enabled": false
118+
},
119+
{
120+
"name": "wheelVersionsMap",
121+
"enabled": false
122+
}
123+
],
124+
"substitutionRules": [
125+
{
126+
"name": "ruleName",
127+
"enabled": false,
128+
"type": "commit_map | static",
129+
"placeholder": "placeholder",
130+
"from": "$.json.path.expression.to.cfg.value",
131+
"to": "$.json.path.expression.to.commit.map"
132+
}
133+
]
105134
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
import json
5+
import os
6+
7+
8+
class CfgManager():
9+
def __init__(self, cfg) -> None:
10+
self.cfg = cfg
11+
12+
def applyTemplate(self):
13+
if not "template" in self.cfg:
14+
return self.cfg
15+
logPath = self.cfg["logPath"]
16+
tmplName = self.cfg["template"]["name"]
17+
fullCfg = {}
18+
if tmplName == "bm_simple":
19+
fullCfg = self.generatebmSimpleTemplate()
20+
else:
21+
raise Exception(
22+
"Unknown template '{}'".format(tmplName)
23+
)
24+
fullCfg["logPath"] = logPath
25+
return fullCfg
26+
27+
def readJsonTmpl(self, tmplFileName: str):
28+
tmplFileName = os.path.join(
29+
"utils/cfg_samples/", tmplFileName
30+
)
31+
with open(tmplFileName) as cfgFile:
32+
tmplJSON = json.load(cfgFile)
33+
return tmplJSON
34+
35+
def generatebmSimpleTemplate(self):
36+
tmpl = self.cfg["template"]
37+
tmpJSON = self.readJsonTmpl("bm_perf_for_CI.json")
38+
devParam = "perfAppropriateDeviation"
39+
if "appCmd" in tmpl:
40+
tmpJSON["appCmd"] = tmpl["appCmd"]
41+
else:
42+
raise("No 'appcmd' in template")
43+
if devParam in tmpl:
44+
tmpJSON["runConfig"][devParam] = tmpl[devParam]
45+
return tmpJSON
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"appCmd":"{appCmd}",
3+
"makeCmd":"cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=OFF -DTHREADING=TBB -DENABLE_MKL_DNN=ON -DENABLE_CLDNN=OFF -DENABLE_INTEL_GNA=OFF -DENABLE_INTEL_VPU=OFF -DENABLE_INTEL_MYRIAD=OFF -DENABLE_INTEL_MYRIAD_COMMON=OFF -DENABLE_HDDL=OFF -DENABLE_MODELS=OFF -DENABLE_SAMPLES=ON -DENABLE_TESTS=OFF -DENABLE_HETERO=OFF -DENABLE_TEMPLATE=OFF -DENABLE_CPU_DEBUG_CAPS=OFF -DENABLE_DEBUG_CAPS=OFF -DENABLE_OV_CORE_BACKEND_UNIT_TESTS=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 ..",
4+
"runConfig":{
5+
"mode":"bmPerf",
6+
"traversal":"firstFailedVersion",
7+
"perfAppropriateDeviation": 0.05
8+
},
9+
"extendBuildCommand":true
10+
}

src/plugins/intel_cpu/tools/commit_slider/utils/cfg_samples/e2e.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"appPath" : "/<e2e_path>/e2e/frameworks.ai.openvino.tests/e2e_oss/",
33
"appCmd" : "pytest test_dynamism.py <e2e_args>",
44
"envVars" : [
5-
{"name" : "PYTHONPATH", "val" : "/<ov_path>/bin/intel64/Release/python/"},
6-
{"name" : "LD_LIBRARY_PATH", "val" : "/<ov_path>/bin/intel64/Release/"},
7-
{"name" : "MO_ROOT", "val" : "/<ov_path>/tools/mo/openvino/tools/"},
8-
{"name" : "OPENVINO_ROOT_DIR", "val" : "/<ov_path>/"}
5+
{"name" : "PYTHONPATH", "val" : "{gitPath}/bin/intel64/Release/python/"},
6+
{"name" : "LD_LIBRARY_PATH", "val" : "{gitPath}/bin/intel64/Release/"},
7+
{"name" : "MO_ROOT", "val" : "{gitPath}/tools/mo/openvino/tools/"},
8+
{"name" : "OPENVINO_ROOT_DIR", "val" : "{gitPath}/"}
99
],
1010
"makeCmd" : "cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON -DPython3_EXECUTABLE=/usr/bin/python3.8 -DTHREADING=TBB -DENABLE_INTEL_GPU=OFF -DENABLE_SAMPLES=OFF -DENABLE_TESTS=OFF -DENABLE_CPU_DEBUG_CAPS=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 ..",
1111
"runConfig" : {

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

+12-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from abc import ABC
55
import utils.helpers as util
6-
import utils.map_builder as mapBuilder
6+
from utils.subscription import SubscriptionManager
77
from utils.break_validator import validateBMOutput
88
from utils.break_validator import BmValidationError
99
import json
@@ -119,6 +119,14 @@ def prepareRun(self, list, cfg):
119119
c1=newList[0], c2=newList[-1])
120120
)
121121
list = newList
122+
elif self.traversal.isComparative():
123+
raise util.PreliminaryAnalysisError(
124+
"No degradation for reduced interval: \
125+
{i1} and {i2} don't differ".format(
126+
i1=list[0], i2=list[-1]),
127+
util.PreliminaryAnalysisError.\
128+
PreliminaryErrType.NO_DEGRADATION
129+
)
122130
else:
123131
self.preliminaryCheck(list, cfg)
124132
return list
@@ -132,12 +140,9 @@ def normalizeCfg(self, cfg):
132140
# switch off illegal check
133141
if not self.traversal.isComparative():
134142
cfg["checkIfBordersDiffer"] = False
135-
cashCfg = cfg["cachedPathConfig"]
136-
# build cash map
137-
if (cashCfg["enabled"] and cashCfg["generateMap"]):
138-
cfg["cachedPathConfig"]["cashMap"] = mapBuilder(
139-
cashCfg["commonPath"], cashCfg["subPath"]
140-
)
143+
# apply necessary subscriptions for cfg
144+
subManager = SubscriptionManager(cfg)
145+
subManager.apply()
141146
if "modeName" in cfg["skipMode"]:
142147
errorHandlingMode = cfg["skipMode"]["modeName"]
143148
if errorHandlingMode == "skip":

0 commit comments

Comments
 (0)