Skip to content

Commit

Permalink
[Commit Slider] Multimodel support (openvinotoolkit#27279)
Browse files Browse the repository at this point in the history
### Details:
 - *item1*
 - *...*

### Tickets:
 - *ticket-id*
  • Loading branch information
yury-intel authored and NishantPrabhuFujitsu committed Nov 26, 2024
1 parent bc78f78 commit 2e34759
Show file tree
Hide file tree
Showing 11 changed files with 741 additions and 99 deletions.
76 changes: 52 additions & 24 deletions src/plugins/intel_cpu/tools/commit_slider/commit_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@
import sys
from distutils.dir_util import copy_tree
from distutils.errors import DistutilsFileError
from utils.helpers import safeClearDir, getParams
from utils.cfg_manager import CfgManager
from utils.helpers import safeClearDir, getParams, getActualCfg

args, cfgData, customCfgPath = getParams()

# multiconfig handling: fetch actual config by idx
curCfgData = getActualCfg(cfgData, args.multiconfig)

if isinstance(cfgData, list) and args.multiconfig == "undefined":
for idx, _ in enumerate(cfgData):
argString = " ".join(sys.argv)
workPath = os.getcwd()
formattedCmd = "{py} {argString} -x {idx}".format(
py=sys.executable, argString=argString, idx=idx
)
subprocess.call(formattedCmd.split())
exit()

if args.utility != "no_utility":
from utils.helpers import runUtility
runUtility(cfgData, args)
runUtility(curCfgData, args)

elif args.isWorkingDir:
# rerun script from work directory
Expand All @@ -22,41 +36,52 @@
from utils.helpers import checkArgAndGetCommits

commitList = []
if "commitList" in cfgData["runConfig"] and\
"explicitList" in cfgData["runConfig"]["commitList"]:
commitList = cfgData["runConfig"]["commitList"]["explicitList"]
if "commitList" in curCfgData["runConfig"] and\
"explicitList" in curCfgData["runConfig"]["commitList"]:
commitList = curCfgData["runConfig"]["commitList"]["explicitList"]
elif args.commitSeq is None:
if "getCommitListCmd" in cfgData["runConfig"]["commitList"]:
commitListCmd = cfgData["runConfig"]["commitList"]
if "getCommitListCmd" in curCfgData["runConfig"]["commitList"]:
commitListCmd = curCfgData["runConfig"]["commitList"]
commitListCmd = commitListCmd["getCommitListCmd"]
cwd = cfgData["gitPath"]
cwd = curCfgData["gitPath"]
try:
out = subprocess.check_output(commitListCmd.split(), cwd=cwd)
except subprocess.CalledProcessError as e:
msg = "Commit list command caused error"
raise CfgError("{msg} {e}".format(msg=msg, e=str(e)))
out = out.decode("utf-8")
commitList = out.split()
elif "explicitList" in cfgData["runConfig"]["commitList"]:
commitList = cfgData["runConfig"]["commitList"]["explicitList"]
elif "explicitList" in curCfgData["runConfig"]["commitList"]:
commitList = curCfgData["runConfig"]["commitList"]["explicitList"]
else:
raise CfgError("Commit list is mandatory")
else:
commitList = checkArgAndGetCommits(args.commitSeq, cfgData)
commitList = checkArgAndGetCommits(args.commitSeq, curCfgData)

commitList.reverse()
p = Mode.factory(cfgData)
p.run(commitList, cfgData)
p = Mode.factory(curCfgData)
p.run(commitList, curCfgData)
p.printResult()

else:
workPath = cfgData["workPath"]
# prepare run
workPath = curCfgData["workPath"]
if not os.path.exists(workPath):
os.mkdir(workPath)
else:
safeClearDir(workPath, cfgData)
safeClearDir(workPath, curCfgData)
curPath = os.getcwd()
copy_tree(curPath, workPath)
# handle user cache path
tempCachePath = CfgManager.singlestepStrFormat(curCfgData["cachePath"], "workPath", workPath)
permCachePath = CfgManager.singlestepStrFormat(curCfgData["cachePath"], "workPath", curPath)
# setup cache path if specified
if curCfgData['userCachePath']:
permCachePath = curCfgData['userCachePath']
else:
curCfgData['userCachePath'] = permCachePath

# run CS
scriptName = os.path.basename(__file__)
argString = " ".join(sys.argv)
formattedCmd = "{py} {workPath}/{argString} -wd".format(
Expand All @@ -65,14 +90,17 @@
subprocess.call(formattedCmd.split())

# copy logs and cache back to general repo
tempLogPath = cfgData["logPath"].format(workPath=workPath)
permLogPath = cfgData["logPath"].format(workPath=curPath)
safeClearDir(permLogPath, cfgData)
copy_tree(tempLogPath, permLogPath)

tempCachePath = cfgData["cachePath"].format(workPath=workPath)
permCachePath = cfgData["cachePath"].format(workPath=curPath)
safeClearDir(permCachePath, cfgData)
tempLogPath = CfgManager.singlestepStrFormat(curCfgData["logPath"], "workPath", workPath)
permLogPath = CfgManager.singlestepStrFormat(curCfgData["logPath"], "workPath", curPath)

if curCfgData['userLogPath']:
permLogPath = curCfgData['userLogPath']

safeClearDir(permLogPath, curCfgData)
if not curCfgData['clearLogsAposteriori']:
copy_tree(tempLogPath, permLogPath)

safeClearDir(permCachePath, curCfgData)
try:
copy_tree(tempCachePath, permCachePath)
except DistutilsFileError:
Expand All @@ -89,4 +117,4 @@
# prevent exception raising if cfg set up from outer location
pass

safeClearDir(workPath, cfgData)
safeClearDir(workPath, curCfgData)
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

sys.path.append('./')
from test_util import getExpectedCommit,\
getBordersByTestData, getActualCommit
getBordersByTestData, getActualCommit, getCSOutput
from utils.break_validator import validateBMOutput, BmValidationError
from test_data import FirstBadVersionData, FirstValidVersionData,\
BmStableData, BmValidatorSteppedBreakData, BmValidatorSteppedBreakData2,\
BenchmarkAppDataUnstable, BenchmarkAppDataStable, BenchmarkAppNoDegradationData,\
BenchmarkAppUnstableDevData, BenchmarkAppWrongPathData, BenchmarkAppPathFoundData,\
BenchmarkFirstFixedAppData, AcModeData, BenchmarkMetricData

BenchmarkFirstFixedAppData, AcModeData, BenchmarkMetricData, CustomizedLogData, \
MultiConfigData, ConfigMultiplicatorData, ConfigMultiplicatorWithKeyData

class CommitSliderTest(TestCase):
@skip_commit_slider_devtest
Expand All @@ -32,6 +32,40 @@ def testFirstBadVersion(self):
actualCommit, _ = getActualCommit(updatedData)
self.assertEqual(breakCommit, actualCommit)

@skip_commit_slider_devtest
def testCustomizedLog(self):
breakCommit, updatedData = getExpectedCommit(
CustomizedLogData())
actualCommit, _ = getActualCommit(updatedData)
self.assertEqual(breakCommit, actualCommit)

@skip_commit_slider_devtest
def testMultiConfig(self):
_, updatedData = getExpectedCommit(
MultiConfigData())

self.assertEqual(
getCSOutput(updatedData),
"\n\n".join(['cfg #{n}'.format(n=n) for n in range(3)]) + "\n")

@skip_commit_slider_devtest
def testConfigMultiplicatorByKey(self):
from utils.helpers import multiplyCfgByKey
from utils.helpers import deepCopyJSON
testData = ConfigMultiplicatorData()
self.assertEqual(
multiplyCfgByKey(testData.testCfg),
deepCopyJSON(testData.multipliedCfg))

@skip_commit_slider_devtest
def testRunCSMultiplicatedCfgByKey(self):
_, updatedData = getExpectedCommit(
ConfigMultiplicatorWithKeyData())

self.assertEqual(
getCSOutput(updatedData),
"\n\n".join(['cfg #{n}'.format(n=n) for n in range(3)]) + "\n")

@skip_commit_slider_devtest
def testBmUnstable(self):
_, updatedData = getExpectedCommit(
Expand Down Expand Up @@ -323,7 +357,7 @@ def testForDeepUpdate(self):
}
}
}
cfg = deepMapUpdate(cfg, ["path", "to", "placeholder"], "updated")
deepMapUpdate(cfg, ["path", "to", "placeholder"], "updated")
self.assertEqual(
cfg["path"]["to"]["placeholder"],
"updated"
Expand Down
78 changes: 69 additions & 9 deletions src/plugins/intel_cpu/tools/commit_slider/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from enum import Enum
import json
from utils.cfg_manager import CfgManager

class TestData():
__test__ = False
Expand All @@ -21,14 +22,14 @@ def fillActualData(self, markedVersionList):

def formatConfig(self, content):
# redefine for non trivial cases
return content.format(
appCmd="./{}".format(self.repoName),
appPath="tests/{}/build".format(self.repoName),
buildPath="tests/{}/build".format(self.repoName),
gitPath="tests/{}".format(self.repoName),
start=self.start,
end=self.end
)
return CfgManager.multistepStrFormat(content, [
{'p' : 'appCmd', 's' : "./{}".format(self.repoName)},
{'p' : 'appPath', 's' : "tests/{}/build".format(self.repoName)},
{'p' : 'buildPath', 's' : "tests/{}/build".format(self.repoName)},
{'p' : 'gitPath', 's' : "tests/{}".format(self.repoName)},
{'p' : 'start', 's' : self.start},
{'p' : 'end', 's' : self.end}
])

@staticmethod
def checkTestSet():
Expand Down Expand Up @@ -66,7 +67,11 @@ class TestCase(Enum):
BmPathFound = 11,
BmFirstFixed = 12,
BmLatencyMetric = 13,
ACModeData = 14
ACModeData = 14,
CustomizedLog = 15,
MultiConfig = 16,
ConfigMultiplicator = 17,
MultiConfigWithKey = 18

def requireTestData(self, reqLambda):
# mapping json to test data holder
Expand All @@ -91,6 +96,61 @@ def __init__(self):
requireBinarySearchData
)

class CustomizedLogData(TestData):
def getTestCase():
return TestData.TestCase.CustomizedLog

def getTestName(self):
return "CustomizedLog"

def __init__(self):
from test_util import requireBinarySearchData
self.requireTestData(
requireBinarySearchData
)

class MultiConfigData(TestData):
def getTestCase():
return TestData.TestCase.CustomizedLog

def getTestName(self):
return "MultiConfig"

def __init__(self):
from test_util import requireBinarySearchData
self.requireTestData(
requireBinarySearchData
)

class ConfigMultiplicatorWithKeyData(TestData):
def getTestCase():
return TestData.TestCase.MultiConfigWithKey

def getTestName(self):
return "MultiConfigWithKey"

def __init__(self):
from test_util import requireBinarySearchData
self.requireTestData(
requireBinarySearchData
)

class ConfigMultiplicatorData(TestData):
def getTestCase():
return TestData.TestCase.ConfigMultiplicator

def getTestName(self):
return "ConfigMultiplicatorByKey"

def __init__(self):
self.requireTestData(
lambda td, rsc: [
setattr(td, key, rsc[td.getTestName()][key])
for key in [
'multipliedCfg', 'testCfg'
]]
)

class BenchmarkAppDataUnstable(TestData):
def getTestCase():
return TestData.TestCase.BmBinarySearchUnstable
Expand Down
Loading

0 comments on commit 2e34759

Please sign in to comment.