This PR introduces schemas for all algorithm 1 objects defined in the algorithm specification found here. That is, all the objects that make up Schedule and Professor. Note that there is an optional field in CourseSection, maxCapacity, that is not in the spec because it is used by our system but not the other company's. Our algorithms are backwards compatible.
Additionally, this PR implements three functions to validate dicts against these schemas:
validate_professor(professor) will validate a Professor dict
validate_professors(professors) will validate a list of Professor dicts
validate_schedule(schedule) will validate a Schedule dict
If the input is valid according to the spec, these functions will return True. If there is a spec violation, a SchemaError will be raised and the stack trace will include where the violation occurred in the input data.
A second parameter can be passed to all three validate functions called print_output, which is set to True by default.
If print_output is True and the input is valid, a message will be printed to the console.
This PR also adjusts the mock input data to include the maxCapacity field, set to None for all courses. I kept the old input for testing backwards compatibility.
There are two tests:
Test the scheduler output meets the spec when using the debug flag for both parameters
Test the scheduler output meets the spec when using the old schedule mock input (without maxCapacity) and the debug flag for professors
Note: This PR introduces a dependency (schema==0.7.5), so a requirements.txt file has been added and the setup.py script has been updated to require the package.
This PR introduces schemas for all algorithm 1 objects defined in the algorithm specification found here. That is, all the objects that make up Schedule and Professor. Note that there is an optional field in CourseSection,
maxCapacity
, that is not in the spec because it is used by our system but not the other company's. Our algorithms are backwards compatible.Additionally, this PR implements three functions to validate dicts against these schemas:
validate_professor(professor)
will validate a Professor dictvalidate_professors(professors)
will validate a list of Professor dictsvalidate_schedule(schedule)
will validate a Schedule dictIf the input is valid according to the spec, these functions will return
True
. If there is a spec violation, aSchemaError
will be raised and the stack trace will include where the violation occurred in the input data.A second parameter can be passed to all three validate functions called
print_output
, which is set toTrue
by default. Ifprint_output
isTrue
and the input is valid, a message will be printed to the console.This PR also adjusts the mock input data to include the
maxCapacity
field, set toNone
for all courses. I kept the old input for testing backwards compatibility.There are two tests:
maxCapacity
) and the debug flag for professorsNote: This PR introduces a dependency (
schema==0.7.5
), so a requirements.txt file has been added and the setup.py script has been updated to require the package.Completes #42