Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post binary sizes to dashboard database #1517

Merged
merged 74 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
48dd7c8
commented out part of cpu pipeline, added azure blob upload
shahasad Jun 22, 2019
c496a1a
fix indentation
shahasad Jun 22, 2019
28abff1
Merge branch 'master' of https://github.com/Microsoft/onnxruntime int…
shahasad Jun 24, 2019
c82cbdd
dependecy added
shahasad Jun 26, 2019
da5b6c7
use v-2 of the azure file copy task instead of v-3
shahasad Jun 26, 2019
1bc927d
use hosted agent for the copy task
shahasad Jun 26, 2019
ec91daa
use latest windows hosted agent
shahasad Jun 26, 2019
3aaf88b
do without waiting for build
shahasad Jun 26, 2019
38cd7bc
add dependency to build for copy job
shahasad Jun 26, 2019
33fd354
try a file without build
shahasad Jun 26, 2019
f6202c7
try some wildcard file
shahasad Jun 26, 2019
e172399
added the whole pipeline
shahasad Jun 27, 2019
e9a7ef1
fix syntax error
shahasad Jun 27, 2019
1eafb26
fix syntax error more
shahasad Jun 27, 2019
d55993b
skip linux ci dev
shahasad Jun 27, 2019
5a1c427
remove linux
shahasad Jun 27, 2019
5c76212
finalized, cleaned up
shahasad Jun 27, 2019
ff1174b
Merge branch 'master' of https://github.com/Microsoft/onnxruntime int…
shahasad Jun 27, 2019
5079070
make the publish task conditional on signing
shahasad Jun 27, 2019
d110c2f
Merge branch 'master' of https://github.com/Microsoft/onnxruntime int…
shahasad Jul 13, 2019
23e9342
added job name parameters
shahasad Jul 19, 2019
807c4b2
Merge branch 'master' into dev/shahasad/publish-nuget-package-to-azur…
shahasad Jul 19, 2019
51a3918
some changes in cpu yml
shahasad Jul 21, 2019
770734f
Merge branch 'master' of https://github.com/Microsoft/onnxruntime int…
shahasad Jul 22, 2019
8447539
stripped off part of the pipeline for testing
shahasad Jul 23, 2019
13c1ecf
fixes
shahasad Jul 23, 2019
e71351e
Merge branch 'master' of https://github.com/Microsoft/onnxruntime int…
shahasad Jul 23, 2019
f663ca2
use win-cpu agent pool
shahasad Jul 23, 2019
ddeb62b
revert last
shahasad Jul 23, 2019
49f9827
fix agent pool in win-ci
shahasad Jul 23, 2019
839bf07
disable others, just check conda and python
shahasad Jul 23, 2019
edf631b
some more log
shahasad Jul 23, 2019
f7e2211
some more log
shahasad Jul 23, 2019
f6291c5
some more log
shahasad Jul 23, 2019
dc6170e
cleanup
shahasad Jul 23, 2019
71de71c
add condabin path
shahasad Jul 23, 2019
23da3e5
remove workingdir
shahasad Jul 23, 2019
f20c8e4
more log
shahasad Jul 23, 2019
f5a10d6
more log
shahasad Jul 24, 2019
fe2b570
more log
shahasad Jul 24, 2019
65f0638
more log
shahasad Jul 24, 2019
cdc4764
update
shahasad Jul 24, 2019
df94bcc
update
shahasad Jul 24, 2019
12c3b21
update py script
shahasad Jul 24, 2019
a403dca
more log
shahasad Jul 24, 2019
2f4ecd9
more log
shahasad Jul 24, 2019
48964d9
try all packaging with 7zip
shahasad Jul 24, 2019
f14f404
add all tests too
shahasad Jul 24, 2019
e7de1d0
enable tests
shahasad Jul 24, 2019
a7c22dd
enable tests
shahasad Jul 24, 2019
2a4db29
some more log
shahasad Jul 24, 2019
ea30689
some more log
shahasad Jul 24, 2019
ee8c842
some more log
shahasad Jul 24, 2019
1a35e78
use for /R loop
shahasad Jul 24, 2019
1ecde0a
updated the python script. templatized the solution
shahasad Jul 25, 2019
5711b33
format fix
shahasad Jul 25, 2019
64e7e0c
format fix
shahasad Jul 25, 2019
a72b957
try debug
shahasad Jul 25, 2019
2df53dc
try debug
shahasad Jul 25, 2019
ae1ca4c
added more log
shahasad Jul 25, 2019
681cfc6
fixed bugs in the py script
shahasad Jul 27, 2019
9d751d7
merge from master
shahasad Jul 27, 2019
f4c38c5
check env on win ci machine
shahasad Jul 27, 2019
c391d76
try installing python and conda
shahasad Jul 27, 2019
7d318a9
try installing python and conda
shahasad Jul 27, 2019
3848aba
cleanup
shahasad Jul 27, 2019
f6fe97d
check env
shahasad Jul 27, 2019
7244f11
echo
shahasad Jul 28, 2019
24cb52c
add the variable group
shahasad Jul 28, 2019
8a77126
cleaned up
shahasad Jul 28, 2019
632dc11
fix the script to get the bin size
shahasad Jul 28, 2019
2a8ea31
cleanup
shahasad Jul 29, 2019
21d2b27
revert changes in the test scripts
shahasad Jul 29, 2019
19502a7
checkout test-linux from master
shahasad Jul 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tools/ci_build/github/azure-pipelines/nuget/templates/cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ jobs:
- MacOS_CI_Dev
condition: succeeded()
steps:

- task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact - NuGet'
inputs:
artifactName: 'drop-nuget'
targetPath: '$(Build.BinariesDirectory)/nuget-artifact'
continueOnError: true


- task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact - Win-x86'
inputs:
Expand Down Expand Up @@ -150,4 +152,25 @@ jobs:
artifactName: 'drop-signed-nuget'
targetPath: '$(Build.ArtifactStagingDirectory)'


- template: test_all_os.yml

- job: Publish_NuGet_Package_And_Report
variables:
- group: Dashboard_MySQL_Secret
condition: ${{ parameters.DoEsrp }}
pool:
name: Hosted Windows 2019 with VS2019
demands: azureps
dependsOn:
- NuGet_Test_Win
- NuGet_Test_Linux
- NuGet_Test_MacOS
steps:

- template: ../../templates/set-version-number-variables-step.yml
- template: upload-binary-sizes-from-nuget-package.yml
parameters:
gitCommitHash: $(OnnxRuntimeGitCommitHashShort)


Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
parameters:
gitCommitHash: ''

steps:
- task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact - Signed NuGet Package'
inputs:
artifactName: 'drop-signed-nuget'
targetPath: '$(Build.BinariesDirectory)/nuget-artifact/final-package'

- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
architecture: 'x64'

- task: CmdLine@1
displayName: 'Install conda modules mysql-connector-python'
inputs:
filename: '%CONDA%\condabin\conda.bat'
arguments: 'install -q --insecure -y mysql-connector-python'
timeoutInMinutes: 10

- task: CmdLine@2
displayName: 'Post binary sizes to the dashboard database using command line'
inputs:
script: |
echo changing directory to artifact download path
pushd $(Build.BinariesDirectory)\nuget-artifact\final-package
echo processing nupkg
FOR /R %%i IN (*.nupkg) do (
echo processing %%~ni.nupkg
copy %%~ni.nupkg %%~ni.zip
echo copied to zip
echo listing lib files in the zip
REM use a single .csv file to put the data
echo os,arch,build_config,size > binary_size_data.txt
7z.exe l -slt %%~ni.zip runtimes\linux-x64\native\libonnxruntime.so | findstr /R /C:"^Size = [0-9]*" | for /F "tokens=3" %%a in ('more') do if not "%%a" == "" echo linux,x64,openmp,%%a >> binary_size_data.txt
7z.exe l -slt %%~ni.zip runtimes\linux-x86\native\libonnxruntime.so | findstr /R /C:"^Size = [0-9]*" | for /F "tokens=3" %%a in ('more') do if not "%%a" == "" echo linux,x86,openmp,%%a >> binary_size_data.txt
7z.exe l -slt %%~ni.zip runtimes\osx-x64\native\libonnxruntime.dylib | findstr /R /C:"^Size = [0-9]*" | for /F "tokens=3" %%a in ('more') do if not "%%a" == "" echo osx,x64,openmp,%%a >> binary_size_data.txt
7z.exe l -slt %%~ni.zip runtimes\win-x64\native\onnxruntime.dll | findstr /R /C:"^Size = [0-9]*" | for /F "tokens=3" %%a in ('more') do if not "%%a" == "" echo win,x64,openmp,%%a >> binary_size_data.txt
7z.exe l -slt %%~ni.zip runtimes\win-x86\native\onnxruntime.dll | findstr /R /C:"^Size = [0-9]*" | for /F "tokens=3" %%a in ('more') do if not "%%a" == "" echo win,x86,openmp,%%a >> binary_size_data.txt
echo calling python script to post to database
%CONDA%\python.exe $(Build.SourcesDirectory)\tools\ci_build\github\windows\post_binary_sizes_to_dashboard.py --commit_hash=${{ parameters.gitCommitHash }} --size_data_file=binary_size_data.txt --build_project=Lotus --build_id=$(Build.BuildId)
)

env:
DASHBOARD_MYSQL_ORT_PASSWORD: $(dashboard-mysql-ort-password)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ steps:
FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse HEAD`) DO (
@echo ##vso[task.setvariable variable=OnnxRuntimeGitCommitHash;]%%F
)

FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse --short HEAD`) DO (
@echo ##vso[task.setvariable variable=OnnxRuntimeGitCommitHashShort;]%%F
)

workingDirectory: '$(Build.SourcesDirectory)'
condition: eq(variables['Agent.OS'], 'Windows_NT')
Expand All @@ -26,5 +30,8 @@ steps:
_OnnxRuntimeGitCommitHash=$(git rev-parse HEAD)
echo "##vso[task.setvariable variable=OnnxRuntimeGitCommitHash;]$_OnnxRuntimeGitCommitHash"

_OnnxRuntimeGitCommitHash=$(git rev-parse --short=8 HEAD)
echo "##vso[task.setvariable variable=OnnxRuntimeGitCommitHashShort;]$_OnnxRuntimeGitCommitHash"

workingDirectory: '$(Build.SourcesDirectory)'
condition: not(eq(variables['Agent.OS'], 'Windows_NT'))
2 changes: 2 additions & 0 deletions tools/ci_build/github/azure-pipelines/templates/win-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ parameters:
MsbuildArguments: '/m'
EnvSetupScript: 'setup_env.bat'
CudaVersion: ''
AgentPool: 'Win-CPU'

jobs:
- job: ${{ parameters.JobName }}
timeoutInMinutes: 120
pool: ${{ parameters.AgentPool }}
variables:
buildDirectory: '$(Build.BinariesDirectory)'
BuildCommand: ${{ parameters.BuildCommand }}
Expand Down
110 changes: 110 additions & 0 deletions tools/ci_build/github/windows/post_binary_sizes_to_dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.


import argparse
import mysql.connector
import xml.etree.ElementTree as ET
import sys
import os

def parse_arguments():
parser = argparse.ArgumentParser(description="ONNXRuntime binary size uploader for dashboard")
parser.add_argument("--commit_hash", help="Full Git commit hash")
parser.add_argument("--build_project", default='Lotus', choices=['Lotus','onnxruntime'], help="Lotus or onnxruntime build project, to construct the build URL")
parser.add_argument("--build_id", help="Build Id")
parser.add_argument("--size_data_file", help="Path to file that contains the binary size data")

return parser.parse_args()

# Assumes size_data_file is a csv file with a header line, containing binary sizes and other attributes
# CSV fields are:
# os,arch,build_config,size
# No empty line or space between fields expected
def get_binary_sizes(size_data_file):
binary_size = []
with open(size_data_file, 'r') as f:
line = f.readline()
headers = line.strip().split(',')
while line:
line = f.readline()
if not line:
break;
linedata = line.strip().split(',')
tablerow = {}
for i in range(0,len(headers)):
if headers[i] == 'size':
tablerow[headers[i]] = int(linedata[i])
else:
tablerow[headers[i]] = linedata[i]
binary_size.append(tablerow)
return binary_size


def write_to_db(binary_size_data, args):
# connect to database

cnx = mysql.connector.connect(
user='ort@onnxruntimedashboard',
password=os.environ.get('DASHBOARD_MYSQL_ORT_PASSWORD'),
host='onnxruntimedashboard.mysql.database.azure.com',
database='onnxruntime')

try:
cursor = cnx.cursor()

#delete old records
delete_query = ('DELETE FROM onnxruntime.binary_size '
'WHERE build_time < DATE_SUB(Now(), INTERVAL 30 DAY);'
)

cursor.execute(delete_query)

#insert current records
for row in binary_size_data:
insert_query = ('INSERT INTO onnxruntime.binary_size '
'(build_time, build_project, build_id, commit_id, os, arch, build_config, size) '
'VALUES (Now(), "%s", "%s", "%s", "%s", "%s", "%s", %d) '
'ON DUPLICATE KEY UPDATE '
'build_time=Now(), build_project="%s", build_id="%s", size=%d;'
) % (
args.build_project,
args.build_id,
args.commit_hash,
row['os'],
row['arch'],
row['build_config'],
row['size'],

args.build_project,
args.build_id,
row['size']
)
cursor.execute(insert_query)

cnx.commit()

# # Use below for debugging:
# cursor.execute('select * from onnxruntime.binary_size')
# for r in cursor:
# print(r)

cursor.close()
cnx.close()
except BaseException as e:
cnx.close()
raise e


if __name__ == "__main__":
try:
args = parse_arguments()
binary_size_data = get_binary_sizes(args.size_data_file)
write_to_db(binary_size_data, args)
except BaseException as e:
print(str(e))
sys.exit(1)