Skip to content

fix: de-duplicate identical editions in all_editions (#317) #660

fix: de-duplicate identical editions in all_editions (#317)

fix: de-duplicate identical editions in all_editions (#317) #660

Workflow file for this run

name: Benchmark Pull Request
on:
pull_request:
repository_dispatch:
types: [ reporters-db-pr ]
env:
main: "$(/usr/bin/git log -1 --format='%H')"
jobs:
benchmark:
name: PR comment
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v5
- name: Set up Python
id: setup-python
uses: actions/setup-python@v6
with:
python-version: 3.12
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
version: "0.7.x"
- name: Add or Update comment on PR that Test is running
uses: marocchino/sticky-pull-request-comment@v3
with:
recreate: true
message: |
Eyecite Benchmarking in progress...
For details, see: https://github.com/freelawproject/eyecite/actions/workflows/benchmark.yml
This message will be updated when the test is completed.
- name: Install Python dependencies
run: |
uv sync --frozen --no-group dev --group benchmark
source .venv/bin/activate
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
# branch1 = the PR (the repo is checked out at the PR ref here, so
# `env.main` resolves to the PR head sha). The baseline (main) is
# captured later as branch2, after we check main out.
- name: Setup variables I
id: branch1
run: |
echo ${{ github.event.issue.pull_request }}
echo "filepath=benchmark/${{ env.main }}.json" >> "$GITHUB_OUTPUT"
echo "hash=${{ env.main }}" >> "$GITHUB_OUTPUT"
#----------------------------------------------
# Download Testing File
#
# We generated our testing datasets with the following command:
#
# root@maintenance:/opt/courtlistener# PGPASSWORD=$DB_PASSWORD psql \
# --host $DB_HOST \
# --username $DB_USER \
# --dbname courtlistener \
# --command \
# 'set statement_timeout to 0;
# COPY (
# SELECT \
# id, plain_text, html, html_lawbox, html_columbia, html_anon_2020, xml_harvard \
# FROM \
# search_opinion \
# TABLESAMPLE BERNOULLI (0.1) \
# ) \
# TO STDOUT \
# WITH (FORMAT csv, ENCODING utf8, HEADER); \
# ' \
# | bzip2 \
# | aws s3 cp - s3://com-courtlistener-storage/bulk-data/eyecite/tests/ten-percent.csv.bz2 \
# --acl public-read
#----------------------------------------------
- name: Download Testing File
run: |
curl https://storage.courtlistener.com/bulk-data/eyecite/tests/one-percent.csv.bz2 --output benchmark/bulk-file.csv.bz2
- name: Run first benchmark
run: |
python benchmark/benchmark.py --branches ${{ steps.branch1.outputs.hash }}
# Preserve the PR's benchmark.py outside the working tree: the next
# step checks out main (clean: true), which would otherwise replace
# this script with main's version. The second run needs main's
# eyecite *library* for the baseline, but the PR's *script* so its
# report/CLI changes (e.g. --base) actually run.
cp benchmark/benchmark.py "$RUNNER_TEMP/benchmark.py"
git stash --include-untracked
- uses: actions/checkout@v5
with:
repository: freelawproject/eyecite
ref: main
- name: Install dependencies 2
run: uv sync --frozen --no-group dev --group benchmark
# branch2 = main (we just checked it out above), i.e. the baseline.
- name: Setup variables II
id: branch2
run: |
echo "filepath=benchmark/${{ env.main }}.json" >> "$GITHUB_OUTPUT"
echo "hash=${{ env.main }}" >> "$GITHUB_OUTPUT"
# Pass --base so gains/losses are oriented against main regardless of
# the order the two hashes appear in --branches.
- name: Run second benchmark
run: |
git stash pop
# Restore the PR's benchmark.py over main's checkout so the report
# generation and the --base flag come from the PR, not from main.
cp "$RUNNER_TEMP/benchmark.py" benchmark/benchmark.py
python benchmark/benchmark.py --branches ${{ steps.branch1.outputs.hash }} ${{ steps.branch2.outputs.hash }} --base ${{ steps.branch2.outputs.hash }} --pr ${{ github.event.number }}
mkdir results
mv benchmark/output.csv benchmark/${{ steps.branch1.outputs.hash }}.json benchmark/${{ steps.branch2.outputs.hash }}.json benchmark/report.md benchmark/chart.png results/
#----------------------------------------------
# Upload to Github PR
#----------------------------------------------
- name: Pushes test file
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.FREELAWBOT_TOKEN }}
with:
user_email: 'info@free.law'
user_name: 'freelawbot'
source_file: 'results/'
destination_repo: 'freelawproject/eyecite'
destination_folder: '${{ github.event.number }}'
destination_branch: 'artifacts'
commit_message: 'feat(ci): Add artifacts for PR# ${{ github.event.number }}'
- name: Add or Update PR Comment from Generated Report
uses: marocchino/sticky-pull-request-comment@v3
with:
recreate: true
path: results/report.md
dispatch:
name: Reporters-DB-Dipatch
if: github.event_name == 'repository_dispatch'
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v5
- name: Set up Python
id: setup-python
uses: actions/setup-python@v6
with:
python-version: 3.12
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
version: "0.7.x"
- name: Add or Update comment on PR that Test is running
uses: marocchino/sticky-pull-request-comment@v3
with:
recreate: true
GITHUB_TOKEN: ${{ secrets.FREELAWBOT_TOKEN }}
number: ${{ github.event.client_payload.pr_number }}
repo: reporters-db
message: |
Eyecite Benchmarking in progress ...
This message will be updated when the test is completed.
- name: Install Python dependencies
run: |
uv sync --frozen --no-group dev --group benchmark
source .venv/bin/activate
echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
- name: Run Tests
run: |
uv pip install "git+https://github.com/freelawproject/reporters-db.git"
echo ${{ github.event.client_payload.pr_number }}
curl https://storage.courtlistener.com/bulk-data/eyecite/tests/one-percent.csv.bz2 --output benchmark/bulk-file.csv.bz2
python benchmark/benchmark.py --branches original
uv pip install "git+https://github.com/freelawproject/reporters-db.git@${{ github.event.client_payload.commit }}"
# "original" is the baseline; "update" is the reporters-db PR.
python benchmark/benchmark.py --branches original update --base original --reporters --pr ${{ github.event.client_payload.pr_number }}
mkdir results
mv benchmark/output.csv benchmark/original.json benchmark/update.json benchmark/report.md benchmark/chart.png results/
- name: Pushes test file
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.FREELAWBOT_TOKEN }}
with:
user_email: 'info@free.law'
user_name: 'freelawbot'
source_file: 'results/'
destination_repo: 'freelawproject/reporters-db'
destination_folder: '${{ github.event.client_payload.pr_number }}'
destination_branch: 'artifacts'
commit_message: 'feat(ci): Add artifacts for PR #${{ github.event.client_payload.pr_number }}'
- name: Add or Update PR Comment from Generated Report
uses: marocchino/sticky-pull-request-comment@v3
with:
recreate: true
GITHUB_TOKEN: ${{ secrets.FREELAWBOT_TOKEN }}
path: results/report.md
number: ${{ github.event.client_payload.pr_number }}
repo: reporters-db