[CPU][Commit slider] Rmtree fixed (#17858)
This commit is contained in:
parent
36625404eb
commit
c0fb831c6e
@ -41,7 +41,7 @@ else:
|
|||||||
if not os.path.exists(workPath):
|
if not os.path.exists(workPath):
|
||||||
os.mkdir(workPath)
|
os.mkdir(workPath)
|
||||||
else:
|
else:
|
||||||
safeClearDir(workPath)
|
safeClearDir(workPath, cfgData)
|
||||||
curPath = os.getcwd()
|
curPath = os.getcwd()
|
||||||
copy_tree(curPath, workPath)
|
copy_tree(curPath, workPath)
|
||||||
scriptName = os.path.basename(__file__)
|
scriptName = os.path.basename(__file__)
|
||||||
@ -54,12 +54,12 @@ else:
|
|||||||
# copy logs and cache back to general repo
|
# copy logs and cache back to general repo
|
||||||
tempLogPath = cfgData["logPath"].format(workPath=workPath)
|
tempLogPath = cfgData["logPath"].format(workPath=workPath)
|
||||||
permLogPath = cfgData["logPath"].format(workPath=curPath)
|
permLogPath = cfgData["logPath"].format(workPath=curPath)
|
||||||
safeClearDir(permLogPath)
|
safeClearDir(permLogPath, cfgData)
|
||||||
copy_tree(tempLogPath, permLogPath)
|
copy_tree(tempLogPath, permLogPath)
|
||||||
|
|
||||||
tempCachePath = cfgData["cachePath"].format(workPath=workPath)
|
tempCachePath = cfgData["cachePath"].format(workPath=workPath)
|
||||||
permCachePath = cfgData["cachePath"].format(workPath=curPath)
|
permCachePath = cfgData["cachePath"].format(workPath=curPath)
|
||||||
safeClearDir(permCachePath)
|
safeClearDir(permCachePath, cfgData)
|
||||||
copy_tree(tempCachePath, permCachePath)
|
copy_tree(tempCachePath, permCachePath)
|
||||||
|
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
@ -67,4 +67,4 @@ else:
|
|||||||
os.path.join(curPath, customCfgPath),
|
os.path.join(curPath, customCfgPath),
|
||||||
follow_symlinks=True,
|
follow_symlinks=True,
|
||||||
)
|
)
|
||||||
safeClearDir(workPath)
|
safeClearDir(workPath, cfgData)
|
||||||
|
@ -81,6 +81,7 @@ def absolutizePaths(cfg):
|
|||||||
pl = sys.platform
|
pl = sys.platform
|
||||||
if pl == "linux" or pl == "linux2":
|
if pl == "linux" or pl == "linux2":
|
||||||
cfg["workPath"] = cfg["linWorkPath"]
|
cfg["workPath"] = cfg["linWorkPath"]
|
||||||
|
cfg["os"] = "linux"
|
||||||
elif pl == "win32":
|
elif pl == "win32":
|
||||||
wp = cfg["winWorkPath"]
|
wp = cfg["winWorkPath"]
|
||||||
wp = "echo {path}".format(path=wp)
|
wp = "echo {path}".format(path=wp)
|
||||||
@ -88,6 +89,7 @@ def absolutizePaths(cfg):
|
|||||||
wp = wp.decode()
|
wp = wp.decode()
|
||||||
wp = wp.rstrip()
|
wp = wp.rstrip()
|
||||||
cfg["workPath"] = wp
|
cfg["workPath"] = wp
|
||||||
|
cfg["os"] = "win"
|
||||||
else:
|
else:
|
||||||
raise CfgError(
|
raise CfgError(
|
||||||
"No support for current OS: {pl}".format(pl=pl)
|
"No support for current OS: {pl}".format(pl=pl)
|
||||||
@ -199,7 +201,7 @@ def runCommandList(commit, cfgData, enforceClean=False):
|
|||||||
raise CmdError(checkOut)
|
raise CmdError(checkOut)
|
||||||
|
|
||||||
|
|
||||||
def fetchAppOutput(cfg):
|
def fetchAppOutput(cfg, commit):
|
||||||
newEnv = os.environ.copy()
|
newEnv = os.environ.copy()
|
||||||
if "envVars" in cfg:
|
if "envVars" in cfg:
|
||||||
for env in cfg["envVars"]:
|
for env in cfg["envVars"]:
|
||||||
@ -208,6 +210,10 @@ def fetchAppOutput(cfg):
|
|||||||
newEnv[envKey] = envVal
|
newEnv[envKey] = envVal
|
||||||
appCmd = cfg["appCmd"]
|
appCmd = cfg["appCmd"]
|
||||||
appPath = cfg["appPath"]
|
appPath = cfg["appPath"]
|
||||||
|
commitLogger = getCommitLogger(cfg, commit)
|
||||||
|
commitLogger.info("Run command: {command}".format(
|
||||||
|
command=appCmd)
|
||||||
|
)
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
appCmd.split(),
|
appCmd.split(),
|
||||||
cwd=appPath,
|
cwd=appPath,
|
||||||
@ -273,12 +279,12 @@ def getActualPath(pathName, cfg):
|
|||||||
return curPath.format(workPath=workPath)
|
return curPath.format(workPath=workPath)
|
||||||
|
|
||||||
|
|
||||||
def safeClearDir(path):
|
def safeClearDir(path, cfg):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
try:
|
if cfg["os"] == "win":
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
except PermissionError:
|
else:
|
||||||
# WA, because of unstability of rmtree()
|
# WA, because of unstability of rmtree()
|
||||||
# in linux environment
|
# in linux environment
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
|
@ -49,7 +49,7 @@ class CheckOutputMode(Mode):
|
|||||||
commit=commit)
|
commit=commit)
|
||||||
)
|
)
|
||||||
handleCommit(commit, cfg)
|
handleCommit(commit, cfg)
|
||||||
checkOut = fetchAppOutput(cfg)
|
checkOut = fetchAppOutput(cfg, commit)
|
||||||
commitLogger.info(checkOut)
|
commitLogger.info(checkOut)
|
||||||
self.setCommitCash(commit, checkOut)
|
self.setCommitCash(commit, checkOut)
|
||||||
stopPattern = cfg["runConfig"]["stopPattern"]
|
stopPattern = cfg["runConfig"]["stopPattern"]
|
||||||
@ -83,7 +83,7 @@ class BenchmarkAppPerformanceMode(Mode):
|
|||||||
foundThroughput = cashedThroughput
|
foundThroughput = cashedThroughput
|
||||||
else:
|
else:
|
||||||
runCommandList(sampleCommit, cfg, enforceClean=True)
|
runCommandList(sampleCommit, cfg, enforceClean=True)
|
||||||
output = fetchAppOutput(cfg)
|
output = fetchAppOutput(cfg, sampleCommit)
|
||||||
commitLogger.info(output)
|
commitLogger.info(output)
|
||||||
foundThroughput = re.search(
|
foundThroughput = re.search(
|
||||||
self.outPattern, output, flags=re.MULTILINE
|
self.outPattern, output, flags=re.MULTILINE
|
||||||
@ -129,12 +129,12 @@ class BenchmarkAppPerformanceMode(Mode):
|
|||||||
commit=commit)
|
commit=commit)
|
||||||
)
|
)
|
||||||
handleCommit(commit, cfg)
|
handleCommit(commit, cfg)
|
||||||
output = fetchAppOutput(cfg)
|
output = fetchAppOutput(cfg, commit)
|
||||||
|
commitLogger.info(output)
|
||||||
foundThroughput = re.search(
|
foundThroughput = re.search(
|
||||||
self.outPattern, output, flags=re.MULTILINE
|
self.outPattern, output, flags=re.MULTILINE
|
||||||
).group(1)
|
).group(1)
|
||||||
curThroughput = float(foundThroughput)
|
curThroughput = float(foundThroughput)
|
||||||
commitLogger.info(output)
|
|
||||||
self.setCommitCash(commit, curThroughput)
|
self.setCommitCash(commit, curThroughput)
|
||||||
return curThroughput
|
return curThroughput
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ class CompareBlobsMode(Mode):
|
|||||||
commit=commit)
|
commit=commit)
|
||||||
)
|
)
|
||||||
runCommandList(commit, cfg, enforceClean=True)
|
runCommandList(commit, cfg, enforceClean=True)
|
||||||
output = fetchAppOutput(cfg)
|
output = fetchAppOutput(cfg, commit)
|
||||||
commitLogger.info(output)
|
commitLogger.info(output)
|
||||||
filename = self.setCommitCash(commit, None)
|
filename = self.setCommitCash(commit, None)
|
||||||
return filename
|
return filename
|
||||||
|
Loading…
Reference in New Issue
Block a user