Skip to content

Commit 88a76cf

Browse files
committed
Add logging for evaluation debugging, update base image to Python 3.12, and switch staging-deploy workflow to main branch
1 parent b45dafa commit 88a76cf

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

.github/workflows/staging-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
if-no-files-found: warn
5353
deploy:
5454
needs: test
55-
uses: lambda-feedback/evaluation-function-workflows/.github/workflows/deploy.yml@deploy-request-on-dev
55+
uses: lambda-feedback/evaluation-function-workflows/.github/workflows/deploy.yml@main
5656
with:
5757
template-repository-name: "lambda-feedback/evaluation-function-boilerplate-python"
5858
build-platforms: "aws"

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/lambda-feedback/evaluation-function-base/python:feature-mued-3.12 AS builder
1+
FROM ghcr.io/lambda-feedback/evaluation-function-base/python:3.12 AS builder
22

33
RUN pip install poetry==1.8.3
44

@@ -12,7 +12,7 @@ COPY pyproject.toml poetry.lock ./
1212
RUN --mount=type=cache,target=$POETRY_CACHE_DIR \
1313
poetry install --without dev --no-root
1414

15-
FROM ghcr.io/lambda-feedback/evaluation-function-base/python:feature-mued-3.12
15+
FROM ghcr.io/lambda-feedback/evaluation-function-base/python:3.12
1616

1717
ENV VIRTUAL_ENV=/app/.venv \
1818
PATH="/app/.venv/bin:$PATH"

evaluation_function/evaluation.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import logging
12
from typing import Any
23
from sympy import simplify_logic, Equivalent
34
from lf_toolkit.evaluation import Result, Params
45
from lf_toolkit.parse.set import SetParser, LatexPrinter, SymPyBooleanTransformer, ASCIIPrinter
56

67
from .parse import parse_with_feedback, FeedbackException
78

9+
logger = logging.getLogger(__name__)
10+
logging.basicConfig(level=logging.DEBUG, format="%(levelname)s [%(name)s] %(message)s")
11+
812
def evaluation_function(
913
response: Any,
1014
answer: Any,
@@ -33,39 +37,58 @@ def evaluation_function(
3337
to output the evaluation response.
3438
"""
3539

40+
logger.debug("evaluation_function called")
41+
logger.debug("response type=%s value=%r", type(response).__name__, response)
42+
logger.debug("answer type=%s value=%r", type(answer).__name__, answer)
43+
logger.debug("params value=%r", params)
44+
3645
parser = SetParser.instance()
3746
sympyTransformer = SymPyBooleanTransformer()
3847

3948
# here we want to compare the response set with the example solution set.
4049
# we have to do the following steps
4150

4251
try:
52+
is_latex = params.get("is_latex", False)
53+
logger.debug("is_latex=%r", is_latex)
54+
4355
# 1. convert the `response`, which may be a latex string, to a sympy expression
44-
responseSet = parse_with_feedback(response, latex=params.get("is_latex", False))
56+
logger.debug("parsing response...")
57+
responseSet = parse_with_feedback(response, latex=is_latex)
58+
logger.debug("responseSet=%r", responseSet)
4559
responseSetSympy = sympyTransformer.transform(responseSet)
60+
logger.debug("responseSetSympy=%r", responseSetSympy)
4661

4762
# 2. convert the `answer`, which may be a latex string, to a sympy expression
4863
# TODO: what if answer is also in latex? how do we know?
64+
logger.debug("parsing answer...")
4965
try:
5066
answerSet = parser.parse(answer, latex=False)
5167
except Exception as e:
68+
logger.error("failed to parse answer: type=%s value=%r error=%r", type(answer).__name__, answer, e)
5269
raise FeedbackException() from e
70+
logger.debug("answerSet=%r", answerSet)
5371
answerSetSympy = sympyTransformer.transform(answerSet)
72+
logger.debug("answerSetSympy=%r", answerSetSympy)
5473

5574
# 3. compare the two sympy expressions w/ simplification enabled.
5675
# If they are equal, the sets produced by the two expressions are
5776
# semantically equal. However, the expressions may not be equal.
5877
semantic_equal = simplify_logic(Equivalent(responseSetSympy, answerSetSympy)) == True
78+
logger.debug("semantic_equal=%r", semantic_equal)
5979

6080
# 4. compare the two sympy expressions w/ simplifaction disabled.
6181
# If they are equal, the expressions are also equal in syntax.
6282
# This respects laws of commutativity, e.g. A u B == B u A.
6383
syntactic_equal = responseSetSympy == answerSetSympy
84+
logger.debug("syntactic_equal=%r", syntactic_equal)
6485

6586
enforce_expression_equality = params.get("enforce_expression_equality", False)
87+
logger.debug("enforce_expression_equality=%r", enforce_expression_equality)
6688

6789
# 5. `is_correct` is True, iff 3) is True, and either 4) or `enforce_expression_equality` is True
6890
is_correct = semantic_equal and (syntactic_equal or not enforce_expression_equality)
91+
logger.debug("is_correct=%r", is_correct)
6992

7093
feedback_items=[]
7194

@@ -87,6 +110,7 @@ def evaluation_function(
87110
feedback_items=feedback_items,
88111
)
89112
except FeedbackException as e:
113+
logger.error("FeedbackException: %r", e)
90114
return Result(
91115
is_correct=False,
92116
feedback_items=[("parse_error", str(e))]

0 commit comments

Comments
 (0)