-
Notifications
You must be signed in to change notification settings - Fork 70
155 lines (126 loc) · 6.51 KB
/
main.yml
File metadata and controls
155 lines (126 loc) · 6.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Portfolio Optimization Notebook Runner
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
run-notebooks:
runs-on: arc-runners-org-nvidia-ai-bp-1-gpu
env:
PYTHON_VERSION: 3.12
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Git LFS
run: |
echo "===================== Install Git LFS ====================="
sudo apt-get update
sudo apt-get install -y git-lfs
git lfs install
- name: Pull Git LFS files
run: |
echo "===================== Pull LFS files ====================="
git lfs pull
- name: Check System Info
run: |
echo "===================== System Info ====================="
more /etc/os-release
uname -a
docker version
- name: Run container and execute notebooks
run: |
docker run --gpus all --rm \
-v "$(pwd):/workspace" \
-w /workspace \
nvcr.io/nvidia/pytorch:25.08-py3 \
bash -c '
set -e
echo "===================== Python and GPU Info ====================="
python --version
nvidia-smi
echo "===================== Install uv ====================="
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="/root/.cargo/bin:$PATH"
source $HOME/.local/bin/env
echo "===================== Install Dependencies with uv ====================="
uv sync --extra cuda13
uv sync --extra cuda13 --extra dev
echo "===================== Install Jupyter and other packages ====================="
pip install jupyter jupyterlab ipykernel papermill nbconvert
echo "===================== Create Jupyter Kernel ====================="
uv run python -m ipykernel install --user --name=portfolio-opt --display-name "Portfolio Optimization"
echo "===================== List Jupyter Kernel ====================="
jupyter kernelspec list
echo "===================== Change to notebooks directory ====================="
cd notebooks
echo "===================== Run cvar_basic notebook ====================="
papermill cvar_basic.ipynb cvar_basic_result.ipynb --kernel portfolio-opt --log-output --log-level DEBUG
echo "===================== Run efficient_frontier notebook ====================="
papermill efficient_frontier.ipynb efficient_frontier_result.ipynb --kernel portfolio-opt --log-output --log-level DEBUG
echo "===================== Run rebalancing_strategies notebook ====================="
papermill rebalancing_strategies.ipynb rebalancing_strategies_result.ipynb --kernel portfolio-opt --log-output --log-level DEBUG
echo "===================== Run launchable notebook ====================="
papermill launchable.ipynb launchable_brev_result.ipynb --kernel portfolio-opt --log-output --log-level DEBUG
echo "===================== Convert notebooks to HTML ====================="
jupyter nbconvert --to html cvar_basic_result.ipynb
jupyter nbconvert --to html efficient_frontier_result.ipynb
jupyter nbconvert --to html rebalancing_strategies_result.ipynb
jupyter nbconvert --to html launchable_brev_result.ipynb
'
- name: Verify results
if: always()
env:
TEST_DOCKER_PULL_KEY: ${{ secrets.TEST_DOCKER_PULL_KEY }}
run: |
echo "Checking for generated files...."
ls -lh notebooks/*result*
cd notebooks
echo "$TEST_DOCKER_PULL_KEY" |docker login nvcr.io --username '$oauthtoken' --password-stdin
docker run --rm \
-v ./cvar_basic_result.html:/app/input/quantitative_portfolio_optimization/cvar_basic.html \
-v ./efficient_frontier_result.html:/app/input/quantitative_portfolio_optimization/efficient_frontier.html \
-v ./rebalancing_strategies_result.html:/app/input/quantitative_portfolio_optimization/rebalancing_strategies.html \
-v ./launchable_brev_result.html:/app/input/quantitative_portfolio_optimization/launchable_brev_result.html \
-v "$(pwd):/workspace" \
nvcr.io/rw983xdqtcdp/auto_test_team/blueprint-github-test-image:latest \
pytest -m quantitative_portfolio_optimization --disable-warnings --html=/workspace/quantitative_portfolio_optimization.html --self-contained-html
- name: Upload notebook results as artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: notebook-results
path: |
notebooks/cvar_basic_result.html
notebooks/efficient_frontier_result.html
notebooks/rebalancing_strategies_result.html
notebooks/launchable_brev_result.html
notebooks/quantitative_portfolio_optimization.html
retention-days: 30
- name: Set result output
id: set_result
if: always()
run: |
echo "RESULT=$(if [ ${{ job.status }} == 'success' ]; then echo 'PASS'; else echo 'FAIL'; fi)" >> $GITHUB_OUTPUT
- name: Send mail
uses: dawidd6/action-send-mail@6e71c855c9a091d80a519621b9fd3e8d252ca40c
if: always()
with:
server_address: smtp.gmail.com
server_port: 587
username: ${{ secrets.SMTP_USERNAME }}
password: ${{ secrets.SMTP_PASSWORD }}
# Email details
subject: "QA Test Workflow Result for ${{ github.repository }}"
from: [email protected]
html_body: |
<p>Hello,</p>
<p>The workflow for repository: <strong>${{ github.repository }}</strong> has completed.<br>
<strong>Result:</strong> ${{ steps.set_result.outputs.RESULT }}</p>
<p>You can review the details on GitHub:<br>
<a href="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}">${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}</a></p>
<p>Thanks!</p>