Merged PR 452: Automate the benchmark process
## Summary This pull request integrates full automation of the PrimAITE benchmarking process into our Azure DevOps pipeline, enhancing consistency and minimizing manual effort. #### Key Changes: 1. **Pipeline Automation**: Configured to trigger on commits to `dev` and `release` branches, with scheduled runs during off-peak hours. 2. **Error Handling Improvements**: The pipeline is set to fail on any Python execution errors, ensuring immediate identification of issues. 3. **Artifact Publishing**: Benchmark results are now automatically compressed and published as artifacts, facilitating easy access and analysis. ## Test process Tested the pipeline runs from end-to-end and produces a working benchmark report: https://dev.azure.com/ma-dev-uk/PrimAITE/_build/results?buildId=5280&view=results ## Checklist - [ ] PR is linked to a **work item** - [ ] **acceptance criteria** of linked ticket are met - [ ] performed **self-review** of the code - [ ] written **tests** for any new functionality added with this PR - [ ] updated the **documentation** if this PR changes or adds functionality - [ ] written/updated **design docs** if this PR implements new functionality - [ ] updated the **change log** - [ ] ran **pre-commit** checks for code style - [ ] attended to any **TO-DOs** left in the code Related work items: #2739
This commit is contained in:
@@ -11,74 +11,78 @@ schedules:
|
|||||||
branches:
|
branches:
|
||||||
include:
|
include:
|
||||||
- 'refs/heads/dev'
|
- 'refs/heads/dev'
|
||||||
|
|
||||||
pool:
|
|
||||||
vmImage: ubuntu-latest
|
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
VERSION: ''
|
VERSION: ''
|
||||||
MAJOR_VERSION: ''
|
MAJOR_VERSION: ''
|
||||||
|
|
||||||
steps:
|
jobs:
|
||||||
- checkout: self
|
- job: PrimAITE_Benchmark
|
||||||
persistCredentials: true
|
timeoutInMinutes: 360 # 6-hour maximum
|
||||||
|
pool:
|
||||||
|
vmImage: ubuntu-latest
|
||||||
|
workspace:
|
||||||
|
clean: all
|
||||||
|
steps:
|
||||||
|
- checkout: self
|
||||||
|
persistCredentials: true
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
VERSION=$(cat src/primaite/VERSION | tr -d '\n')
|
VERSION=$(cat src/primaite/VERSION | tr -d '\n')
|
||||||
if [[ "$(Build.SourceBranch)" == "refs/heads/dev" ]]; then
|
if [[ "$(Build.SourceBranch)" == "refs/heads/dev" ]]; then
|
||||||
DATE=$(date +%Y%m%d)
|
DATE=$(date +%Y%m%d)
|
||||||
echo "${VERSION}+dev.${DATE}" > src/primaite/VERSION
|
echo "${VERSION}+dev.${DATE}" > src/primaite/VERSION
|
||||||
fi
|
fi
|
||||||
displayName: 'Update VERSION file for Dev Benchmark'
|
displayName: 'Update VERSION file for Dev Benchmark'
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
VERSION=$(cat src/primaite/VERSION | tr -d '\n')
|
VERSION=$(cat src/primaite/VERSION | tr -d '\n')
|
||||||
MAJOR_VERSION=$(echo $VERSION | cut -d. -f1)
|
MAJOR_VERSION=$(echo $VERSION | cut -d. -f1)
|
||||||
echo "##vso[task.setvariable variable=VERSION]$VERSION"
|
echo "##vso[task.setvariable variable=VERSION]$VERSION"
|
||||||
echo "##vso[task.setvariable variable=MAJOR_VERSION]$MAJOR_VERSION"
|
echo "##vso[task.setvariable variable=MAJOR_VERSION]$MAJOR_VERSION"
|
||||||
displayName: 'Set Version Variables'
|
displayName: 'Set Version Variables'
|
||||||
|
|
||||||
- task: UsePythonVersion@0
|
- task: UsePythonVersion@0
|
||||||
inputs:
|
inputs:
|
||||||
versionSpec: '3.11'
|
versionSpec: '3.11'
|
||||||
addToPath: true
|
addToPath: true
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -e .[dev,rl]
|
pip install -e .[dev,rl]
|
||||||
primaite setup
|
primaite setup
|
||||||
displayName: 'Install Dependencies'
|
displayName: 'Install Dependencies'
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
cd benchmark
|
set -e
|
||||||
python3 primaite_benchmark.py
|
cd benchmark
|
||||||
cd ..
|
python3 primaite_benchmark.py
|
||||||
displayName: 'Run Benchmarking Script'
|
cd ..
|
||||||
|
displayName: 'Run Benchmarking Script'
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
git config --global user.email "oss@dstl.gov.uk"
|
git config --global user.email "oss@dstl.gov.uk"
|
||||||
git config --global user.name "Defence Science and Technology Laboratory UK"
|
git config --global user.name "Defence Science and Technology Laboratory UK"
|
||||||
workingDirectory: $(System.DefaultWorkingDirectory)
|
workingDirectory: $(System.DefaultWorkingDirectory)
|
||||||
displayName: 'Configure Git'
|
displayName: 'Configure Git'
|
||||||
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release'))
|
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release'))
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
git add benchmark/results/v$(MAJOR_VERSION)/v$(VERSION)/*
|
git add benchmark/results/v$(MAJOR_VERSION)/v$(VERSION)/*
|
||||||
git commit -m "Automated benchmark output commit for version $(VERSION)"
|
git commit -m "Automated benchmark output commit for version $(VERSION)"
|
||||||
git push origin HEAD:refs/heads/$(Build.SourceBranchName)
|
git push origin HEAD:refs/heads/$(Build.SourceBranchName)
|
||||||
displayName: 'Commit and Push Benchmark Results'
|
displayName: 'Commit and Push Benchmark Results'
|
||||||
workingDirectory: $(System.DefaultWorkingDirectory)
|
workingDirectory: $(System.DefaultWorkingDirectory)
|
||||||
env:
|
env:
|
||||||
GIT_CREDENTIALS: $(System.AccessToken)
|
GIT_CREDENTIALS: $(System.AccessToken)
|
||||||
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/heads/release'))
|
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/heads/release'))
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
tar czf primaite_v$(VERSION)_benchmark.tar.gz benchmark/results/v$(MAJOR_VERSION)/v$(VERSION)
|
tar czf primaite_v$(VERSION)_benchmark.tar.gz benchmark/results/v$(MAJOR_VERSION)/v$(VERSION)
|
||||||
displayName: 'Prepare Artifacts for Publishing'
|
displayName: 'Prepare Artifacts for Publishing'
|
||||||
|
|
||||||
- task: PublishPipelineArtifact@1
|
- task: PublishPipelineArtifact@1
|
||||||
inputs:
|
inputs:
|
||||||
targetPath: primaite_v$(VERSION)_benchmark.tar.gz
|
targetPath: primaite_v$(VERSION)_benchmark.tar.gz
|
||||||
artifactName: 'benchmark-output'
|
artifactName: 'benchmark-output'
|
||||||
publishLocation: 'pipeline'
|
publishLocation: 'pipeline'
|
||||||
displayName: 'Publish Benchmark Output as Artifact'
|
displayName: 'Publish Benchmark Output as Artifact'
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
"av_s_per_session": 3205.6340542,
|
"av_s_per_session": 3205.6340542,
|
||||||
"av_s_per_step": 0.10017606419375,
|
"av_s_per_step": 0.10017606419375,
|
||||||
"av_s_per_100_steps_10_nodes": 10.017606419375,
|
"av_s_per_100_steps_10_nodes": 10.017606419375,
|
||||||
"combined_av_reward_per_episode": {
|
"combined_total_reward_per_episode": {
|
||||||
"1": -53.42999999999999,
|
"1": -53.42999999999999,
|
||||||
"2": -25.18000000000001,
|
"2": -25.18000000000001,
|
||||||
"3": -42.00000000000002,
|
"3": -42.00000000000002,
|
||||||
|
|||||||
Reference in New Issue
Block a user