Skip to content

Commit 719ab52

Browse files
committed
Fixed IO and stucture
1 parent 8cd3772 commit 719ab52

File tree

4 files changed

+37
-31
lines changed

4 files changed

+37
-31
lines changed

Dockerfile

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
FROM ghcr.io/lambda-feedback/evaluation-function-base/wolfram:latest AS final
2-
3-
# Use the WSTP server as a kernel backend
4-
ENV WSTP_SERVER="true"
1+
FROM ghcr.io/lambda-feedback/evaluation-function-base/wolfram:latest as base
52

63
# Command to start the evaluation function with
74
ENV FUNCTION_COMMAND="wolframscript"
@@ -12,22 +9,17 @@ ENV FUNCTION_ARGS="-f,/app/evaluation_function.wl"
129
# Interface to use for the evaluation function
1310
ENV FUNCTION_INTERFACE="file"
1411

12+
ENV LOG_LEVEL="DEBUG"
13+
1514
# Copy the evaluation function to the app directory
1615
COPY ./evaluation_function.wl /app/evaluation_function.wl
1716

18-
# Final layer for private images, which contains the wolfram licence key,
19-
# and is started with the shimmy handle command.
20-
FROM final AS final-private
21-
22-
# Copy the mathpass secret to the Wolfram Engine licensing directory.
23-
# See https://hub.docker.com/r/wolframresearch/wolframengine for more information.
24-
RUN --mount=type=secret,id=mathpass \
25-
mkdir -p /tmp/home/.WolframEngine/Licensing && \
26-
cp /run/secrets/mathpass /tmp/home/.WolframEngine/Licensing/mathpass
27-
17+
FROM base AS with-license
18+
COPY ./dist/LICENCE.txt /home/wolframengine/.WolframEngine/Licensing/mathpass
2819

29-
RUN apt-get update && apt-get install -y \
30-
netcat \
31-
&& rm -rf /var/lib/apt/lists/*
20+
FROM base AS without-license
21+
# no COPY, no error
3222

33-
COPY ./entrypoint.sh /entrypoint.sh
23+
# Choose final stage with build arg
24+
ARG WITH_LICENSE=false
25+
FROM ${WITH_LICENSE:+with-license}${WITH_LICENSE:-without-license}

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"EvaluationFunctionName": ""
2+
"EvaluationFunctionName": "wolframEvaluationFunction"
33
}

evaluation_function.wl

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,25 +140,36 @@ evalQ[type_, answer_, response_, params_] := Module[{},
140140
];
141141

142142
EvaluationFunction[type_, answer_, response_, params_] := Module[{tolerance, correctQ, error},
143+
Print["Running Evaluation Function"];
143144
result = evalQ[type, answer, response, params];
144-
<|
145-
"is_correct" -> result["is_correct"],
146-
"feedback" -> If[result["is_correct"],
145+
Print["Results"];
146+
Print[result];
147+
feedback = If[result["is_correct"],
147148
Lookup[params, "correct_response_feedback", "Correct!"],
148149
Lookup[params, "incorrect_response_feedback", "Incorrect!"]
149-
],
150-
"error" -> result["error"]
150+
];
151+
<|
152+
"command" -> "eval",
153+
"result" -> <|
154+
"is_correct" -> result["is_correct"],
155+
"feedback" -> feedback,
156+
"error" -> result["error"]
157+
|>
151158
|>
152159
];
153160

154161
evalQuestionIO = Function[
155162
Module[{jsonData, result},
156163
jsonData = Import[#1, "JSON"] //. List :> Association;
157-
type = jsonData["comparisonType"];
158-
answer = jsonData["answerTemplate"];
159-
response = jsonData["response"];
160-
params = jsonData["params"];
164+
requestData = jsonData["params"];
165+
answer = requestData["answer"];
166+
response = requestData["response"];
167+
params = requestData["params"];
168+
type = params["comparisonType"];
169+
Print["Evaluating Response Against Answer"];
161170
result = EvaluationFunction[type, answer, response, params];
171+
Print["Response"];
172+
Print[result];
162173
Export[#2, result, "JSON", "Compact" -> True]
163174
]
164175
];

structure_match_example1.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
2-
"comparisonType":"structure",
3-
"answerTemplate":"Sin[p x + q]",
2+
"method": "eval",
3+
"params": {
4+
"answer":"Sin[p x + q]",
45
"response":"Sin[a x + b]",
56
"params":{
7+
"comparisonType":"structure",
68
"named_variables":"{x}",
79
"correct_response_feedback":"Your answer is correct!",
810
"incorrect_response_feedback":"Your answer is incorrect!"
911
}
10-
}
12+
}
13+
}

0 commit comments

Comments
 (0)