-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add file content #577
base: master
Are you sure you want to change the base?
add file content #577
Conversation
…make stdin more consistent
Documentation for usage of filesThis documentation will discuss all the changes made regarding FilesFiles are used to describe files that can be added as input for a test and will provide the student with this file in Dodona. This is done in the following way: files:
- name: "animal.txt"
url: "media/workdir/animal.txt"
file:
content: "animal.txt" # is the content that the file should have
location: "media/workdir/animal.txt" # is the location of the file
oracle: ... There are several issues with this:
The name input_files:
- name: "animal.txt"
path: "media/workdir/animal.txt"
- name: "human.txt"
path: "media/workdir/human.txt"
output_files:
data:
- content: "lion"
path: "media/workdir/animal.txt"
- content: "tim"
path: "media/workdir/human.txt"
oracle: ....
output_files:
- content: "animal"
path: "media/workdir/animal.txt"
- content: "humant"
path: "media/workdir/human.txt" You can still only specify paths in the output_files:
data:
- content: !path "animal.txt"
path: "media/workdir/animal.txt"
- content: "Humans can make music and a warm meal"
path: "media/workdir/human.txt"
oracle: .... So For the feedback, it's all still a bit fuzzy because right now all the content is dumped after eachother. Potential solution:
Most of that will probably need to happen on Dodona itself. Stdin, Stdout and StderrHow things currently work, you have to specify the full contents of the stdin, stdout and stderr channels. This can get ugly, when that's a lot of text. This is why the usage of files is also very benificial here. Example for Stdin: stdin: !path "media/workdir/animal.txt" The usage of Under the hood, Stderr and Stdout are both just textual output channels. So they both have the exact same functionality. Examples for Stdout: stdout: !path "media/workdir/animal.txt"
stdout:
content: !path "media/workdir/animal.txt"
config: ...
oracle: ... |
First review based on the text. I have a feeling the naming scheme is still a bit inconsistent. The input_files: List of files
- name: The name of the file to be used in the code (eg to pass to a function)
path: The path to the content of the file in the exercise directory But What I would have expected based on seeing output_files: List of files
- name: The name of the file the student should write it's output in
path: The path of the expected output file
content: Alternative to path, specify the expected content of the file inline here It would even be great if this Instead I like the I left out the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't specify it every time it is relevant, but how to properly handle the name changes seems like the biggest open issue. It will probably be best if we also discus this IRL tomorrow
@@ -39,7 +39,7 @@ | |||
} | |||
], | |||
"properties" : { | |||
"files" : { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly, we'll preferably remain backwards compatible here.
So while we can introduce a new improved naming scheme with input_files
and output_files
, we'll have to keep supporting the old scheme at the same time.
We could also think about starting to give deprecation notices, and/or automatically updating all existing exercises. (We have done these scripted updates before, but these have to be well timed, and with a growing number of users, we have a growing risk of confusing some, if we don't give proper deprecation warnings)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code itself looks OK, added some comments here and there.
More high-level:
- Jorg is right that we need backwards compatibility
- Your examples are slightly confusing, since the paths in the
output_files
will not be to the media dir, but rather the name of a file that is either specified in the assignment or as a parameter. So rather something like
output_files:
data:
- content: "lion"
path: "animal.txt"
- content: "tim"
path: "human.txt"
And when using a path as "content", it will probably be to a file inside in the evaluation folder of the exercise.
@@ -148,6 +168,7 @@ def _parse_yaml(yaml_stream: str) -> YamlObject: | |||
yaml.add_constructor("!" + actual_type, _custom_type_constructors, loader) | |||
yaml.add_constructor("!expression", _expression_string, loader) | |||
yaml.add_constructor("!oracle", _return_oracle, loader) | |||
yaml.add_constructor("!path", _path_string, loader) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not against adding another custom tag, but I do think we need to be slightly careful here, since we also expose all "TESTed types" as tags, this would prevent us from ever having a "path" type in TESTed.
An alternative is working with plain objects, e.g.
- path: "animal.txt"
content:
type: "path"
path: "media/workdir/animal.txt"
Again, not against it, just something to consider.
@@ -528,7 +535,7 @@ def get_functions(self) -> Iterable[FunctionCall]: | |||
|
|||
@define(frozen=True) | |||
class FileUrl: | |||
url: str | |||
path: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason this was named url
is that this is a path to the media folder of an exercise, since it is linked on Dodona. The "generated "file" stuff should all have paths to the evaluation
folder instead. Now, there is an argument to be made that this distinction is unnecessary, but that is done at the Dodona side (I think, it has been a while, so this should be checked).
But to be clear, I am not against renaming this, just giving some context.
…ists. Also fixed the tests
@@ -3,12 +3,20 @@ | |||
""" | |||
|
|||
import math | |||
import os |
Check notice
Code scanning / CodeQL
Unused import Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 1 day ago
To fix the problem, we should remove the unused import statement for the os
module. This will clean up the code and remove the unnecessary dependency, making the code easier to read and maintain.
- Locate the import statement for the
os
module on line 6. - Remove the line
import os
from the filetested/oracles/text.py
.
@@ -5,3 +5,2 @@ | ||
import math | ||
import os | ||
from typing import Any |
from tested.testsuite import ( | ||
FileOutputChannel, | ||
OutputChannel, | ||
OutputFileData, | ||
TextChannelType, | ||
TextOutputChannel, | ||
) |
Check notice
Code scanning / CodeQL
Unused import Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 1 day ago
To fix the problem, we need to remove the unused import statement for FileOutputChannel
. This will clean up the code and remove unnecessary dependencies, making the code easier to read and maintain.
- Locate the import statement for
FileOutputChannel
in the filetested/oracles/text.py
. - Remove the
FileOutputChannel
from the import statement on line 13. - Ensure that no other parts of the code rely on this import.
-
Copy modified line R14
@@ -13,3 +13,3 @@ | ||
from tested.testsuite import ( | ||
FileOutputChannel, | ||
|
||
OutputChannel, |
No description provided.