From 384efe5e12b72dbb02d3bb3ccc146dc09781751f Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Apr 2025 11:51:47 -0700 Subject: [PATCH 01/11] add workflow --- .../monitor_requirements_size_master.yml | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/monitor_requirements_size_master.yml diff --git a/.github/workflows/monitor_requirements_size_master.yml b/.github/workflows/monitor_requirements_size_master.yml new file mode 100644 index 0000000000..7d86171d5e --- /dev/null +++ b/.github/workflows/monitor_requirements_size_master.yml @@ -0,0 +1,76 @@ +# This workflow measures the disk size of a virtual environment +# after installing the Bittensor SDK across multiple Python versions. +# It runs only when a new pull request targets the master branch, +# and posts a comment with the results. + +name: Monitor SDK Requirements Size + +on: + pull_request: + types: [opened] + branches: [master] + +jobs: + measure-venv: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + + name: Python ${{ matrix.python-version }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Create virtualenv and install Bittensor SDK + run: | + python -m venv venv + source venv/bin/activate + pip install --upgrade pip + pip install . + + - name: Measure venv folder size + id: venv-size + run: | + du -sm venv | cut -f1 > venv_size_mb.txt + echo "venv_size=$(cat venv_size_mb.txt)" >> $GITHUB_OUTPUT + + - name: Save size for summary + run: | + echo "Python ${{ matrix.python-version }}: ${{ steps.venv-size.outputs.venv_size }} MB" >> $GITHUB_WORKSPACE/venv_sizes.txt + + - name: Upload summary file as artifact + uses: actions/upload-artifact@v4 + with: + name: venv_sizes + path: $GITHUB_WORKSPACE/venv_sizes.txt + + comment-on-pr: + if: github.event_name == 'pull_request' && github.base_ref == 'master' + runs-on: ubuntu-latest + needs: measure-venv + + steps: + - name: Download summary + uses: actions/download-artifact@v4 + with: + name: venv_sizes + path: . + + - name: Read summary and comment it + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const comment = fs.readFileSync('venv_sizes.txt', 'utf8'); + github.rest.issues.createComment({ + issue_number: context.payload.pull_request.number, + owner: context.repo.owner, + repo: context.repo.name, + body: `Bittensor SDK virtual environment sizes by Python version:**\n\n\`\`\`\n${comment}\n\`\`\`` + }); From b33b87dbc73a23cde8a6940c125e48d01c54ee51 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Apr 2025 12:00:32 -0700 Subject: [PATCH 02/11] update --- .../monitor_requirements_size_master.yml | 68 +++++++++---------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/.github/workflows/monitor_requirements_size_master.yml b/.github/workflows/monitor_requirements_size_master.yml index 7d86171d5e..6527b8abe4 100644 --- a/.github/workflows/monitor_requirements_size_master.yml +++ b/.github/workflows/monitor_requirements_size_master.yml @@ -7,7 +7,7 @@ name: Monitor SDK Requirements Size on: pull_request: - types: [opened] + types: [opened, synchronize] branches: [master] jobs: @@ -16,61 +16,59 @@ jobs: strategy: matrix: python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] - - name: Python ${{ matrix.python-version }} + outputs: + py39: ${{ steps.set-output.outputs.py39 }} + py310: ${{ steps.set-output.outputs.py310 }} + py311: ${{ steps.set-output.outputs.py311 }} + py312: ${{ steps.set-output.outputs.py312 }} + py313: ${{ steps.set-output.outputs.py313 }} steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Create virtualenv and install Bittensor SDK + - name: Create virtualenv and install run: | python -m venv venv source venv/bin/activate pip install --upgrade pip pip install . - - name: Measure venv folder size - id: venv-size - run: | - du -sm venv | cut -f1 > venv_size_mb.txt - echo "venv_size=$(cat venv_size_mb.txt)" >> $GITHUB_OUTPUT - - - name: Save size for summary + - name: Measure venv size + id: set-output run: | - echo "Python ${{ matrix.python-version }}: ${{ steps.venv-size.outputs.venv_size }} MB" >> $GITHUB_WORKSPACE/venv_sizes.txt - - - name: Upload summary file as artifact - uses: actions/upload-artifact@v4 - with: - name: venv_sizes - path: $GITHUB_WORKSPACE/venv_sizes.txt + SIZE=$(du -sm venv | cut -f1) + VERSION=${{ matrix.python-version }} + echo "Detected size: $SIZE MB for Python $VERSION" + case "$VERSION" in + 3.9) echo "py39=$SIZE" >> $GITHUB_OUTPUT ;; + 3.10) echo "py310=$SIZE" >> $GITHUB_OUTPUT ;; + 3.11) echo "py311=$SIZE" >> $GITHUB_OUTPUT ;; + 3.12) echo "py312=$SIZE" >> $GITHUB_OUTPUT ;; + 3.13) echo "py313=$SIZE" >> $GITHUB_OUTPUT ;; + esac comment-on-pr: if: github.event_name == 'pull_request' && github.base_ref == 'master' - runs-on: ubuntu-latest needs: measure-venv - + runs-on: ubuntu-latest steps: - - name: Download summary - uses: actions/download-artifact@v4 - with: - name: venv_sizes - path: . - - - name: Read summary and comment it + - name: Comment on PR uses: actions/github-script@v7 with: script: | - const fs = require('fs'); - const comment = fs.readFileSync('venv_sizes.txt', 'utf8'); + const sizes = { + "3.9": "${{ needs.measure-venv.outputs.py39 || 'N/A' }}", + "3.10": "${{ needs.measure-venv.outputs.py310 || 'N/A' }}", + "3.11": "${{ needs.measure-venv.outputs.py311 || 'N/A' }}", + "3.12": "${{ needs.measure-venv.outputs.py312 || 'N/A' }}", + "3.13": "${{ needs.measure-venv.outputs.py313 || 'N/A' }}" + }; + const lines = Object.entries(sizes).map(([ver, size]) => `Python ${ver}: ${size} MB`); github.rest.issues.createComment({ issue_number: context.payload.pull_request.number, owner: context.repo.owner, repo: context.repo.name, - body: `Bittensor SDK virtual environment sizes by Python version:**\n\n\`\`\`\n${comment}\n\`\`\`` + body: `Bittensor SDK virtual environment sizes by Python version:**\n\n\`\`\`\n${lines.join("\n")}\n\`\`\`` }); From 9f6bba33cf575ef789a12bdaa7df83b63efad5a6 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Apr 2025 12:02:11 -0700 Subject: [PATCH 03/11] trigger --- .github/workflows/monitor_requirements_size_master.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/monitor_requirements_size_master.yml b/.github/workflows/monitor_requirements_size_master.yml index 6527b8abe4..a16f157828 100644 --- a/.github/workflows/monitor_requirements_size_master.yml +++ b/.github/workflows/monitor_requirements_size_master.yml @@ -5,10 +5,16 @@ name: Monitor SDK Requirements Size +#on: +# pull_request: +# types: [opened] +# branches: [master] + on: pull_request: - types: [opened, synchronize] - branches: [master] + types: [opened, synchronize, reopened] + branches: + - master jobs: measure-venv: From 48192d588e6b00ee5c754f8da4bee44cf32135c7 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Apr 2025 12:10:13 -0700 Subject: [PATCH 04/11] trigger --- .../monitor_requirements_size_master.yml | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/workflows/monitor_requirements_size_master.yml b/.github/workflows/monitor_requirements_size_master.yml index a16f157828..eec56956f1 100644 --- a/.github/workflows/monitor_requirements_size_master.yml +++ b/.github/workflows/monitor_requirements_size_master.yml @@ -60,21 +60,24 @@ jobs: needs: measure-venv runs-on: ubuntu-latest steps: - - name: Comment on PR - uses: actions/github-script@v7 - with: - script: | - const sizes = { - "3.9": "${{ needs.measure-venv.outputs.py39 || 'N/A' }}", - "3.10": "${{ needs.measure-venv.outputs.py310 || 'N/A' }}", - "3.11": "${{ needs.measure-venv.outputs.py311 || 'N/A' }}", - "3.12": "${{ needs.measure-venv.outputs.py312 || 'N/A' }}", - "3.13": "${{ needs.measure-venv.outputs.py313 || 'N/A' }}" - }; - const lines = Object.entries(sizes).map(([ver, size]) => `Python ${ver}: ${size} MB`); - github.rest.issues.createComment({ - issue_number: context.payload.pull_request.number, - owner: context.repo.owner, - repo: context.repo.name, - body: `Bittensor SDK virtual environment sizes by Python version:**\n\n\`\`\`\n${lines.join("\n")}\n\`\`\`` - }); + - name: Post comment to PR + uses: actions/github-script@v7 + with: + script: | + const sizes = { + "3.9": "${{ needs.measure-venv.outputs.py39 || 'N/A' }}", + "3.10": "${{ needs.measure-venv.outputs.py310 || 'N/A' }}", + "3.11": "${{ needs.measure-venv.outputs.py311 || 'N/A' }}", + "3.12": "${{ needs.measure-venv.outputs.py312 || 'N/A' }}", + "3.13": "${{ needs.measure-venv.outputs.py313 || 'N/A' }}" + }; + const lines = Object.entries(sizes).map(([ver, size]) => `Python ${ver}: ${size} MB`); + const body = `Bittensor SDK virtual environment sizes by Python version:**\n\n\`\`\`\n${lines.join("\n")}\n\`\`\``; + + const { owner, repo } = context.repo; + github.rest.issues.createComment({ + issue_number: context.payload.pull_request.number, + owner, + repo, + body + }); From b78c3c173b88812b02c1a9c8a34a7fc4fd541efd Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Apr 2025 12:11:02 -0700 Subject: [PATCH 05/11] no py 3.13 for test (faster) --- .github/workflows/monitor_requirements_size_master.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/monitor_requirements_size_master.yml b/.github/workflows/monitor_requirements_size_master.yml index eec56956f1..52dc5eb4a1 100644 --- a/.github/workflows/monitor_requirements_size_master.yml +++ b/.github/workflows/monitor_requirements_size_master.yml @@ -21,13 +21,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python-version: ["3.9", "3.10", "3.11", "3.12"] outputs: py39: ${{ steps.set-output.outputs.py39 }} py310: ${{ steps.set-output.outputs.py310 }} py311: ${{ steps.set-output.outputs.py311 }} py312: ${{ steps.set-output.outputs.py312 }} - py313: ${{ steps.set-output.outputs.py313 }} +# py313: ${{ steps.set-output.outputs.py313 }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -52,7 +52,7 @@ jobs: 3.10) echo "py310=$SIZE" >> $GITHUB_OUTPUT ;; 3.11) echo "py311=$SIZE" >> $GITHUB_OUTPUT ;; 3.12) echo "py312=$SIZE" >> $GITHUB_OUTPUT ;; - 3.13) echo "py313=$SIZE" >> $GITHUB_OUTPUT ;; +# 3.13) echo "py313=$SIZE" >> $GITHUB_OUTPUT ;; esac comment-on-pr: @@ -69,7 +69,7 @@ jobs: "3.10": "${{ needs.measure-venv.outputs.py310 || 'N/A' }}", "3.11": "${{ needs.measure-venv.outputs.py311 || 'N/A' }}", "3.12": "${{ needs.measure-venv.outputs.py312 || 'N/A' }}", - "3.13": "${{ needs.measure-venv.outputs.py313 || 'N/A' }}" +# "3.13": "${{ needs.measure-venv.outputs.py313 || 'N/A' }}" }; const lines = Object.entries(sizes).map(([ver, size]) => `Python ${ver}: ${size} MB`); const body = `Bittensor SDK virtual environment sizes by Python version:**\n\n\`\`\`\n${lines.join("\n")}\n\`\`\``; From 8a15139456069465f549ab51e28d833fe28639a4 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Apr 2025 12:12:04 -0700 Subject: [PATCH 06/11] no py 3.13 for test (faster) --- .github/workflows/monitor_requirements_size_master.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/monitor_requirements_size_master.yml b/.github/workflows/monitor_requirements_size_master.yml index 52dc5eb4a1..5cd80bf142 100644 --- a/.github/workflows/monitor_requirements_size_master.yml +++ b/.github/workflows/monitor_requirements_size_master.yml @@ -27,7 +27,7 @@ jobs: py310: ${{ steps.set-output.outputs.py310 }} py311: ${{ steps.set-output.outputs.py311 }} py312: ${{ steps.set-output.outputs.py312 }} -# py313: ${{ steps.set-output.outputs.py313 }} + steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -52,7 +52,6 @@ jobs: 3.10) echo "py310=$SIZE" >> $GITHUB_OUTPUT ;; 3.11) echo "py311=$SIZE" >> $GITHUB_OUTPUT ;; 3.12) echo "py312=$SIZE" >> $GITHUB_OUTPUT ;; -# 3.13) echo "py313=$SIZE" >> $GITHUB_OUTPUT ;; esac comment-on-pr: @@ -69,7 +68,6 @@ jobs: "3.10": "${{ needs.measure-venv.outputs.py310 || 'N/A' }}", "3.11": "${{ needs.measure-venv.outputs.py311 || 'N/A' }}", "3.12": "${{ needs.measure-venv.outputs.py312 || 'N/A' }}", -# "3.13": "${{ needs.measure-venv.outputs.py313 || 'N/A' }}" }; const lines = Object.entries(sizes).map(([ver, size]) => `Python ${ver}: ${size} MB`); const body = `Bittensor SDK virtual environment sizes by Python version:**\n\n\`\`\`\n${lines.join("\n")}\n\`\`\``; From deb00149dfde7d7e7ecc58001c51a566fbf95af8 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Apr 2025 12:18:50 -0700 Subject: [PATCH 07/11] more --- .../monitor_requirements_size_master.yml | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/.github/workflows/monitor_requirements_size_master.yml b/.github/workflows/monitor_requirements_size_master.yml index 5cd80bf142..3bf2fba602 100644 --- a/.github/workflows/monitor_requirements_size_master.yml +++ b/.github/workflows/monitor_requirements_size_master.yml @@ -59,23 +59,30 @@ jobs: needs: measure-venv runs-on: ubuntu-latest steps: - - name: Post comment to PR - uses: actions/github-script@v7 - with: - script: | - const sizes = { - "3.9": "${{ needs.measure-venv.outputs.py39 || 'N/A' }}", - "3.10": "${{ needs.measure-venv.outputs.py310 || 'N/A' }}", - "3.11": "${{ needs.measure-venv.outputs.py311 || 'N/A' }}", - "3.12": "${{ needs.measure-venv.outputs.py312 || 'N/A' }}", - }; - const lines = Object.entries(sizes).map(([ver, size]) => `Python ${ver}: ${size} MB`); - const body = `Bittensor SDK virtual environment sizes by Python version:**\n\n\`\`\`\n${lines.join("\n")}\n\`\`\``; - - const { owner, repo } = context.repo; - github.rest.issues.createComment({ - issue_number: context.payload.pull_request.number, - owner, - repo, - body - }); + - name: Post venv size summary to PR + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const sizes = { + "3.9": "${{ needs.measure-venv.outputs.py39 || 'N/A' }}", + "3.10": "${{ needs.measure-venv.outputs.py310 || 'N/A' }}", + "3.11": "${{ needs.measure-venv.outputs.py311 || 'N/A' }}", + "3.12": "${{ needs.measure-venv.outputs.py312 || 'N/A' }}", + }; + + const body = [ + '**Bittensor SDK virtual environment sizes by Python version:**', + '', + '```' + ] + .concat(Object.entries(sizes).map(([v, s]) => `Python ${v}: ${s} MB`)) + .concat(['```']) + .join('\n'); + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body + }); From 3feedf747fb656c11e755e24cceda01f6516132e Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Apr 2025 12:25:04 -0700 Subject: [PATCH 08/11] add permissions --- .github/workflows/monitor_requirements_size_master.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/monitor_requirements_size_master.yml b/.github/workflows/monitor_requirements_size_master.yml index 3bf2fba602..0a2f390d72 100644 --- a/.github/workflows/monitor_requirements_size_master.yml +++ b/.github/workflows/monitor_requirements_size_master.yml @@ -16,6 +16,10 @@ on: branches: - master +permissions: + pull-requests: write + contents: read + jobs: measure-venv: runs-on: ubuntu-latest From 543ff034cd6c3ac3aa0e313ac72266937f6f976b Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Apr 2025 12:27:50 -0700 Subject: [PATCH 09/11] bring back 3.13 --- .github/workflows/monitor_requirements_size_master.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/monitor_requirements_size_master.yml b/.github/workflows/monitor_requirements_size_master.yml index 0a2f390d72..53833806fb 100644 --- a/.github/workflows/monitor_requirements_size_master.yml +++ b/.github/workflows/monitor_requirements_size_master.yml @@ -25,12 +25,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] outputs: py39: ${{ steps.set-output.outputs.py39 }} py310: ${{ steps.set-output.outputs.py310 }} py311: ${{ steps.set-output.outputs.py311 }} py312: ${{ steps.set-output.outputs.py312 }} + py313: ${{ steps.set-output.outputs.py313 }} steps: - uses: actions/checkout@v4 @@ -56,6 +57,7 @@ jobs: 3.10) echo "py310=$SIZE" >> $GITHUB_OUTPUT ;; 3.11) echo "py311=$SIZE" >> $GITHUB_OUTPUT ;; 3.12) echo "py312=$SIZE" >> $GITHUB_OUTPUT ;; + 3.13) echo "py313=$SIZE" >> $GITHUB_OUTPUT ;; esac comment-on-pr: @@ -73,6 +75,7 @@ jobs: "3.10": "${{ needs.measure-venv.outputs.py310 || 'N/A' }}", "3.11": "${{ needs.measure-venv.outputs.py311 || 'N/A' }}", "3.12": "${{ needs.measure-venv.outputs.py312 || 'N/A' }}", + "3.13": "${{ needs.measure-venv.outputs.py313 || 'N/A' }}", }; const body = [ From f47050c53c1a265cf31a887cd03aad0ad4f5780b Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Apr 2025 12:34:07 -0700 Subject: [PATCH 10/11] just for new master PR --- .github/workflows/monitor_requirements_size_master.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/monitor_requirements_size_master.yml b/.github/workflows/monitor_requirements_size_master.yml index 53833806fb..a567b4f7bc 100644 --- a/.github/workflows/monitor_requirements_size_master.yml +++ b/.github/workflows/monitor_requirements_size_master.yml @@ -5,16 +5,10 @@ name: Monitor SDK Requirements Size -#on: -# pull_request: -# types: [opened] -# branches: [master] - on: pull_request: - types: [opened, synchronize, reopened] - branches: - - master + types: [opened] + branches: [master] permissions: pull-requests: write From a0c67c899dffb07ae908d677c0555d49cd9643a0 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Apr 2025 12:40:24 -0700 Subject: [PATCH 11/11] check PR update --- .github/workflows/monitor_requirements_size_master.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/monitor_requirements_size_master.yml b/.github/workflows/monitor_requirements_size_master.yml index a567b4f7bc..301767ce7e 100644 --- a/.github/workflows/monitor_requirements_size_master.yml +++ b/.github/workflows/monitor_requirements_size_master.yml @@ -2,7 +2,6 @@ # after installing the Bittensor SDK across multiple Python versions. # It runs only when a new pull request targets the master branch, # and posts a comment with the results. - name: Monitor SDK Requirements Size on: