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

Regression Test repo pull request #232

Merged
merged 153 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
9f4aa19
test config file created
asyatrhl Jun 2, 2023
2dddb3d
Update test_config.yaml
asyatrhl Jun 2, 2023
de82a6e
Update test_config.yaml
asyatrhl Jun 2, 2023
4fce13e
Update test_config.yaml
asyatrhl Jun 2, 2023
e299787
Update test_config.yaml
asyatrhl Jun 2, 2023
5bd25ad
Update test_config.yaml
asyatrhl Jun 2, 2023
04d6799
Update test_config.yaml
asyatrhl Jun 2, 2023
e910514
Update test_config.yaml
asyatrhl Jun 2, 2023
ecf2842
Update test_config.yaml
asyatrhl Jun 2, 2023
15cf074
Update test_config.yaml
asyatrhl Jun 2, 2023
5efa887
Create last_dev.py
asyatrhl Jun 2, 2023
d619c58
Update last_dev.py
asyatrhl Jun 2, 2023
87c3d8f
Create create_test_script.py
asyatrhl Jun 2, 2023
d430f36
Update last_dev.py
asyatrhl Jun 2, 2023
d4700c3
Update create_test_script.py
asyatrhl Jun 2, 2023
ab73eab
Create log_comparison.py
asyatrhl Jun 2, 2023
1607ca2
Create pass_fail.py
asyatrhl Jun 2, 2023
17e9b2a
Update log_comparison.py
asyatrhl Jun 2, 2023
c69fd4e
Update pass_fail.py
asyatrhl Jun 2, 2023
6c0304b
Update pass_fail.py
asyatrhl Jun 2, 2023
97adea9
Update pass_fail.py
asyatrhl Jun 2, 2023
d64468e
Create create_onnx_script.py
asyatrhl Jun 4, 2023
36de2ee
Create test.yaml
asyatrhl Jun 4, 2023
51f02b9
Update test.yaml
asyatrhl Jun 4, 2023
745cc01
Update test.yaml
asyatrhl Jun 4, 2023
59897e7
Update test.yaml
asyatrhl Jun 4, 2023
603297a
Update test.yaml
asyatrhl Jun 4, 2023
1fed0d6
Update create_test_script.py
asyatrhl Jun 4, 2023
2fca15b
Update create_test_script.py
asyatrhl Jun 4, 2023
e78244f
Update test.yaml
asyatrhl Jun 4, 2023
e2de131
Update test.yaml
asyatrhl Jun 4, 2023
d399400
Update test.yaml
asyatrhl Jun 4, 2023
2b76427
Update test_config.yaml
asyatrhl Jun 5, 2023
b55904d
Update create_onnx_script.py
asyatrhl Jun 5, 2023
0c0dc42
Update pass_fail.py
asyatrhl Jun 5, 2023
44e8da9
Update pass_fail.py
asyatrhl Jun 6, 2023
ab2ec5b
Update pass_fail.py
asyatrhl Jun 7, 2023
ef02e44
Update pass_fail.py
asyatrhl Jun 7, 2023
6d5866c
Update and rename test.yaml to test.yml
asyatrhl Jun 7, 2023
1b5dbb8
Update and rename test_config.yaml to test_config.yml
asyatrhl Jun 7, 2023
8bd8b6c
Update create_onnx_script.py
asyatrhl Jun 7, 2023
eda912e
Update log_comparison.py
asyatrhl Jun 7, 2023
aa0c58e
Update pass_fail.py
asyatrhl Jun 7, 2023
c29ff42
Update pass_fail.py
asyatrhl Jun 7, 2023
50a01f4
Update pass_fail.py
asyatrhl Jun 7, 2023
e693be6
Update create_onnx_script.py
asyatrhl Jun 7, 2023
5392f2d
Update log_comparison.py
asyatrhl Jun 7, 2023
7bbae8d
Update create_onnx_script.py
asyatrhl Jun 7, 2023
4ebdf39
Update pass_fail.py
asyatrhl Jun 7, 2023
85a1622
Update pass_fail.py
asyatrhl Jun 7, 2023
6ff6d27
Update test_config.yml
asyatrhl Jun 7, 2023
6a6c702
Update pass_fail.py
asyatrhl Jun 7, 2023
84f4be7
Update test_config.yml
asyatrhl Jun 7, 2023
1b3edc6
Update create_onnx_script.py
asyatrhl Jun 7, 2023
6eb51a3
Update test_config.yml
asyatrhl Jun 7, 2023
9c14f72
Delete test_config.yml
asyatrhl Jun 7, 2023
e33a502
Add files via upload
asyatrhl Jun 7, 2023
76e2c99
Update README.md
asyatrhl Jun 7, 2023
406a4fa
Update README.md
asyatrhl Jun 7, 2023
27e50ba
Update README.md
asyatrhl Jun 7, 2023
35399b3
Update test.yml
asyatrhl Jun 7, 2023
17e626c
Rename test_config.yml to test_config.yaml
asyatrhl Jun 7, 2023
bd7e579
Update test.yml
asyatrhl Jun 7, 2023
03bde4f
Update test.yml
asyatrhl Jun 7, 2023
4b77d4a
Update test.yml
asyatrhl Jun 7, 2023
8127141
Update create_onnx_script.py
asyatrhl Jun 8, 2023
ffe19b8
Update log_comparison.py
asyatrhl Jun 8, 2023
9ea8b83
Update pass_fail.py
asyatrhl Jun 8, 2023
43863ce
Update pass_fail.py
asyatrhl Jun 8, 2023
6f6005e
Update create_test_script.py
asyatrhl Jun 8, 2023
59d900e
Update test_config.yaml
asyatrhl Jun 8, 2023
cf2430a
Update README.md
asyatrhl Jun 8, 2023
809854a
Update create_onnx_script.py
asyatrhl Jun 14, 2023
cdc3049
Update create_test_script.py
asyatrhl Jun 14, 2023
bb4958c
Update last_dev.py
asyatrhl Jun 14, 2023
ac24e2a
Update log_comparison.py
asyatrhl Jun 14, 2023
77b63b7
Update pass_fail.py
asyatrhl Jun 14, 2023
3098dd5
Update test.yml
asyatrhl Jun 16, 2023
332cd9a
Update test.yml
asyatrhl Jun 16, 2023
f754a24
Update test.yml
asyatrhl Jun 16, 2023
74e1ba0
Update last_dev.py
asyatrhl Jun 16, 2023
938bf0a
Update create_onnx_script.py
asyatrhl Jun 16, 2023
50f7389
Update create_test_script.py
asyatrhl Jun 16, 2023
b740448
Update log_comparison.py
asyatrhl Jun 16, 2023
2189f71
Update pass_fail.py
asyatrhl Jun 16, 2023
0e2c8bc
Create paths.yml
asyatrhl Jun 16, 2023
0d2ca13
Update test.yml
asyatrhl Jun 20, 2023
8dd6656
Update test.yml
asyatrhl Jun 20, 2023
611ffe4
Update log_comparison.py
asyatrhl Jun 20, 2023
61b0473
Update log_comparison.py
asyatrhl Jun 20, 2023
66f6a55
Update log_comparison.py
asyatrhl Jun 21, 2023
cc40364
Update log_comparison.py
asyatrhl Jun 21, 2023
c9137d1
Update log_comparison.py
asyatrhl Jun 21, 2023
5093a52
Update test.yml
asyatrhl Jun 21, 2023
2ec9073
Update pass_fail.py
asyatrhl Jun 21, 2023
06d1e9e
Update pass_fail.py
asyatrhl Jun 21, 2023
9fc44ea
Update test.yml
asyatrhl Jun 21, 2023
e2f36b9
Update test.yml
asyatrhl Jun 21, 2023
1107833
value error for untrained models fixed in pass_fail.py
asyatrhl Jun 21, 2023
674b983
Update README.md
asyatrhl Jun 22, 2023
0111793
Merge branch 'develop' into test
Jun 22, 2023
9a041ca
Merge branch 'MaximIntegratedAI:develop' into test_pr
asyatrhl Jun 22, 2023
a5ccc65
Delete test.yml
asyatrhl Jun 26, 2023
d5e9ded
Grammarly check done.
asyatrhl Jun 26, 2023
b29725b
Merge pull request #3 from asyatrhl/test_pr
asyatrhl Jun 26, 2023
b3f12c0
Merge branch 'develop' into test
Jun 27, 2023
2191adb
Run yamllint; rename from .yml to .yaml
Jun 27, 2023
a14fd15
Reorganize files
Jun 27, 2023
557fb79
Add missing requirement
Jun 27, 2023
504e3b0
Fix linter errors
Jun 27, 2023
7359af9
Rename test_config.yaml to test_config.yml
asyatrhl Jun 27, 2023
0908dfb
Create test.yml
asyatrhl Jun 27, 2023
7456409
Update test.yml
asyatrhl Jun 27, 2023
2869469
Linter fix.
asyatrhl Jun 27, 2023
4e81031
Linter fix.
asyatrhl Jun 27, 2023
a61cb73
Linter fix.
asyatrhl Jun 27, 2023
a4fbfd9
Linter fix.
asyatrhl Jun 27, 2023
f9ebc29
Update test.yml
asyatrhl Jun 27, 2023
0b72330
Merge branch 'test' into feature/patches
Jun 28, 2023
f9711b2
Minor modification to train.py (backport)
Jun 28, 2023
3140b3f
Update test.yml
asyatrhl Jun 28, 2023
2cca234
Merge pull request #4 from rotx-maxim/feature/patches
asyatrhl Jun 28, 2023
4c21dfb
Update test.yml
asyatrhl Jun 28, 2023
84d6b5a
Merge pull request #6 from asyatrhl/test_backup
asyatrhl Jun 29, 2023
e4d453f
Merge branch 'develop' into test
Jun 29, 2023
b9bb091
Update test.yml
asyatrhl Jun 29, 2023
3d5871c
Update test.yml
asyatrhl Jun 30, 2023
d83b837
Update test.yml
asyatrhl Jun 30, 2023
1c34312
Update paths.yaml
asyatrhl Jun 30, 2023
4c3e87f
Update test.yml
asyatrhl Jun 30, 2023
5a341dc
Update paths.yaml
asyatrhl Jun 30, 2023
893817c
Update log_comparison.py
asyatrhl Jun 30, 2023
6f56b4d
Update test_config.yaml
asyatrhl Jun 30, 2023
fb9239d
Update test.yml
asyatrhl Jun 30, 2023
563d4f0
Update test.yml
asyatrhl Jun 30, 2023
ca44ec9
Update test.yml
asyatrhl Jun 30, 2023
111c5ff
Update paths.yaml
asyatrhl Jul 6, 2023
f782e26
Update paths.yaml
asyatrhl Jul 6, 2023
9ec1bb7
Path join updated. Kinetics datapath updated.
asyatrhl Jul 6, 2023
bc70e50
Update last_dev.py
asyatrhl Jul 6, 2023
af0896f
Update last_dev.py
asyatrhl Jul 6, 2023
72eaa7d
Update last_dev.py
asyatrhl Jul 6, 2023
84eb8b5
Update create_onnx_script.py
asyatrhl Jul 18, 2023
f6fcca8
Update create_onnx_script.py
asyatrhl Jul 18, 2023
b22d1a7
Copyright title and docs/Regression.md updated. file and file2 naming…
asyatrhl Jul 18, 2023
c728c2e
Copyright title and docs/Regression.md updated. file and file2 naming…
asyatrhl Jul 18, 2023
a580101
Merge branch 'develop' into test
Jul 24, 2023
9fce294
Setting Up Regression Test part added to docs/Regression.md
asyatrhl Jul 26, 2023
2651656
Update create_test_script.py
asyatrhl Jul 26, 2023
bc2f3ab
Linter fix. Comment update.
asyatrhl Jul 26, 2023
1c83db7
Update Regression.md
asyatrhl Jul 26, 2023
3ad7f82
Merge branch 'MaximIntegratedAI:develop' into test
asyatrhl Jul 31, 2023
a51667a
Update Regression.md
Aug 2, 2023
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
24 changes: 10 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
pip3 install -U pip wheel setuptools
pip3 install -r requirements-cu11.txt
- name: Last Develop Check
run: python ./regression-test/last_dev.py --testconf ./regression-test/test_config.yaml
run: python ./regression/last_dev.py --testconf ./regression/test_config.yaml --testpaths ./regression/paths.yaml

new-code:
runs-on: self-hosted
Expand All @@ -57,27 +57,23 @@ jobs:
pip3 install -U pip wheel setuptools
pip3 install -r requirements-cu11.txt
- name: Create Test Script
run: python ./regression-test/create_test_script.py --testconf ./regression-test/test_config.yaml
run: python ./regression/create_test_script.py --testconf ./regression/test_config.yaml --testpaths ./regression/paths.yaml
- name: Run Training Scripts
run: bash /home/asyaturhal/actions-runner/_work/ai8x-training/ai8x-training/scripts/output_file.sh
run: bash /home/test/actions-runner/_work/ai8x-training/ai8x-training/scripts/output_file.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does _work originate?

Copy link
Collaborator Author

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.

- name: Save Log Files
run: cp -r /home/asyaturhal/actions-runner/_work/ai8x-training/ai8x-training/logs/ /home/asyaturhal/desktop/ai/test_logs/$(date +%Y-%m-%d_%H-%M-%S)
- name: Save test scripts
run: cp -r /home/asyaturhal/actions-runner/_work/ai8x-training/ai8x-training/scripts/output_file.sh /home/asyaturhal/desktop/ai/test_scripts/
run: cp -r /home/test/actions-runner/_work/ai8x-training/ai8x-training/logs//home/test/max7800x/test_logs/$(date +%Y-%m-%d_%H-%M-%S)
- name: Save Test Scripts
run: cp -r /home/test/actions-runner/_work/ai8x-training/ai8x-training/scripts/output_file.sh/home/test/max7800x/test_scripts/
- name: Create and run ONNX script
run: python ./regression-test/create_onnx_scripts.py --testconf ./regression-test/test_config.yaml
run: python ./regression/create_onnx_script.py --testconf ./regression/test_config.yaml --testpaths ./regression/paths.yaml

test-results:
runs-on: self-hosted
needs: [new-code]
timeout-minutes: 345600
steps:
- uses: actions/checkout@v2
name: trial-check
with:
submodules: recursive
- name: Checkout Test Codes
uses: actions/checkout@v2
name: Checkout Test Codes
with:
repository: MaximIntegratedAI/ai8x-training
ref: develop
Expand All @@ -97,6 +93,6 @@ jobs:
pip3 install -U pip wheel setuptools
pip3 install -r requirements-cu11.txt
- name: Log Diff
run: python ./regression-test/log_comparison.py
run: python ./regression/log_comparison.py --testconf ./regression/test_config.yaml --testpaths ./regression/paths.yaml
- name: Test Results
run: python ./regression-test/pass_fail.py --testconf ./regression-test/test_config.yaml
run: python ./regression/pass_fail.py --testconf ./regression/test_config.yaml --testpaths ./regression/paths.yaml
29 changes: 0 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3275,35 +3275,6 @@ See the [benchmarking guide](https://github.com/MaximIntegratedAI/MaximAI_Docume



## Regression Test

Regression test for ai8xtraining repo is tested when there is a pull request for develop branch of MaximIntegratedAI/ai8x-training by triggering test.yaml github actions.

### Last Developed Code Training

last_dev.py code generates the log files of the last developed and tested code. These log files are used for comparing the new pushed code to check if there is any change in the trained values. Tracking is done by checking hex number of the repository.

### Creating Test Scripts

There are training scripts that are developed under the scripts path. In order to create training scripts for regression test, these scripts are rewritten by changing their epoch number by running create_test_script.py code. The aim for changing the epoch number is to keep the duration of the test under control. This epoch number is defined in the test_config.yaml file 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 test_config.yaml file for the relevant model.

### Comparing Log Files

After running test scripts for new pushed code, it’s log files are saved and compared with last developed code’s log files by running log_comparison.py and results are also saved.

### Pass Fail Decision

In the comparison, the test's success criterion is that the difference does not exceed the threshold value defined in the test_config.yaml file as a percentage. If all the training scripts passed the test, pass_fail.py code completes with success. Otherwise it fails and exits by cancelling pull request.

### Onnx Export

Scripts for onnx export are created and ran by running create_onnx_scripts.py by configuring ‘Onnx_Status: True’ in test_config.yaml . If it is set as ‘False’ onnx export won't be done.

### Test Configuration

In test_config.yaml file Onnx_Status and Qat_Test should be ste to 'true' if you want to create onnx export or make qat test by using policies/qat_policy.yaml. When Qat_Test is set to false qat will be done according to the main training script. All the threshold values and test epoch numbers for each model dataset combination are also configured in this file.


## Further Information

Additional information about the evaluation kits, and the software development kit (MSDK) is available on the web at <https://github.com/MaximIntegratedAI/MaximAI_Documentation>.
Expand Down
28 changes: 28 additions & 0 deletions docs/Regression.md
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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be os.path.join()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is fixed.


Expand Down
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
Expand All @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better naming can be used for 'file' & 'file2'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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 = []
Expand Down
34 changes: 17 additions & 17 deletions regression-test/last_dev.py → regression/last_dev.py
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
Expand All @@ -16,6 +16,7 @@

import git
import yaml
from git.exc import InvalidGitRepositoryError


def joining(lst):
Expand All @@ -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 = []
Expand Down Expand Up @@ -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:
Expand All @@ -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/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not use a hard coded personal home here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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)


Expand Down
38 changes: 31 additions & 7 deletions regression-test/log_comparison.py → regression/log_comparison.py
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
Expand All @@ -9,12 +9,30 @@
"""
Compare log files of the pulled code and the last developed
"""
import argparse
import datetime
import os
import sys

import yaml
from tabulate import tabulate

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 yaml_file:
# Load the YAML content into a Python dictionary
config = yaml.safe_load(yaml_file)

with open(test_path, 'r', encoding='utf-8') as file2:
# Load the YAML content into a Python dictionary
pathconfig = yaml.safe_load(file2)


def compare_logs(old_log, new_log, output_name, output_pth):
"""
Expand All @@ -29,10 +47,10 @@ def compare_logs(old_log, new_log, output_name, output_pth):
ex_list = [False]

with open(new_log, 'r', encoding='utf-8') as f2:
file2 = f2.read()
file2_content = f2.read()
log_name = new_log.split('/')[-1].split('___')[0]

if word2 not in file2 and word3 not in file2:
if word2 not in file2_content and word3 not in file2_content:
print(f"\033[31m\u2718\033[0m {log_name} does not have any trained results."
" There is an error in training.")
ex_list.append(True)
Expand Down Expand Up @@ -89,6 +107,9 @@ def compare_logs(old_log, new_log, output_name, output_pth):
if not map_value:
i = 0
for (list1, list2) in zip(log1_list, log2_list):
if float(list1[1]) == 0:
print("Top1 value of " + output_name + " is 0.00.")
list1[1] = 0.000001
i = i+1
if '[Top1:' in list2:
top1_diff = ((float(list2[1])-float(list1[1]))/float(list1[1]))*100
Expand All @@ -106,6 +127,9 @@ def compare_logs(old_log, new_log, output_name, output_pth):
if map_value:
i = 0
for (map1, map2) in zip(mAP_list1, mAP_list2):
if float(map1[1]) == 0:
print("Map value of " + output_name + " is 0.00.")
map1[1] = 0.000001
i = i+1
if '[mAP:' in map2:
map_diff = ((float(map2[1])-float(map1[1]))/float(map1[1]))*100
Expand All @@ -128,14 +152,14 @@ def log_path_list(path):
return lst


log_new = r'/home/asyaturhal/desktop/ai/test_logs/'
log_old = r'/home/asyaturhal/desktop/ai/last_developed/dev_logs/'
script_path = r"/home/asyaturhal/desktop/ai/test_scripts/output_file.sh"
log_new = pathconfig["log_new"]
log_old = pathconfig["log_old"]
script_path = pathconfig["script_path_log"]

time = str(datetime.datetime.now())
time = time.replace(' ', '.')
time = time.replace(':', '.')
output_path = r"/home/asyaturhal/desktop/ai/log_diff/" + '/' + str(time)
output_path = pathconfig["output_path"] + '/' + str(time)

os.mkdir(output_path)

Expand Down
Loading
Loading