Skip to content

Commit 46d3b3a

Browse files
authored
Merge pull request #2842 from opentensor/feat/roman/Monitor-Requirements-Size
Add `Monitor-Requirements-Size` workflow
2 parents 2789eb1 + d7df362 commit 46d3b3a

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# This workflow measures the disk size of a virtual environment
2+
# after installing the Bittensor SDK across multiple Python versions.
3+
# It runs only when a new pull request targets the master branch,
4+
# and posts a comment with the results.
5+
name: Monitor SDK Requirements Size
6+
7+
on:
8+
pull_request:
9+
types: [opened]
10+
branches: [master]
11+
12+
permissions:
13+
pull-requests: write
14+
contents: read
15+
16+
jobs:
17+
measure-venv:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
22+
outputs:
23+
py39: ${{ steps.set-output.outputs.py39 }}
24+
py310: ${{ steps.set-output.outputs.py310 }}
25+
py311: ${{ steps.set-output.outputs.py311 }}
26+
py312: ${{ steps.set-output.outputs.py312 }}
27+
py313: ${{ steps.set-output.outputs.py313 }}
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-python@v5
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
35+
- name: Create virtualenv and install
36+
run: |
37+
python -m venv venv
38+
source venv/bin/activate
39+
pip install --upgrade pip
40+
pip install .
41+
42+
- name: Measure venv size
43+
id: set-output
44+
run: |
45+
SIZE=$(du -sm venv | cut -f1)
46+
VERSION=${{ matrix.python-version }}
47+
echo "Detected size: $SIZE MB for Python $VERSION"
48+
case "$VERSION" in
49+
3.9) echo "py39=$SIZE" >> $GITHUB_OUTPUT ;;
50+
3.10) echo "py310=$SIZE" >> $GITHUB_OUTPUT ;;
51+
3.11) echo "py311=$SIZE" >> $GITHUB_OUTPUT ;;
52+
3.12) echo "py312=$SIZE" >> $GITHUB_OUTPUT ;;
53+
3.13) echo "py313=$SIZE" >> $GITHUB_OUTPUT ;;
54+
esac
55+
56+
comment-on-pr:
57+
if: github.event_name == 'pull_request' && github.base_ref == 'master'
58+
needs: measure-venv
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Post venv size summary to PR
62+
uses: actions/github-script@v7
63+
with:
64+
github-token: ${{ secrets.GITHUB_TOKEN }}
65+
script: |
66+
const sizes = {
67+
"3.9": "${{ needs.measure-venv.outputs.py39 || 'N/A' }}",
68+
"3.10": "${{ needs.measure-venv.outputs.py310 || 'N/A' }}",
69+
"3.11": "${{ needs.measure-venv.outputs.py311 || 'N/A' }}",
70+
"3.12": "${{ needs.measure-venv.outputs.py312 || 'N/A' }}",
71+
"3.13": "${{ needs.measure-venv.outputs.py313 || 'N/A' }}",
72+
};
73+
74+
const body = [
75+
'**Bittensor SDK virtual environment sizes by Python version:**',
76+
'',
77+
'```'
78+
]
79+
.concat(Object.entries(sizes).map(([v, s]) => `Python ${v}: ${s} MB`))
80+
.concat(['```'])
81+
.join('\n');
82+
83+
github.rest.issues.createComment({
84+
issue_number: context.issue.number,
85+
owner: context.repo.owner,
86+
repo: context.repo.repo,
87+
body
88+
});

0 commit comments

Comments
 (0)