Grader Convert#
Contents#
Main#
- class GraderConverter(**kwargs: Any)[source]#
- aliases: Dict[str, str] = {'file_pattern': 'ConverterApp.file_pattern', 'i': 'ConverterApp.input_directory', 'input_directory': 'ConverterApp.input_directory', 'log-level': 'Application.log_level', 'o': 'ConverterApp.output_directory', 'output_directory': 'ConverterApp.output_directory', 'p': 'ConverterApp.file_pattern'}#
the alias map for configurables Keys might strings or tuples for additional options; single-letter alias accessed like -v. Values might be like “Class.trait” strings of two-tuples: (Class.trait, help-text).
- description = 'Convert notebooks to different formats'#
- flags: Dict[str, Any] = {'debug': ({'Application': {'log_level': 'DEBUG'}}, 'set log level to DEBUG (maximize logging output)'), 'quiet': ({'Application': {'log_level': 'CRITICAL'}}, 'set log level to CRITICAL (minimize logging output)')}#
- name = 'grader-converter'#
- subcommands = {'autograde': (<class 'grader_convert.converters.autograde.AutogradeApp'>, 'Autograde submitted assignments. Intended for use by instructors\nonly.'), 'generate_assignment': (<class 'grader_convert.converters.generate_assignment.GenerateAssignmentApp'>, 'Create the student version of an assignment. Intended for use by\ninstructors only.'), 'generate_feedback': (<class 'grader_convert.converters.generate_feedback.GenerateFeedbackApp'>, 'Generate feedback (after autograding and manual grading).\nIntended for use by instructors only.'), 'generate_solution': (<class 'grader_convert.converters.generate_solution.GenerateSolutionApp'>, 'Generates the solution for the given assignment.'), 'update': (<class 'grader_convert.converters.updateapp.UpdateApp'>, 'Update nbgrader cell metadata to the most recent version.'), 'validate': (<class 'grader_convert.converters.validateapp.ValidateApp'>, 'Validate a notebook. Intended for use by instructors and students.')}#
- version = '0.1.2'#
Utils#
- capture_log(app, fmt='[%(levelname)s] %(message)s')[source]#
Adds an extra handler to the given application the logs to a string buffer, calls
app.start(), and returns the log output. The extra handler is removed from the application before returning.- Parameters
- app: LoggingConfigurable
An application, withh the .start() method implemented
- fmt: string
A format string for formatting log messages
- Returns
- A dictionary with the following keys (error and log may or may not be present):
success (bool): whether or not the operation completed successfully
error (string): formatted traceback
log (string): captured log output
- check_directory(path, read=False, write=False, execute=False)[source]#
Does that path exist and can the current user rwx.
- check_mode(path, read=False, write=False, execute=False)[source]#
Can the current user can rwx the path.
- determine_grade(cell: nbformat.notebooknode.NotebookNode, log: Optional[logging.Logger] = None) Tuple[Optional[float], float][source]#
- find_all_files(path: str, exclude: Optional[List[str]] = None) List[str][source]#
Recursively finds all filenames rooted at path, optionally excluding some based on filename globs.
- find_all_notebooks(path)[source]#
Return a sorted list of notebooks recursively found rooted at path.
- get_partial_grade(output, max_points, log=None)[source]#
Calculates partial grade for a cell, based on contents of output[“data”][“text/plain”]. Returns a value between 0 and max_points. Returns max_points (and a warning) for edge cases.
- ignore_patterns(exclude=None, include=None, max_file_size=None, log=None)[source]#
Function that can be used as
shutils.copytree()ignore parameter.This is a generalization of
shutils.ignore_patterns()that supports include globs, exclude globs, max file size, and logging.- Parameters
- exclude: list or None
A list of filename globs or None (the default)
- include: list or None
A list of filename globs or None (the default)
- max_file_size: int or float
The max file size, in kilobytes
- log: logging.Logger or None (the default)
- Returns
- A function taking a directory name and list of file/directory
- names and returning the list of file/directory names to be
- ignored.
- A file/directory is ignored as soon as it is either excluded, or
- not included explicitely, or too large.
- If a logger is provided, a warning is logged for files too large
- and a debug message for otherwise ignored files.
- is_grade(cell: nbformat.notebooknode.NotebookNode) bool[source]#
Returns True if the cell is a grade cell.
- is_ignored(filename: str, ignore_globs: Optional[List[str]] = None) bool[source]#
Determines whether a filename should be ignored, based on whether it matches any file glob in the given list. Note that this only matches on the base filename itself, not the full path.
- is_locked(cell: nbformat.notebooknode.NotebookNode) bool[source]#
Returns True if the cell source is locked (will be overwritten).
- is_solution(cell: nbformat.notebooknode.NotebookNode) bool[source]#
Returns True if the cell is a solution cell.
- is_task(cell: nbformat.notebooknode.NotebookNode) bool[source]#
Returns True if the cell is a task cell.
- parse_utc(ts: Union[datetime.datetime, str]) datetime.datetime[source]#
Parses a timestamp into datetime format, converting it to UTC if necessary.
- to_bytes(string: str) bytes[source]#
A helper function for converting a string to bytes with utf-8 encoding.
- unzip(src, dest, zip_ext=None, create_own_folder=False, tree=False)[source]#
Extract all content from an archive file to a destination folder.
- Parameters
- src: str
Absolute path to the archive file (‘/path/to/archive_filename.zip’)
- dest: str
Asolute path to extract all content to (‘/path/to/extract/’)
- zip_ext: list
Valid zip file extensions. Default: [‘.zip’, ‘.gz’]
- create_own_folder: bool
Create a sub-folder in ‘dest’ with the archive file name if True (‘/path/to/extract/archive_filename/’). Default: False
- tree: bool
Extract archive files within archive files (into their own sub-directory) if True. Default: False
Validator#
- class Validator(**kwargs: Any)[source]#
- changed_warning#
A trait for unicode strings.
- failed_warning#
A trait for unicode strings.
- ignore_checksums#
A boolean (True, False) trait.
- indent#
A trait for unicode strings.
- invert#
A boolean (True, False) trait.
- passed_warning#
A trait for unicode strings.
- preprocessors#
An instance of a Python list.
- stream = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>#
- type_changed_warning#
A trait for unicode strings.
- validate_all#
A boolean (True, False) trait.
- width#
An int trait.