-
Notifications
You must be signed in to change notification settings - Fork 80
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
Regression Test repo pull request #232
Changes from 64 commits
9f4aa19
2dddb3d
de82a6e
4fce13e
e299787
5bd25ad
04d6799
e910514
ecf2842
15cf074
5efa887
d619c58
87c3d8f
d430f36
d4700c3
ab73eab
1607ca2
17e9b2a
c69fd4e
6c0304b
97adea9
d64468e
36de2ee
51f02b9
745cc01
59897e7
603297a
1fed0d6
2fca15b
e78244f
e2de131
d399400
2b76427
b55904d
0c0dc42
44e8da9
ab2ec5b
ef02e44
6d5866c
1b5dbb8
8bd8b6c
eda912e
aa0c58e
c29ff42
50a01f4
e693be6
5392f2d
7bbae8d
4ebdf39
85a1622
6ff6d27
6a6c702
84f4be7
1b3edc6
6eb51a3
9c14f72
e33a502
76e2c99
406a4fa
27e50ba
35399b3
17e626c
bd7e579
03bde4f
4b77d4a
8127141
ffe19b8
9ea8b83
43863ce
6f6005e
59d900e
cf2430a
809854a
cdc3049
bb4958c
ac24e2a
77b63b7
3098dd5
332cd9a
f754a24
74e1ba0
938bf0a
50f7389
b740448
2189f71
0e2c8bc
0d2ca13
8dd6656
611ffe4
61b0473
66f6a55
cc40364
c9137d1
5093a52
2ec9073
06d1e9e
9fc44ea
e2f36b9
1107833
674b983
0111793
9a041ca
a5ccc65
d5e9ded
b29725b
b3f12c0
2191adb
a14fd15
557fb79
504e3b0
7359af9
0908dfb
7456409
2869469
4e81031
a61cb73
a4fbfd9
f9ebc29
0b72330
f9711b2
3140b3f
2cca234
4c21dfb
84d6b5a
e4d453f
b9bb091
3d5871c
d83b837
1c34312
4c3e87f
5a341dc
893817c
6f56b4d
fb9239d
563d4f0
ca44ec9
111c5ff
f782e26
9ec1bb7
bc70e50
af0896f
72eaa7d
84eb8b5
f6fcca8
b22d1a7
c728c2e
a580101
9fce294
2651656
bc2f3ab
1c83db7
3ad7f82
a51667a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Regression Test | ||
|
||
The regression test for the `ai8x-training` repository is tested when there is a pull request for the `develop` branch of `MaximIntegratedAI/ai8x-training` by triggering `test.yaml` GitHub actions. | ||
|
||
## Last Tested Code | ||
|
||
`last_dev.py` generates the log files for the last tested code. These log files are used for comparing the newly pushed code to check if there are any significant changes in the trained values. Tracking is done by checking the hash of the commit. | ||
|
||
## Creating Test Scripts | ||
|
||
The sample training scripts are under the `scripts` path. In order to create training scripts for regression tests, these scripts are rewritten by changing their epoch numbers by running `regression/create_test_script.py`. The aim of changing the epoch number is to keep the duration of the test under control. This epoch number is defined in `regression/test_config.yaml` for each model/dataset combination. Since the sizes of the models are different, different epoch numbers can be defined for each of them in order to create a healthy test. If a new training script is added, the epoch number and threshold values must be defined in the `regression/test_config.yaml` file for the relevant model. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'Since the sizes of the models are different' can be changed as 'Since the sizes of the models and the datasets are varying' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
|
||
## Comparing Log Files | ||
|
||
After running test scripts for newly pushed code, the log files are saved and compared to the last tested code’s log files by running `regression/log_comparison.py`, and the results are saved. | ||
|
||
## Pass-Fail Decision | ||
|
||
In the comparison, the test success criterion is that the difference does not exceed the threshold values defined in `regression/test_config.yaml` as a percentage. If all the training scripts pass the test, `pass_fail.py` completes with success. Otherwise, it fails and exits. | ||
|
||
## ONNX Export | ||
|
||
Scripts for ONNX export are created and run by running `create_onnx_scripts.py` by configuring `Onnx_Status: True` in `regression/test_config.yaml`. If it is set to `False`, ONNX export will be skipped. | ||
|
||
## Configuration | ||
|
||
In `regression/test_config.yaml`, the `Onnx_Status` and `Qat_Test` settings should be defined to `True` when ONNX export or QAT tests by using `policies/qat_policy.yaml` are desired. When `Qat_Test` is set to `False`, QAT will be done according to the main training script. All threshold values and test epoch numbers for each model/dataset combination are also configured in this file. In order to set up the test on a new system, `regression/paths.yaml` needs to be configured accordingly. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
################################################################################################### | ||
# | ||
# Copyright (C) 2020 Maxim Integrated Products, Inc. All Rights Reserved. | ||
# Copyright (C) 2023 Maxim Integrated Products, Inc. All Rights Reserved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The copyright should be for Analog Devices Inc. not for Maxim Integrated Products. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copyright updated. |
||
# | ||
# Maxim Integrated Products, Inc. Default Copyright Notice: | ||
# https://www.maximintegrated.com/en/aboutus/legal/copyrights.html | ||
|
@@ -38,24 +38,26 @@ def time_stamp(): | |
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--testconf', help='Enter the config file for the test', required=True) | ||
parser.add_argument('--testpaths', help='Enter the paths for the test', required=True) | ||
args = parser.parse_args() | ||
yaml_path = args.testconf | ||
test_path = args.testpaths | ||
|
||
# Open the YAML file | ||
with open(yaml_path, 'r', encoding='utf-8') as file: | ||
# Load the YAML content into a Python dictionary | ||
config = yaml.safe_load(file) | ||
|
||
with open(test_path, 'r', encoding='utf-8') as file2: | ||
# Load the YAML content into a Python dictionary | ||
pathconfig = yaml.safe_load(file2) | ||
|
||
if not config["Onnx_Status"]: | ||
sys.exit(1) | ||
|
||
folder_path = r"/home/asyaturhal/desktop/ai/test_logs/" | ||
output_file_path = ( | ||
r"./scripts/onnx_scripts.sh" | ||
) | ||
train_path = ( | ||
r"/home/asyaturhal/desktop/ai/test_scripts/output_file.sh" | ||
) | ||
folder_path = pathconfig["folder_path"] | ||
output_file_path = pathconfig["output_file_path_onnx"] | ||
train_path = pathconfig["train_path"] | ||
|
||
logs_list = folder_path + '/' + sorted(os.listdir(folder_path))[-1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be os.path.join()? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is fixed. |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
################################################################################################### | ||
# | ||
# Copyright (C) 2020-2022 Maxim Integrated Products, Inc. All Rights Reserved. | ||
# Copyright (C) 2023 Maxim Integrated Products, Inc. All Rights Reserved. | ||
# | ||
# Maxim Integrated Products, Inc. Default Copyright Notice: | ||
# https://www.maximintegrated.com/en/aboutus/legal/copyrights.html | ||
|
@@ -25,19 +25,24 @@ def joining(lst): | |
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--testconf', help='Enter the config file for the test', required=True) | ||
parser.add_argument('--testpaths', help='Enter the paths for the test', required=True) | ||
args = parser.parse_args() | ||
yaml_path = args.testconf | ||
test_path = args.testpaths | ||
|
||
# Open the YAML file | ||
with open(yaml_path, 'r', encoding='utf-8') as file: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better naming can be used for 'file' & 'file2' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'file' and 'file2' updated as 'yaml_file' and 'path_file'. |
||
# Load the YAML content into a Python dictionary | ||
config = yaml.safe_load(file) | ||
|
||
# Folder containing the files to be concatenated | ||
script_path = r"./scripts" | ||
with open(test_path, 'r', encoding='utf-8') as file2: | ||
# Load the YAML content into a Python dictionary | ||
pathconfig = yaml.safe_load(file2) | ||
|
||
# Folder containing the files to be concatenated | ||
script_path = pathconfig["script_path"] | ||
# Output file name and path | ||
output_file_path = r"./scripts/output_file.sh" | ||
output_file_path = pathconfig["output_file_path"] | ||
|
||
# global log_file_names | ||
log_file_names = [] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
################################################################################################### | ||
# | ||
# Copyright (C) 2020-2022 Maxim Integrated Products, Inc. All Rights Reserved. | ||
# Copyright (C) 2023 Maxim Integrated Products, Inc. All Rights Reserved. | ||
# | ||
# Maxim Integrated Products, Inc. Default Copyright Notice: | ||
# https://www.maximintegrated.com/en/aboutus/legal/copyrights.html | ||
|
@@ -16,6 +16,7 @@ | |
|
||
import git | ||
import yaml | ||
from git.exc import InvalidGitRepositoryError | ||
|
||
|
||
def joining(lst): | ||
|
@@ -27,21 +28,25 @@ def joining(lst): | |
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--testconf', help='Enter the config file for the test', | ||
required=True) | ||
parser.add_argument('--testconf', help='Enter the config file for the test', required=True) | ||
parser.add_argument('--testpaths', help='Enter the paths for the test', required=True) | ||
args = parser.parse_args() | ||
yaml_path = args.testconf | ||
test_path = args.testpaths | ||
|
||
# Open the YAML file | ||
with open(yaml_path, 'r', encoding='utf-8') as yaml_file: | ||
# Load the YAML content into a Python dictionary | ||
config = yaml.safe_load(yaml_file) | ||
|
||
# Folder containing the files to be concatenated | ||
script_path = r"/home/asyaturhal/desktop/ai/last_developed/last_dev_source/scripts" | ||
with open(test_path, 'r', encoding='utf-8') as file2: | ||
# Load the YAML content into a Python dictionary | ||
pathconfig = yaml.safe_load(file2) | ||
|
||
# Folder containing the files to be concatenated | ||
script_path = pathconfig["script_path_dev"] | ||
# Output file name and path | ||
output_file_path = r"/home/asyaturhal/desktop/ai/last_developed/dev_scripts/last_dev_train.sh" | ||
output_file_path = pathconfig["output_file_path_dev"] | ||
|
||
# global log_file_names | ||
log_file_names = [] | ||
|
@@ -110,15 +115,15 @@ def dev_checkout(): | |
Checkout the last developed code | ||
""" | ||
repo_url = "https://github.com/MaximIntegratedAI/ai8x-training.git" | ||
local_path = r'/home/asyaturhal/desktop/ai/last_developed/last_dev_source/' | ||
local_path = pathconfig['local_path'] | ||
|
||
try: | ||
repo = git.Repo(local_path) | ||
except git.exc.InvalidGitRepositoryError: | ||
except InvalidGitRepositoryError: | ||
repo = git.Repo.clone_from(repo_url, local_path, branch="develop", recursive=True) | ||
|
||
commit_hash = repo.heads.develop.object.hexsha | ||
commit_num_path = r"/home/asyaturhal/desktop/ai/last_developed/commit_number.txt" | ||
commit_num_path = pathconfig['commit_num_path'] | ||
|
||
try: | ||
with open(commit_num_path, "r", encoding='utf-8') as file: | ||
|
@@ -132,20 +137,15 @@ def dev_checkout(): | |
repo.remotes.origin.pull("develop") | ||
|
||
dev_scripts(script_path, output_file_path) | ||
cmd_command = ( | ||
"bash /home/asyaturhal/desktop/ai/" | ||
"last_developed/dev_scripts/last_dev_train.sh" | ||
) | ||
cmd_command = "bash " + output_file_path | ||
subprocess.run(cmd_command, shell=True, check=True) | ||
|
||
path_command = "cd /home/asyaturhal/desktop/ai/last_developed/last_dev_source/" | ||
path_command = "cd " + local_path | ||
subprocess.run(path_command, shell=True, check=True) | ||
|
||
source_path = "/home/asyaturhal/actions-runner/_work/ai8x-training/ai8x-training/logs/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should not use a hard coded personal home here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is fixed. |
||
destination_path = ( | ||
"/home/asyaturhal/desktop/ai/last_developed/dev_logs/" | ||
destination_path = pathconfig["destination_path"] \ | ||
+ datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S") | ||
) | ||
subprocess.run(['mv', source_path, destination_path], check=True) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does _work originate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is default working directory of the github runner. Name of this directory can be changed while installing for the MaximIntegratedAI:develop repo.