8c8dd4c005adb96dd72d52450592056655780ee7 lrnassar Mon Mar 24 16:52:08 2025 -0700 Fixing one big problem: I was not going through the 'all history' loop at all due to incorrect variables. And the second change is an improvement to the 20h and all time logic, now it takes the average of the values in that range instead of one discreet data point, refs #32284 diff --git src/utils/qa/hgTracksTiming.py src/utils/qa/hgTracksTiming.py index 42df7cd47b2..ce2cb43e407 100644 --- src/utils/qa/hgTracksTiming.py +++ src/utils/qa/hgTracksTiming.py @@ -22,83 +22,97 @@ bashStdoutt = rawBashOutput.stdout except subprocess.CalledProcessError as e: raise RuntimeError("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output)) return(bashStdoutt) def makeSymLinks(user,save_dir): if user == 'qateam': bash("ln -sf "+save_dir+"*.html /usr/local/apache/htdocs-genecats/qa/test-results/hgTracksTiming/") bash("ln -sf "+save_dir+"*.png /usr/local/apache/htdocs-genecats/qa/test-results/hgTracksTiming/") else: bash("ln -sf "+save_dir+"*.html /cluster/home/"+user+"/public_html/cronResults/hgTracksTiming/") bash("ln -sf "+save_dir+"*.png /cluster/home/"+user+"/public_html/cronResults/hgTracksTiming/") def getLastLinesAndMakeList(file_path, num_lines=20): with open(file_path, "r") as file: - if num_lines == 'all': + if num_lines == 'All': all_lines = file.readlines() # Read all lines in the file else: last_lines = deque(file, maxlen=num_lines) # Read only the last 'num_lines' lines dates = [] times = [] if num_lines == 20: for line in last_lines: # Split the line and extract the date and time parts = line.rstrip().split("\t") dates.append(parts[0]) # First part is the date times.append(float(parts[1].split("s")[0])) # Second part is the time, removing the 's' elif num_lines == 80: + timeToWrite = [] for i, line in enumerate(last_lines): + parts = line.rstrip().split("\t") + time = float(parts[1].split("s")[0]) # Apply logic to every 4th line (0, 4, 8, ...) if i % 4 == 0: - - parts = line.rstrip().split("\t") + timeToWrite.append(time) + averageTime = round(sum(timeToWrite)/len(timeToWrite),1) dates.append(parts[0]) # First part is the date - times.append(float(parts[1].split("s")[0])) # Second part is the time, removing the 's' + times.append(averageTime) + timeToWrite = [] + else: + timeToWrite.append(time) - elif num_lines == 'AllTime/20': + elif num_lines == 'All': #Calculate average times of all lines / 20 total_lines = len(all_lines) # Determine 20 evenly spaced line indices indices = [int(i * total_lines / 20) for i in range(20)] + timeToWrite = [] - for i in indices: - line = all_lines[i] + for i, line in enumerate(all_lines): parts = line.rstrip().split("\t") + time = float(parts[1].split("s")[0]) + + if i in indices: + timeToWrite.append(time) + averageTime = round(sum(timeToWrite)/len(timeToWrite),1) dates.append(parts[0]) # First part is the date - times.append(float(parts[1].split("s")[0])) # Second part is the time, removing the 's' + times.append(averageTime) + timeToWrite = [] + else: + timeToWrite.append(time) return(dates,times) def generateGraphs(user,save_dir,filePath,server): #Create the 3 time scale graphs for each server reportsToGenerate = ['Last 5h','Last 20h','AllTime/20'] n=0 for report in reportsToGenerate: n+=1 # x axis values if report == "Last 5h": dates,times = getLastLinesAndMakeList(filePath, num_lines=20) elif report == "Last 20h": dates,times = getLastLinesAndMakeList(filePath, num_lines=80) - elif report == "All": - dates,times = getLastLinesAndMakeList(filePath, num_lines='all') + elif report == "AllTime/20": + dates,times = getLastLinesAndMakeList(filePath, num_lines='All') x_dates = dates y = times # plotting the points plt.plot(x_dates, y, marker='o') # Rotate date labels for better readability plt.gcf().autofmt_xdate() # naming the x axis plt.xlabel('Date/time') # naming the y axis plt.ylabel("Load time in s") plt.xticks(x_dates)