Profile cbds with different blocks input, big #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Profile cbds with different blocks input, big | |
on: | |
# Trigger the workflow on # push or pull request | |
push: | |
# Trigger the workflow manually | |
schedule: | |
- cron: '0 0 */1 * *' | |
workflow_dispatch: | |
jobs: | |
test: | |
name: Profile BDS with different blocks input, big | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
matlab: [latest] | |
dim: [big] | |
with_optim_toolbox: [yes] | |
solver: [cbds] | |
competitor_1: [ds] | |
competitor_2: [cbds-half] | |
competitor_3: [cbds-quarter] | |
run_plain: [false] | |
summarize_log_ratio_profiles: [false] | |
feature: [plain, noisy_1e-1, noisy_1e-2, noisy_1e-3, noisy_1e-4, linearly_transformed, rotation_noisy_1e-1, rotation_noisy_1e-2, rotation_noisy_1e-3, rotation_noisy_1e-4] | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Checkout OptiProfiler | |
uses: actions/checkout@v4 | |
with: | |
repository: optiprofiler/optiprofiler | |
ref: matlab | |
path: optiprofiler | |
- name: Install Texlive | |
run: sudo apt-get update && sudo apt-get install texlive | |
- name: Check whether LaTeX is installed | |
run: pdflatex --version | |
- name: Cache MATLAB | |
id: cache-matlab | |
uses: actions/cache@v4.0.1 | |
with: | |
path: ${{ runner.tool_cache }}/MATLAB | |
key: ${{ matrix.os }}-${{ matrix.matlab }}-${{ matrix.with_optim_toolbox }} | |
- name: Set up MATLAB with optimization toolbox | |
if: ${{ matrix.with_optim_toolbox == 'yes' }} | |
uses: matlab-actions/setup-matlab@v2.1.2 | |
with: | |
release: ${{ matrix.matlab }} | |
products: Optimization_Toolbox | |
- name: Run test | |
uses: matlab-actions/run-command@v2.1.1 | |
with: | |
command: | | |
root_dir = pwd() | |
ls | |
% Setup optiprofiler | |
cd(fullfile(root_dir, 'optiprofiler')); | |
setup | |
cd(root_dir); | |
% Setup bds | |
setup | |
cd(fullfile(root_dir, 'tests', 'competitors')); | |
addpath(pwd); | |
% profile | |
cd(fullfile(root_dir, 'tests')); | |
options = struct(); | |
options.feature_name = '${{ matrix.feature }}'; | |
options.solver_names = {'${{ matrix.solver }}', '${{ matrix.competitor_1 }}', '${{ matrix.competitor_2 }}', '${{ matrix.competitor_3 }}'}; | |
options.dim = '${{ matrix.dim }}'; | |
options.n_runs = 1; | |
options.run_plain = ${{ matrix.run_plain }}; | |
options.summarize_log_ratio_profiles = ${{ matrix.summarize_log_ratio_profiles }}; | |
profile_optiprofiler(options); | |
cd(root_dir); | |
cd(fullfile(root_dir, 'tests', 'out')); | |
ls -R | |
cd(root_dir); | |
- name: Change the summary file name | |
run: | | |
cd ./tests/out | |
ls -R | |
find . -type f -name 'summary.pdf' | while read -r file; do | |
# Obtain the parent directory and name | |
parent_dir=$(dirname "$file") | |
parent_name=$(basename "$parent_dir") | |
# Obtain the new name(Why the fifth underline? Because the last five parts are the time stamp) | |
new_name=$(echo "$parent_name" | awk -F'_' '{if(NF>=5) {for(i=1;i<=NF-5;i++) printf "%s%s", $i, (i<NF-5?"_":"")} else print $0}') | |
# Print the new name | |
echo "New name: $new_name" | |
# Obtain the directory name | |
dir_name=$(dirname "$file") | |
# Establish the new file name | |
new_file="$dir_name/summary_$new_name.pdf" | |
# Check if the source and destination are the same | |
if [ "$file" != "$new_file" ]; then | |
mv "$file" "$new_file" | |
echo "Renamed $file to $new_file" | |
else | |
echo "Source and destination are the same, skipping: $file" | |
fi | |
done | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3.1.2 | |
with: | |
name: profile_optiprofiler_${{ matrix.solver }}_${{ matrix.competitor_1 }}_${{ matrix.competitor_2 }}_${{ matrix.competitor_3 }}_${{ matrix.dim }}_${{ matrix.feature }} | |
path: ./tests/out/** | |
merge_artifacts: | |
name: Merge Artifacts | |
runs-on: ubuntu-latest | |
needs: test | |
permissions: | |
actions: read | |
contents: read | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install PDF tools | |
run: sudo apt-get update && sudo apt-get install -y poppler-utils | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: tests/testdata/downloaded_artifacts | |
- name: List all files | |
run: | | |
cd tests/testdata/downloaded_artifacts | |
ls -R | |
- name: Merge PDF files | |
run: | | |
cp tests/tools/merge_pdf.sh tests/testdata/downloaded_artifacts | |
cd tests/testdata/downloaded_artifacts/ | |
ARTIFACT_NAME=$(ls | grep "profile_optiprofiler" | head -n 1) | |
BASE_INFO=$(echo $ARTIFACT_NAME | sed -n 's/.*optiprofiler_\([^_]*_[^_]*_\(small\|big\)\).*/\1/p') | |
echo "Base info extracted: ${BASE_INFO}" | |
echo "BASE_INFO=${BASE_INFO}" >> $GITHUB_ENV | |
# Merge PDF files | |
mkdir summary | |
for f in $(find . -maxdepth 3 -type f -name 'summary*.pdf'); do | |
if [ ! -f "summary/$(basename $f)" ]; then | |
cp "$f" summary/ | |
fi | |
done | |
cd summary | |
ls | |
bash ../merge_pdf.sh | |
mv merged.pdf "summary_${BASE_INFO}.pdf" | |
cd .. | |
if [ -d "summary" ]; then | |
mv summary "summary_${BASE_INFO}" | |
fi | |
- name: Upload merged artifact | |
uses: actions/upload-artifact@v3 | |
env: | |
BASE_INFO: ${{ env.BASE_INFO }} | |
with: | |
name: merged_profiles_blocks_big | |
path: tests/testdata/downloaded_artifacts/** | |
- name: Upload summary files | |
uses: actions/upload-artifact@v3 | |
env: | |
BASE_INFO: ${{ env.BASE_INFO }} | |
with: | |
name: summary_files_blocks_big | |
path: tests/testdata/downloaded_artifacts/summary_${{ env.BASE_INFO }}/** |