Skip to content

Commit ae83f9c

Browse files
david-yz-liuNaragod
authored andcommitted
Upgraded to markus_exam_matcher v0.4.0 (#7823)
1 parent febc001 commit ae83f9c

7 files changed

Lines changed: 30 additions & 25 deletions

File tree

.dockerfiles/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MARKUS__REDIS__URL=redis://redis:6379/
2-
MARKUS__PYTHON=/app/venv/bin/python
2+
MARKUS__PYTHON=/app/venv/bin/python3.13
33
PGUSER=postgres
44
PGHOST=postgres
55
PGPORT=5432

.dockerfiles/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ ENV PATH="$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH"
7777

7878
# install optional system dependencies
7979
RUN apt-get update -qq && \
80+
DEBIAN_FRONTEND=noninteractive apt-get -y install software-properties-common && \
81+
DEBIAN_FRONTEND=noninteractive add-apt-repository -y ppa:deadsnakes/ppa && \
8082
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends openssh-server \
81-
python3 \
82-
python3-dev \
83-
python3-venv \
83+
python3.13 \
84+
python3.13-venv \
8485
equivs \
8586
libjemalloc2
8687

.dockerfiles/entrypoint-dev-deps-updater.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,22 @@ else
2020
fi
2121

2222
# Install Python packages
23-
[ -f ./venv/bin/python3 ] || python3 -m venv ./venv
24-
./venv/bin/python3 -m pip install -q --upgrade pip
25-
printf "[MarkUs] Running pip install -q -r requirements-jupyter.txt..."
26-
if ./venv/bin/python3 -m pip install -q -r requirements-jupyter.txt; then
23+
PYTHON_EXE=./venv/bin/python3.13
24+
[ -f $PYTHON_EXE ] || python3.13 -m venv ./venv
25+
$PYTHON_EXE -m pip install -q --upgrade pip
26+
$PYTHON_EXE -m pip install -q uv
27+
printf "[MarkUs] Running $PYTHON_EXE -m pip install -q -r requirements-jupyter.txt..."
28+
if $PYTHON_EXE -m pip install -q -r requirements-jupyter.txt; then
2729
printf " \e[32m✔\e[0m \n"
2830
fi
29-
printf "[MarkUs] Running pip install -q -r requirements-scanner.txt..."
30-
if ./venv/bin/python3 -m pip install -q -r requirements-scanner.txt; then
31+
printf "[MarkUs] Running $PYTHON_EXE -m pip install -q -r requirements-scanner.txt..."
32+
if $PYTHON_EXE -m pip install --extra-index-url https://download.pytorch.org/whl/cpu -r requirements-scanner.txt; then
3133
printf " \e[32m✔\e[0m \n"
3234
fi
3335

3436
# Install chromium (for nbconvert webpdf conversion)
35-
printf "[MarkUs] Running playwright install chromium..."
36-
if ./venv/bin/python3 -m playwright install chromium; then
37+
printf "[MarkUs] Running $PYTHON_EXE -m playwright install chromium..."
38+
if $PYTHON_EXE -m playwright install chromium; then
3739
printf " \e[32m✔\e[0m \n"
3840
fi
3941

.github/workflows/test_ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
- name: Install python
102102
uses: actions/setup-python@v5
103103
with:
104-
python-version: "3.10"
104+
python-version: "3.13"
105105
- name: Get pip cache dir
106106
id: pip-cache
107107
run: |
@@ -122,8 +122,8 @@ jobs:
122122
${{ runner.os }}-playwright-
123123
- name: Install python packages and playwright dependencies
124124
run: |
125-
python3.10 -m venv venv
126-
./venv/bin/pip install -r requirements-jupyter.txt -r requirements-scanner.txt
125+
python3.13 -m venv venv
126+
./venv/bin/pip install --extra-index-url https://download.pytorch.org/whl/cpu -r requirements-jupyter.txt -r requirements-scanner.txt
127127
./venv/bin/playwright install chromium
128128
- name: Configure server
129129
run: |

app/jobs/split_pdf_job.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,16 @@ def perform(exam_template, _path, split_pdf_log, _original_filename = nil, _role
5252
qr_scan_results = {}
5353
if status.success?
5454
csv = CSV.parse(stdout, headers: false)
55-
csv.each do |row|
55+
csv.each_with_index do |row, i|
5656
next if row.empty?
5757
qr_scan_results[row[0]] = row.length >= 2 ? row[1] : ''
58+
if row.length >= 3
59+
orientation = row[2].to_i
60+
if (-181..-179).cover?(orientation) || (179..181).cover?(orientation)
61+
current_rotation = pdf.pages[i][:Rotate] || 0
62+
pdf.pages[i][:Rotate] = (current_rotation + orientation) % 360
63+
end
64+
end
5865
end
5966
else
6067
raise "Error running markus-exam-matcher. Details:\n#{stdout}\n#{stderr}"

requirements-scanner.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# TODO: replace requirements files with Pipfile file (when it is stable and supported by pip)
2-
markus_exam_matcher==0.2.0
2+
markus_exam_matcher==0.4.0

spec/jobs/split_pdf_job_spec.rb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,9 @@
8181
SplitPdfJob.perform_now(exam_template, '', split_pdf_log, filename, instructor, user)
8282

8383
expect(Group.count).to eq 1
84-
expect(split_pdf_log.num_groups_in_incomplete).to eq 1
85-
expect(split_pdf_log.num_pages_qr_scan_error).to eq 2
86-
expect(split_pdf_log.split_pages.where(status: 'ERROR: QR code not found').count).to eq 2
87-
expect(split_pdf_log.split_pages.where(status: 'Saved to incomplete directory').count).to eq 4
88-
89-
# Check that error pages were saved correctly.
90-
error_dir_entries = Dir.entries(File.join(exam_template.base_path, 'error')) - %w[. ..]
91-
expect(error_dir_entries.length).to eq 2
84+
expect(split_pdf_log.num_groups_in_complete).to eq 1
85+
expect(split_pdf_log.num_pages_qr_scan_error).to eq 0
86+
expect(split_pdf_log.split_pages.where(status: 'Saved to complete directory').count).to eq 6
9287
end
9388

9489
it 'correctly splits a PDF with one test paper with three pages having an unparseable QR code but parseable text' do

0 commit comments

Comments
 (0)