Skip to content

Adding the programming language tag to TESTed #583

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

Open
wants to merge 26 commits into
base: feat/add-natural-translation
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f9e118f
Added the possibility for using the programming_language key
BrentBlanckaert Mar 31, 2025
3836d62
Fixed some linting issues
BrentBlanckaert Mar 31, 2025
537f0e8
Made some changes
BrentBlanckaert Apr 3, 2025
b482816
Fixed merge conflict
BrentBlanckaert Apr 7, 2025
6675fa8
Fixed tests
BrentBlanckaert Apr 7, 2025
6f19925
Merge branch 'master' into feat/add-programming-language-tag
BrentBlanckaert Apr 7, 2025
23dafd3
Fixed dsl tests and added warning
BrentBlanckaert Apr 7, 2025
214c5ee
fix linting
BrentBlanckaert Apr 7, 2025
d98aa82
removed default
BrentBlanckaert Apr 10, 2025
a57d932
Merge branch 'feat/add-natural-translation' into feat/add-programming…
BrentBlanckaert Apr 14, 2025
202168b
added extra bit to the schema
BrentBlanckaert Apr 14, 2025
e35f474
Merge branch 'feat/add-natural-translation' into feat/add-programming…
BrentBlanckaert Apr 14, 2025
05f1e88
Merge branch 'feat/add-natural-translation' into feat/add-programming…
BrentBlanckaert Apr 15, 2025
051ba09
merged with main translator branch
BrentBlanckaert Apr 28, 2025
c4c2fe4
using messages instead of boolean in parser
BrentBlanckaert Apr 28, 2025
8d5f700
hotfix
BrentBlanckaert Apr 28, 2025
ffc1d3a
revert changes in tests
BrentBlanckaert Apr 28, 2025
c562b91
added the tests for programming_language tag in the parser
BrentBlanckaert Apr 28, 2025
71dfcc4
fix linting
BrentBlanckaert Apr 29, 2025
e9ba1ef
changed some of the names
BrentBlanckaert May 2, 2025
47df8a6
merge with main translation branch
BrentBlanckaert May 2, 2025
8be8e83
merged messages and made extra test
BrentBlanckaert May 2, 2025
0f2e397
Fixed crash
BrentBlanckaert May 2, 2025
d8b39eb
Use Data class instead of tuple
BrentBlanckaert May 9, 2025
544d4df
changed a few variable names + few small changes
BrentBlanckaert May 12, 2025
4e9b9bd
changed variable names
BrentBlanckaert May 12, 2025
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
1 change: 0 additions & 1 deletion tested/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"--translate",
type=str,
help="Specifies the language to translate translate the dsl to.",
default="-",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this change do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actualy a change that already should be in the other branch. This default will cause the translator to run when the option -t isn't even provided.

)
parser = parser.parse_args()

Expand Down
10 changes: 8 additions & 2 deletions tested/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class Bundle:
global_config: GlobalConfig
out: IO
preprocessor_messages: list[ExtendedMessage] = []
parser_messages: set[ExtendedMessage] = set()

@property
def config(self) -> DodonaConfig:
Expand Down Expand Up @@ -210,6 +211,7 @@ def create_bundle(
suite: Suite,
language: str | None = None,
preprocessor_messages: list[ExtendedMessage] | None = None,
parser_messages: set[ExtendedMessage] | None = None,
) -> Bundle:
"""
Create a configuration bundle.
Expand All @@ -219,8 +221,8 @@ def create_bundle(
:param suite: The test suite.
:param language: Optional programming language. If None, the one from the Dodona
configuration will be used.
:param preprocessor_messages: Indicator that the natural language translator
for the DSL key that was not defined in any translations map.
:param preprocessor_messages: Messages generated out of the preprocessor.
:param parser_messages: Messages generated out of the DSL-parser.

:return: The configuration bundle.
"""
Expand All @@ -240,9 +242,13 @@ def create_bundle(
if preprocessor_messages is None:
preprocessor_messages = []

if parser_messages is None:
parser_messages = set()

return Bundle(
language=lang_config,
global_config=global_config,
out=output,
preprocessor_messages=preprocessor_messages,
parser_messages=parser_messages,
)
2 changes: 1 addition & 1 deletion tested/descriptions/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _render_dsl_statements(self, element: block.FencedCode) -> str:
rendered_dsl = self.render_children(element)

# Parse the DSL
parsed_dsl = parse_dsl(rendered_dsl)
parsed_dsl, _ = parse_dsl(rendered_dsl)

# Get all actual tests
tests = []
Expand Down
2 changes: 1 addition & 1 deletion tested/dodona.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Permission(StrEnum):
ZEUS = auto()


@define
@define(frozen=True)
class ExtendedMessage:
description: str
format: str = "text"
Expand Down
11 changes: 11 additions & 0 deletions tested/dsl/dsl_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,14 @@ def build_preprocessor_messages(
)
for key in translations_missing_key
]


def build_deprecated_language_message() -> ExtendedMessage:
"""
Builds a message for not using the '!programming_language' tag in the DSL.
:return: The deprecation message.
"""
return ExtendedMessage(
f"WARNING: You are using YAML syntax to specify statements or expressions in multiple programming languages without the `!programming_language` tag. This usage is deprecated!",
permission=Permission.STAFF,
)
77 changes: 77 additions & 0 deletions tested/dsl/schema-strict-nat-translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,32 @@
"type" : "string",
"description" : "A language-specific literal, which will be used verbatim."
}
},
{
"type" : "object",
"required": [
"__tag__",
"value"
],
"properties" : {
"__tag__": {
"type" : "string",
"description" : "The tag used in the yaml",
"const": "!programming_language"
},
"value":{
"type": "object",
"description" : "Programming-language-specific statement or expression.",
"minProperties" : 1,
"propertyNames" : {
"$ref" : "#/definitions/programmingLanguage"
},
"items" : {
"type" : "string",
"description" : "A language-specific literal, which will be used verbatim."
}
}
}
}
]
},
Expand Down Expand Up @@ -1313,6 +1339,57 @@
]
}
},
{
"type" : "object",
"required": [
"__tag__",
"value"
],
"properties" : {
"__tag__": {
"type" : "string",
"description" : "The tag used in the yaml",
"const": "!programming_language"
},
"value":{
"type": "object",
"description" : "Programming-language-specific statement or expression.",
"minProperties" : 1,
"propertyNames" : {
"$ref" : "#/definitions/programmingLanguage"
},
"items" : {
"oneOf" : [
{
"type" : "string",
"description" : "A language-specific literal, which will be used verbatim."
},
{
"type" : "object",
"required": [
"__tag__",
"value"
],
"properties" : {
"__tag__": {
"type" : "string",
"description" : "The tag used in the yaml",
"const": "!natural_language"
},
"value":{
"type": "object",
"additionalProperties": {
"type" : "string",
"description" : "A language-specific literal, which will be used verbatim."
}
}
}
}
]
}
}
}
},
{
"type" : "object",
"required": [
Expand Down
11 changes: 10 additions & 1 deletion tested/dsl/schema-strict.json
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,14 @@
},
{
"description" : "Programming-language-specific statement or expression.",
"anyOf": [
{
"type": "object"
},
{
"type": "programming_language"
}
],
"type" : "object",
"minProperties" : 1,
"propertyNames" : {
Expand Down Expand Up @@ -873,7 +881,8 @@
"not" : {
"type" : [
"oracle",
"expression"
"expression",
"programming_language"
]
}
},
Expand Down
Loading