Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
fd2f05a
Refactor test structure: move test files to `app/tests/`, update impo…
m-messer Oct 13, 2026
4ee224a
Refactor preview structure: move context-specific preview functions, …
m-messer Oct 13, 2026
cdadcc4
Refactor symbolic and numerical contexts: extract set equivalence and…
m-messer Oct 14, 2026
27015fd
Refactor context structure: reorganize symbolic and physical_quantity…
m-messer Oct 15, 2026
779ff7a
Refactor graph helpers: extract shared helper functions (`attach_term…
m-messer Oct 15, 2026
1ecf0db
Refactor symbolic context: remove `set_equivalence.py`, add `graphs` …
m-messer Oct 15, 2026
ff41cd4
Refactor physical_quantity context: split logic into separate modules…
m-messer Oct 15, 2026
ef623c2
Refactor evaluation module: extract reusable logic into helper functi…
m-messer Oct 15, 2026
3f866c5
Add reserved keyword validations to evaluation tests and refactor fee…
m-messer Oct 15, 2026
52669fa
Refactor context structure and evaluation logic: introduce `context/d…
m-messer Oct 15, 2026
c8916c0
Refactor operators and evaluation logic: centralize `COMPARISON_OPERA…
m-messer Oct 15, 2026
c308253
Introduce type annotations for all modules in `app/`, add `mypy.ini` …
m-messer Oct 16, 2026
6fdbf28
Adopt absolute imports across `app/`, replace all relative imports, a…
m-messer Oct 16, 2026
b2aeb70
Centralize type aliases in `app/types.py`, update type hints across t…
m-messer Oct 16, 2026
5a137fa
Update type aliases in `comparison.py` to use centralized definitions…
m-messer Oct 16, 2026
821829c
Update dev docs to reflect absolute import path changes in `app/types…
m-messer Oct 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/staging-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,24 @@ jobs:
- name: Install dependencies
run: |
python -m venv .venv
.venv/bin/pip install pytest
.venv/bin/pip install -r requirements-dev.txt
.venv/bin/pip install -r app/requirements.txt


- name: Lint with flake8
run: |
source .venv/bin/activate
.venv/bin/pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 ./app --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 ./app --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

- name: Type check with mypy
run: |
source .venv/bin/activate
# configuration (checked files, strictness, untyped dependencies) is in mypy.ini
mypy

- name: Run tests
if: always()
run: |
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,23 @@ jobs:
- name: Install dependencies
run: |
python -m venv .venv
.venv/bin/pip install pytest
.venv/bin/pip install -r requirements-dev.txt
.venv/bin/pip install -r app/requirements.txt

- name: Lint with flake8
run: |
source .venv/bin/activate
.venv/bin/pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 ./app --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 ./app --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

- name: Type check with mypy
run: |
source .venv/bin/activate
# configuration (checked files, strictness, untyped dependencies) is in mypy.ini
mypy

- name: Run tests
if: always()
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This version is specifically for python, however the ultimate goal is to make si
5. You are now ready to start developing your function:

- Edit the `app/evaluation.py` file, which ultimately gets called when the function is given the `eval` command
- Add pytest tests to `app/evaluation_test.py`, `app/preview_test.py` or `app/tests/`. They get run:
- Add pytest tests to `app/tests/`. They get run:
- On every pull request and before the image is built and deployed (`pytest` from the repo root)
- Whenever the `healthcheck` command is supplied to the deployed function (via `app/evaluation_tests.py`)
- Edit `app/docs/user.md` and `app/docs/dev.md` to reflect your changes. These files are baked into the function's image, and is made available using the `docs` command. This feature is used to display this function's documentation on our [Documentation](https://lambda-feedback.github.io/Documentation/) website once it's been hooked up!
Expand Down
5 changes: 4 additions & 1 deletion app/conftest.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
def pytest_configure(config):
import pytest


def pytest_configure(config: pytest.Config) -> None:
config.addinivalue_line("markers", "slow: excluded from the deployed healthcheck (see evaluation_tests.py)")
9 changes: 9 additions & 0 deletions app/context/defaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Default evaluation parameters shared by all contexts; each context adds its own on top of these."""

base_default_parameters = {
"complexNumbers": False,
"convention": "equal_precedence",
"elementary_functions": False,
"strict_syntax": False,
"multiple_answers_criteria": "all",
}
38 changes: 38 additions & 0 deletions app/context/graph_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Helpers for building the `CriteriaGraph`s shared by the symbolic and physical quantity contexts."""

from __future__ import annotations

from collections.abc import Mapping
from typing import Any

from lambdafeedback.criteria import CriteriaGraph, FeedbackStringGenerator, OutputNode, ReachedCriteria


def outcome_tag(label: str, result: bool | None, inputs: Mapping[str, Any] | None = None) -> ReachedCriteria:
"""`{label+"_TRUE": inputs}` if `result` is True, `label+"_FALSE"` if it is False, otherwise `label+"_UNKNOWN"`."""
if result is True:
return {label+"_TRUE": inputs}
elif result is False:
return {label+"_FALSE": inputs}
else:
return {label+"_UNKNOWN": inputs}


def attach_terminal_criterion(
graph: CriteriaGraph,
evaluation_label: str,
label: str,
end: OutputNode,
summary: str,
details: str,
feedback_string_generator: FeedbackStringGenerator | None = None,
) -> None:
"""Attaches a new criterion `label` to `evaluation_label` and connects it to the `end` node."""
graph.attach_new_criterion(
evaluation_label,
label,
summary=summary,
details=details,
feedback_string_generator=feedback_string_generator
)
graph.attach(label, end.label)
11 changes: 11 additions & 0 deletions app/context/operators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""The comparison operators that criteria can use, by the symbol used in the criteria string."""

import operator

COMPARISON_OPERATORS = {
"=": operator.eq,
">": operator.gt,
">=": operator.ge,
"<": operator.lt,
"<=": operator.le,
}
Loading
Loading