quickscope.server package¶
Submodules¶
quickscope.server.bundle module¶
-
quickscope.server.bundle.
copy_testrunner
(bundle_directory)¶ PythonEngine specific. Copies the testrunner.py testing utility package from ../templates into the included directory in the bundle.
- Parameters
bundle_directory (
Path
) – the temporary directory where the bundle is being created- Return type
None
-
quickscope.server.bundle.
get_chalkbox
(version, bundle_directory)¶ Procures the specified version of ChalkBox from GitHub releases.
- Parameters
version (
str
) – the version of ChalkBox to get (e.g. v0.2.0)bundle_directory (
Path
) – the path to the temporary directory in which the bundle is constructed
- Return type
Path
- Returns
the path to the ChalkBox JAR in the temporary bundle directory.
-
quickscope.server.bundle.
get_dependencies
(dependency_directory)¶ Creates a list of dependencies based on the contents of the dependency directory.
- Parameters
dependency_directory (
Path
) – where the dependencies uploaded by the user are stored- Return type
List
[str
]- Returns
a list of the dependencies’ paths (including the dependency directory)
-
quickscope.server.bundle.
produce_bundle
(config)¶ Performs bundle construction from the various elements based on the Engine and configuration specified.
- Parameters
config (
Dict
[str
,Any
]) – the configuration dictionary as prepared by .templates.populate_config- Return type
str
- Returns
the path to the zipped bundle as a string
-
quickscope.server.bundle.
produce_config_file
(form, bundle_directory)¶ Takes the form from the React front-end and uses it, in combination with the engine default settings, to populate the configuration and write it to the config.yaml file in the bundle directory.
- Parameters
form (
Dict
[str
,Any
]) – the immutable form dictionary from the request object populated by the React front-endbundle_directory (
Path
) – the temporary directory where the bundle is being created
- Return type
None
-
quickscope.server.bundle.
produce_included_directory
(source, bundle_directory)¶ PythonEngine specific. Copies the entire ‘included’ directory with its uploaded components into the root of the bundle.
- Parameters
source (
Path
) – the original location of the included directory as uploaded by the userbundle_directory (
Path
) – the temporary directory where the bundle is being created
- Return type
None
-
quickscope.server.bundle.
produce_lib_directory
(lib_directory, bundle_directory)¶ JavaEngine specific. Gathers the lib file containing JAR dependencies and copies it to the temporary bundle directory.
- Parameters
lib_directory (
Path
) – the lib directory with JAR dependencies uploaded by the userbundle_directory (
Path
) – the temporary directory where the bundle is being created
- Return type
None
-
quickscope.server.bundle.
produce_resources_directory
(resources_directory, bundle_directory)¶ JavaEngine specific. Gathers the static resources directory and files uploaded by the user and copies them to the temporary bundle directory.
- Parameters
resources_directory (
Path
) – the static resources directory populated by the user’s uploadsbundle_directory (
Path
) – the temporary directory where the bundle is being created
- Return type
None
-
quickscope.server.bundle.
produce_run_script
(run_call, bundle_directory=None)¶ Creates the run.sh script in the root of the bundle that is used by Gradescope to start the autograding process.
- Parameters
run_call (
str
) – typically the call to start ChalkBox with whatever arguments are requiredbundle_directory (
Optional
[Path
]) – the temporary directory where the bundle is being created
- Return type
None
-
quickscope.server.bundle.
produce_setup_script
(setup_calls, bundle_directory)¶ Creates the setup.sh script - required by Gradescope to prepare the Ubuntu environment - and places it in the bundle.
- Parameters
setup_calls (
str
) – the calls made to e.g. install packages, set the PATH etc. These come from .templates.pybundle_directory (
Path
) – the temporary directory where the bundle is being created
- Return type
None
-
quickscope.server.bundle.
produce_solution_directory
(solution_directory, bundle_directory)¶ Copies the solution directory uploaded by the user to the temporary bundle directory.
- Parameters
solution_directory (
Path
) – the directory containing the correct and faulty solutions uploaded by the userbundle_directory (
Path
) – the temporary directory where the bundle is being created
- Return type
None
-
quickscope.server.bundle.
reformat_test_classes
(config, session_directory)¶ JavaEngine specific. Transforms the assessable test classes listed in the config from Java import style (e.g. chalkbox.import.style) to path style (e.g. chalkbox/import/style.java).
- Parameters
config (
Dict
[str
,Any
]) – the config dictionary containing the test classes to updatesession_directory (
Path
) – the directory associated with the user’s session where the user’s uploads are stored
- Return type
None
quickscope.server.config module¶
quickscope.server.routes module¶
-
quickscope.server.routes.
generate
()¶ Generates the bundle based on the uploaded files and the configuration settings passed through in the form.
- Return type
Response
- Returns
a response that downloads the generated bundle to the client machine
-
quickscope.server.routes.
home
()¶ Serve the React front end bundle.
- Return type
str
- Returns
the rendered template of the React index.html page
-
quickscope.server.routes.
upload_locations
(component)¶ Uploads a file to the correct location in the appropriate state directory (based on the session id and the component type).
- Parameters
component (
str
) – the component of the bundle that is being uploaded, this will determine the subdirectory in the state directory based on the engine- Return type
Response
- Returns
a response object indicating success or failure
quickscope.server.run module¶
Utility class for running Quickscope
quickscope.server.templates module¶
-
quickscope.server.templates.
populate_config
(config, form, session_directory, locations)¶ Takes the user-provided configuration settings from the form and uses them to update the default values for the specified engine. User settings will override defaults.
- Parameters
config (
Dict
[str
,Any
]) – the basic settings common to all configurations: course code, assignment ID, engine, and session directoryform (
Any
) – the form (immutable dictionary) attached to the Flask request containing the user-specified settingssession_directory (
Path
) – the path to the directory associated with the user session matching the session ID created by the React front-endlocations (
Dict
[str
,str
]) – the mapping from required components to their respective location in the bundle (e.g. PYTHON_LOCATIONS or JAVA_LOCATIONS, above)
- Return type
Dict
[str
,Any
]- Returns
the compiled configuration dictionary
quickscope.server.utils module¶
-
quickscope.server.utils.
collapse_path_overlap
(clean_file, component, locations)¶ Removes the risk of creating duplicated folders in the state directory by checking if the clean_file has any directory overlap with the component location e.g. /solutions/correct/ and correct/a1.py would ensure that a1.py was put in /solutions/correct/a1.py and not /solutions/correct/correct/a1.py.
- Parameters
clean_file (
str
) – the uploaded file cleaned of any leading forward slashescomponent (
str
) – the particular component being uploadedlocations (
Dict
[str
,str
]) – the set of upload locations specific to the engine associated with the session
- Return type
str
- Returns
the collapsed path as a string
-
quickscope.server.utils.
deep_update
(original, updates)¶ Update a nested dictionary with new values, leaving unupdated values in place. Modifies original in place.
- Parameters
original (
Dict
) – the dictionary whose values will be updatedupdates (
Mapping
) – the dictionary with the values to you want to insert into original
- Return type
Dict
-
quickscope.server.utils.
make_session
(session_id)¶ Creates a session directory with the given session_id if it does not already exist.
- Parameters
session_id (
str
) – the session ID generated by the React front-end whenever the page is loaded or reloaded.- Return type
Path
- Returns
the path object corresponding to the session_id, which now must exist.
-
quickscope.server.utils.
reconstruct
(session_id, component, files, locations)¶ Finds the appropriate directory for uploaded file(s) and saves them there.
- Parameters
session_id (
str
) – the session ID provided by the React front endcomponent (
str
) – the type of component being uploaded (e.g. linter config file)files – the files from the Flask request
locations (
Dict
[str
,str
]) – the locations associated with the components that make up the engine selection
- Return type
None