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

Conversation

BrentBlanckaert
Copy link
Collaborator

@BrentBlanckaert BrentBlanckaert commented Mar 31, 2025

This builds of the PR #574. The goal is to add the tag !programming_language such that it is more consistent with the usage of the tag !natural_language.

@BrentBlanckaert BrentBlanckaert marked this pull request as draft March 31, 2025 11:40
@niknetniko niknetniko changed the base branch from master to feat/add-natural-translation March 31, 2025 21:03
@BrentBlanckaert BrentBlanckaert self-assigned this Apr 8, 2025
@BrentBlanckaert BrentBlanckaert added enhancement New feature or request dsl labels Apr 8, 2025
@BrentBlanckaert BrentBlanckaert marked this pull request as ready for review April 15, 2025 15:30
Copy link
Contributor

@jorg-vr jorg-vr left a comment

Choose a reason for hiding this comment

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

Please add tests:

  • old format still works but adds a deprecation warning
  • new format works
  • the deprecation warning is only added once

@@ -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.

messages.append(
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,
Copy link
Contributor

Choose a reason for hiding this comment

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

@bmesuere, this gave me the idea that we might need to add a Permission.CREATOR or something like that in the future. Some messages just aren't very actionable for teachers using exercises that are not their own.

We might also want to mark exercises with unresolved warnings/errors in dodona and create a page to review these for content creators

@@ -102,3 +102,24 @@ def build_preprocessor_messages(
)
for key in translations_missing_key
]


def build_translate_parser_messages(
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't take a boolean argument here, nor would I return a list, as it is a single message
And rename it to build_deprecated_language_message or something like that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wrote it like this such that this function can easily be expanded when extra deprecation warnings pop-up about using file instead output_files.

# TODO: In the PR of adding file usage to the DSL, other deprecation warnings were added during parsing.
# So I think it's a nice split to have messages from parser and from the preprocessor.
collector.add_messages(
build_translate_parser_messages(bundle.suite.using_deprecated_prog_languages)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as in the natural_languages pr, this method won't be needed here if we had bundle.parser_messages

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've resolved all the other notes because it boils down to this. I changed the usage of booleans to an actual list of ExtendedMessages

@BrentBlanckaert BrentBlanckaert requested a review from jorg-vr April 29, 2025 16:22
@BrentBlanckaert BrentBlanckaert requested a review from jorg-vr May 9, 2025 15:08
Copy link
Contributor

@jorg-vr jorg-vr left a comment

Choose a reason for hiding this comment

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

Looks good, left some mostly minor nitpicks



def parse_dsl(dsl_string: str) -> Suite:
def parse_dsl(dsl_string: str) -> DataWithMessage[Suite]:
Copy link
Contributor

Choose a reason for hiding this comment

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

This returns DataWithMessage, but in practice all messages are just ignored. Do we need this here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These messages are used in main.py.

Copy link
Contributor

Choose a reason for hiding this comment

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

These messages are not passed through

This method returns suite_to_json(suite_with_message.data)

suite_with_message.messages is completely ignored and never used

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

main.py uses parse_dsl and not translate_to_test_suite.

@BrentBlanckaert BrentBlanckaert requested a review from jorg-vr May 12, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dsl enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants