Skip to content

Check File Discrepancies #208

Check File Discrepancies

Check File Discrepancies #208

name: Check File Discrepancies
on:
schedule:
- cron: '0 0 * * *' # Daily at midnight
workflow_dispatch: # Allow manual triggers
jobs:
check-files:
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Cache Huggingface assets
uses: actions/cache@v4
with:
key: huggingface-0-${{ runner.os }}-3.11-${{ hashFiles('**/pyproject.toml') }}
path: ~/.cache/huggingface
restore-keys: |
huggingface-0-${{ runner.os }}-3.11-
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-${{ runner.os }}-3.11-1
- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-0-${{ runner.os }}-3.11-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
venv-0-${{ runner.os }}-3.11-
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction
- name: Run file check script
run: |
poetry run python scripts/huggingface_sae_sync.py > file_discrepancies.txt
- name: Create issue from output
uses: actions/github-script@v7
if: success() # Only create issue if script succeeds
with:
script: |
const fs = require('fs');
const scriptOutput = fs.readFileSync('file_discrepancies.txt', 'utf8');
// Only create issue if there are discrepancies
if (scriptOutput.trim()) {
const date = new Date().toISOString().split('T')[0];
const issueBody = `
# File Discrepancy Report - ${date}
The following discrepancies were found between HuggingFace repositories and sae_lens:
\`\`\`
${scriptOutput}
\`\`\`
## Action Required
Please review these discrepancies and:
1. Update sae_lens mappings if needed
2. Check if any files are missing from HuggingFace repos
3. Verify file paths are correct in both systems
## Run Details
- Workflow: ${process.env.GITHUB_WORKFLOW}
- Run ID: ${process.env.GITHUB_RUN_ID}
- Triggered by: ${process.env.GITHUB_EVENT_NAME}
`;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `File Discrepancy Report - ${date}`,
body: issueBody,
labels: ['file-check', 'needs-review']
});
}