-
Notifications
You must be signed in to change notification settings - Fork 9
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
Conversation
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.
looks good, left some minor (non blocking) questions / comments inline though...
e2xgrader/apps/baseapp.py
Outdated
|
||
mode = Enum( | ||
values=["teacher", "student", "student_exam", "None"], | ||
default_value="None", |
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.
so E2xGrader can be active with "None"
?!?
from .showmodeapp import ShowModeApp | ||
from .togglemodeapp import ToggleModeApp | ||
|
||
__all__ = [ |
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.
how are these called from where? (maybe update docs?)
e2xgrader/apps/deactivatemodeapp.py
Outdated
super().start() | ||
if len(self.extra_args) != 0: | ||
self.fail("e2xgrader deactivate does not take any arguments.") | ||
self.mode = "None" |
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.
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(): |
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.
is this method called by some convention or a leftover?
|
||
class ToggleModeApp(E2xGrader): | ||
|
||
flags = { |
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.
isn't that inferred now?
config = get_nbextension_config() | ||
modes = ["teacher", "student_exam", "student"] | ||
is_active = dict(tree=[], notebook=[]) | ||
for mode in modes: |
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.
not sure what's happening here and why... could use a quick comment...
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.
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: | ||
{ |
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.
why twice? what's the diff between tree and notebook?
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.
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): |
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.
can we not just query the e2x extension? seems like a lot of looping
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.
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.
Quality Gate passedIssues Measures |
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.