• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MarkUsProject / Markus / 16600642746

29 Jul 2025 03:33PM UTC coverage: 91.884% (+0.002%) from 91.882%
16600642746

Pull #7567

github

web-flow
Merge 925bbdba6 into 8944608a8
Pull Request #7567: Moved QR scanning to external python package markus_exam_matcher

658 of 1419 branches covered (46.37%)

Branch coverage included in aggregate %.

2 of 3 new or added lines in 3 files covered. (66.67%)

42034 of 45044 relevant lines covered (93.32%)

118.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.57
/config/initializers/python.rb
1
# Initialize python dependencies
2
require 'open3'
2✔
3

4
Rails.application.config.after_initialize do
2✔
5
  # Initialize this as explicitly false
6
  Rails.application.config.scanner_enabled = false
2✔
7
  Rails.application.config.nbconvert_enabled = false
2✔
8

9
  if Settings.python
2✔
10
    Rails.application.config.python = Settings.python
2✔
11
  else
12
    warn 'MARKUS WARNING: No python executable can be found in settings (under "python:"). ' \
×
13
         'The default python3 executable will be used instead.'
14
    Rails.application.config.python = 'python3'
×
15
  end
16

17
  def process_requirements(requirements_file)
2✔
18
    File.open(requirements_file).each_line.filter_map do |line|
4✔
19
      line.strip!
10✔
20
      line.tr!('-_', '')
10✔
21
      line.start_with?('#') || line.length.zero? ? nil : line
10✔
22
    end
23
  end
24

25
  begin
26
    installed, status = Open3.capture2(Rails.application.config.python, '-m', 'pip', 'freeze')
2✔
27
  rescue Errno::ENOENT
28
    warn 'MARKUS WARNING: No python3 executable can be found. Jupyter notebook rendering ' \
×
29
         'and Automatic student matching will be disabled. Install python3 to enable these features.'
30
  else
31
    pip = "#{Rails.application.config.python} -m pip"
2✔
32

33
    if status.success?
2✔
34
      installed = installed.lines.map(&:chomp)
2✔
35
      installed.each { |p| p.tr!('-_', '') }
132✔
36

37
      jupyter_requirements = process_requirements(Rails.root.join('requirements-jupyter.txt'))
2✔
38
      scanner_requirements = process_requirements(Rails.root.join('requirements-scanner.txt'))
2✔
39

40
      if (jupyter_requirements - installed).empty?
2✔
41
        Rails.application.config.nbconvert_enabled = true
2✔
42
      else
43
        warn 'MARKUS WARNING: not all packages required to process jupyter notebooks are installed. ' \
×
44
             'Jupyter notebook rendering will be disabled. ' \
45
             "To enable notebook rendering run: #{pip} install -r #{Rails.root.join('requirements-jupyter.txt')}"
46
      end
47
      if (scanner_requirements - installed).empty?
2✔
48
        Rails.application.config.scanner_enabled = true
2✔
49
      else
NEW
50
        warn 'MARKUS WARNING: not all packages required to process scanned exams and automatically match students ' \
×
51
             'for scanned exams are installed. Exam scanning will not be enabled and automatic student matching will ' \
52
             'be disabled. To enable exam scanning and automatic student matching run: ' \
53
             "#{pip} install -r #{Rails.root.join('requirements-scanner.txt')}"
54
      end
55
    else
56
      warn "MARKUS WARNING: '#{pip} freeze' failed with: #{installed}. Python code cannot be run."
×
57
    end
58
  end
59
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc