Skip to content

Commit 59d8570

Browse files
committed
.
1 parent 4bb60fb commit 59d8570

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"map_builder" : "printMap",
1818
"log_parser" : "logParser",
1919
"break_validator": "breakValidator",
20-
"e2e_preparator": "getWheelMap"
20+
"e2e_preparator": "getWheelMap",
21+
"replace": "replacePreprocess"
2122
},
2223
"extendBuildCommand" : false,
2324
"commandList" : [

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,13 @@ def safeClearDir(path, cfg):
588588

589589
def runUtility(cfg, args):
590590
modName = args.utility
591+
fullModName = "utils.{un}".format(un=modName)
591592
try:
592-
mod = importlib.import_module(
593-
"utils.{un}".format(un=modName))
593+
if importlib.util.find_spec(fullModName) is not None:
594+
mod = importlib.import_module(fullModName)
595+
else:
596+
mod = importlib.import_module(
597+
"utils.preprocess.{un}".format(un=modName))
594598
utilName = checkAndGetUtilityByName(cfg, modName)
595599
utility = getattr(mod, utilName)
596600
utility(args)
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
11
import re
22
import fileinput
3+
import os
4+
from utils.helpers import CfgError
35

4-
5-
def replace(cfg, commit):
6+
def replace(cfg, commit=None):
67
prepCfg = cfg["runConfig"]["preprocess"]
78
filePath = prepCfg["file"]
9+
curDir = os.path.abspath(os.path.join(
10+
os.path.dirname(__file__), "../../../../../../../"))
11+
filePath = os.path.join(curDir, filePath)
812
pattern = prepCfg["pattern"]
913
replacement = ''
14+
if "replacement" in prepCfg:
15+
replacement = prepCfg["replacement"]
1016
for line in fileinput.input(filePath, inplace=True):
1117
newLine = re.sub(pattern, r'{}'.format(replacement), line, flags=0)
1218
print(newLine, end='')
19+
20+
# example: python3 -m commit_slider -u replace -file src/plugins/intel_cpu/src/graph.cpp -pattern "\!node->isDynamicNode\(\)\ &&\ \!node->isExecutable\(\)\ &&\ \!node->isInPlace\(\)" -replacement "false"
21+
def replacePreprocess(args):
22+
argDict = vars(args)
23+
if "-file" not in argDict:
24+
raise CfgError("No 'file' for replace-pp provided")
25+
if "-pattern" not in argDict:
26+
raise CfgError("No 'pattern' for replace-pp provided")
27+
28+
tmpCfg = { "runConfig": { "preprocess" : {
29+
"file" : argDict["-file"],
30+
"pattern" : argDict["-pattern"],
31+
"replacement" : argDict["-replacement"] if "-replacement" in argDict else ''
32+
}}}
33+
replace(tmpCfg)

0 commit comments

Comments
 (0)