Skip to content

Commit 5ff76c8

Browse files
committed
fix: freezegun version
fix: py version fix: env class fix: ut issues fix: timezone issue fix: timezone issue
1 parent b61186d commit 5ff76c8

File tree

11 files changed

+472
-388
lines changed

11 files changed

+472
-388
lines changed

.github/workflows/pyright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
15+
python-version: ["3.11", "3.13"]
1616

1717
steps:
1818
- uses: jakebailey/pyright-action@v2

.github/workflows/ruff.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
15+
python-version: ["3.11", "3.13"]
1616

1717
steps:
1818
- name: Checkout
@@ -31,7 +31,8 @@ jobs:
3131

3232
strategy:
3333
matrix:
34-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
34+
# Min-max supported versions
35+
python-version: ["3.11", "3.13"]
3536

3637
steps:
3738
- name: Checkout

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ jobs:
3030
run: |
3131
set -o pipefail
3232
uv run pytest --cov-fail-under=70 --junitxml=./.github-pytest/pytest-output.xml | tee .github-pytest/pytest-coverage.txt
33+
env:
34+
OMR_CHECKER_CONTAINER: true
35+
TZ: Asia/Kolkata
3336

3437
- name: Pytest coverage comment
3538
uses: MishaKav/pytest-coverage-comment@v1

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies = [
3232
dev = [
3333
"coverage==7.6.0",
3434
"flake8==7.0.0",
35-
"freezegun==1.4.0",
35+
"freezegun>=1.4.0",
3636
"mkdocs-material>=9.5.50",
3737
"Pillow==11.1.0",
3838
"pre-commit>=4.1.0",

src/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
# https://docs.python.org/3/tutorial/modules.html#:~:text=The%20__init__.py,on%20the%20module%20search%20path.
22

33
# Note: This import is added to the root __init__.py to adjust for perceived loading time
4-
import os
54
from pathlib import Path
65

6+
from src.utils.env import env
77
from src.utils.logger import logger
88

99
# It takes a few seconds for the imports
1010
logger.info("Loading OMRChecker modules...")
1111

12-
VIRTUAL_ENV = os.environ.get("VIRTUAL_ENV", "Not Present")
12+
logger.info(f"VIRTUAL_ENV: {env.VIRTUAL_ENV}")
1313

14-
logger.info(f"VIRTUAL_ENV: {VIRTUAL_ENV}")
15-
16-
if not Path(VIRTUAL_ENV).exists():
14+
if not Path(env.VIRTUAL_ENV).exists():
1715
logger.warning("Your virtual Environment doesn't exist at the path!")

src/algorithm/template/detection/bubbles_threshold/interpretation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import math
2-
import os
32
import random
43
import re
54

@@ -16,6 +15,7 @@
1615
BubblesFieldInterpretationDrawing,
1716
)
1817
from src.algorithm.template.layout.field.base import Field
18+
from src.utils.env import env
1919
from src.utils.logger import logger
2020

2121

@@ -226,7 +226,7 @@ def get_global_threshold(
226226
def plot_for_global_threshold(
227227
plot_means_and_refs, plot_title, file_level_fallback_threshold, thr2
228228
) -> None:
229-
if os.environ.get("OMR_CHECKER_CONTAINER"):
229+
if env.OMR_CHECKER_CONTAINER:
230230
return
231231
_, ax = plt.subplots()
232232
# TODO: move into individual utils

src/processors/AutoRotate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, *args, **kwargs) -> None:
2222
if not path.exists():
2323
msg = f"Reference image for AutoRotate not found at {path}"
2424
raise Exception(msg)
25-
self.reference_image = cv2.imread(path, cv2.IMREAD_GRAYSCALE)
25+
self.reference_image = cv2.imread(str(path), cv2.IMREAD_GRAYSCALE)
2626
self.marker_dimensions = self.options.get("markerDimensions", None)
2727
self.resized_reference = self.reference_image
2828
self.threshold = self.options.get("threshold", None)

src/tests/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def run_entry_point(input_path, output_dir) -> None:
3333
"outputMode": "default",
3434
}
3535
with freeze_time(FROZEN_TIMESTAMP):
36+
import time
37+
38+
frozen_time = time.time()
39+
assert frozen_time == 0, f"Frozen time is not 0: {frozen_time}"
3640
entry_point_for_args(args)
3741

3842

src/utils/env.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import os
2+
3+
4+
class Env:
5+
# Container for all environment variables used in OMRChecker
6+
CI = os.environ.get("CI")
7+
OMR_CHECKER_CONTAINER = os.environ.get("OMR_CHECKER_CONTAINER", CI)
8+
VIRTUAL_ENV = os.environ.get("VIRTUAL_ENV", "Not Present")
9+
10+
11+
env = Env()

src/utils/interaction.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
from dataclasses import dataclass
32

43
import cv2
@@ -7,14 +6,15 @@
76

87
from src.utils.constants import WAIT_KEYS
98
from src.utils.drawing import DrawingUtils
9+
from src.utils.env import env
1010
from src.utils.image import ImageUtils
1111
from src.utils.logger import logger
1212

1313

1414
@dataclass
1515
class ImageMetrics:
1616
# TODO: fix window metrics doesn't account for the doc/taskbar on macos
17-
if os.environ.get("OMR_CHECKER_CONTAINER"):
17+
if env.OMR_CHECKER_CONTAINER:
1818
monitor_window = Monitor(0, 0, 1000, 1000, 100, 100, "FakeMonitor", False) # NOQA: FBT003
1919
else:
2020
monitor_window = get_monitors()[0]
@@ -134,7 +134,7 @@ def show(
134134
config=None,
135135
) -> None:
136136
image_metrics = InteractionUtils.image_metrics
137-
if os.environ.get("OMR_CHECKER_CONTAINER"):
137+
if env.OMR_CHECKER_CONTAINER:
138138
return
139139
if image is None:
140140
logger.warning(f"'{name}' - NoneType image to show!")

0 commit comments

Comments
 (0)