Skip to content
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

Refactor e2xgrader apps #177

Merged
merged 36 commits into from
Mar 7, 2024
Merged

Refactor e2xgrader apps #177

merged 36 commits into from
Mar 7, 2024

Conversation

tmetzl
Copy link
Member

@tmetzl tmetzl commented Feb 26, 2024

Refactor e2xgrader applications to utilize JupyterApps.

The CLI functionality of e2xgrader has been transitioned into a JupyterApp. The current activation mode is determined through the infer_e2xgrader_mode function, which analyzes the current activation of nbextensions and serverextensions. This capability enables the identification of the current mode, facilitating adjustments to e2xgrader's behavior as needed.

@tmetzl tmetzl mentioned this pull request Feb 27, 2024
@joernhees joernhees assigned tmetzl and unassigned joernhees Feb 29, 2024
joernhees
joernhees previously approved these changes Feb 29, 2024
Copy link

@joernhees joernhees 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 minor (non blocking) questions / comments inline though...


mode = Enum(
values=["teacher", "student", "student_exam", "None"],
default_value="None",

Choose a reason for hiding this comment

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

so E2xGrader can be active with "None"?!?

from .showmodeapp import ShowModeApp
from .togglemodeapp import ToggleModeApp

__all__ = [

Choose a reason for hiding this comment

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

how are these called from where? (maybe update docs?)

super().start()
if len(self.extra_args) != 0:
self.fail("e2xgrader deactivate does not take any arguments.")
self.mode = "None"

Choose a reason for hiding this comment

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

maybe "Inactive" to avoid confusion with None?

print(
"No subcommand given (run with --help for options). List of subcommands:\n"
)
self.print_subcommands()


def main():

Choose a reason for hiding this comment

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

is this method called by some convention or a leftover?


class ToggleModeApp(E2xGrader):

flags = {

Choose a reason for hiding this comment

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

isn't that inferred now?

config = get_nbextension_config()
modes = ["teacher", "student_exam", "student"]
is_active = dict(tree=[], notebook=[])
for mode in modes:

Choose a reason for hiding this comment

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

not sure what's happening here and why... could use a quick comment...

Copy link
Member Author

Choose a reason for hiding this comment

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

We infer which extensions are active in the tree section and which in the notebook section. Then for each mode we check if the respective tree and notebook extensions are active. Finally we check if only the extensions for one mode are active and not the extensions for multiple modes.

Returns:
A dictionary containing the configuration for nbextensions.
The dictionary has the following structure:
{

Choose a reason for hiding this comment

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

why twice? what's the diff between tree and notebook?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because we have nbextensions that are visible in the tree view (File view, like how in student_exam mode the delete notebook UI is gone) and nbextensions that are visible in a notebook (Notebook view, like the cells). This is more for sanity checking that not only notebook or only tree extensions are active.

modes = ["teacher", "student_exam", "student"]
is_active = dict(tree=[], notebook=[])
for mode in modes:
for extension in discover_nbextensions(mode):

Choose a reason for hiding this comment

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

can we not just query the e2x extension? seems like a lot of looping

Copy link
Member Author

Choose a reason for hiding this comment

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

discover_nbextensions(mode) will give us the nbextensions that should be activated for a certain mode. We usually have two per mode, one tree extension and one notebook extension.

Copy link

sonarqubecloud bot commented Mar 1, 2024

@tmetzl tmetzl merged commit 31ccffb into main Mar 7, 2024
15 checks passed
@tmetzl tmetzl deleted the refactor_e2xgrader_apps branch March 15, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants