Skip to content

Commit

Permalink
Merge pull request #788 from chrispyles/fix-778
Browse files Browse the repository at this point in the history
Add exclude_conda_defaults to otter assign and otter generate
  • Loading branch information
chrispyles committed Mar 9, 2024
2 parents afa146d + 2d23e62 commit ea762ea
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 86 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Suppress all warnings when running `otter.check.validate_export` as a module per [#735](https://github.com/ucbds-infra/otter-grader/issues/735)
* Updated default version of `ottr` to v1.5.0
* Added a way to exclude Conda's defaults channel from autograder `environment.yml` files in Otter Assign and Otter Generate per [#778](https://github.com/ucbds-infra/otter-grader/issues/778)

**v5.4.1:**

Expand Down
161 changes: 83 additions & 78 deletions otter/assign/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,213 +19,218 @@ class Assignment(fica.Config, Loggable):
"""

name: Optional[str] = fica.Key(
description="a name for the assignment (to validate that students submit to the correct " \
description = "a name for the assignment (to validate that students submit to the correct " \
"autograder)",
default=None,
default = None,
)

config_file: Optional[str] = fica.Key(
description="path to a file containing assignment configurations; any configurations in " \
description = "path to a file containing assignment configurations; any configurations in " \
"this file are overridden by the in-notebook config",
default=None,
default = None,
)

requirements: Optional[str] = fica.Key(
description="the path to a requirements.txt file or a list of packages",
default=None,
description = "the path to a requirements.txt file or a list of packages",
default = None,
)

overwrite_requirements: bool = fica.Key(
description="whether to overwrite Otter's default requirement.txt in Otter Generate",
default=False,
description = "whether to overwrite Otter's default requirement.txt in Otter Generate",
default = False,
)

environment: Optional[str] = fica.Key(
description="the path to a conda environment.yml file",
default=None,
description = "the path to a conda environment.yml file",
default = None,
)

run_tests: bool = fica.Key(
description="whether to run the assignment tests against the autograder notebook",
default=True,
description = "whether to run the assignment tests against the autograder notebook",
default = True,
)

solutions_pdf: bool = fica.Key(
description="whether to generate a PDF of the solutions notebook",
default=False,
description = "whether to generate a PDF of the solutions notebook",
default = False,
)

template_pdf: bool = fica.Key(
description="whether to generate a filtered Gradescope assignment template PDF",
default=False,
description = "whether to generate a filtered Gradescope assignment template PDF",
default = False,
)

init_cell: bool = fica.Key(
description="whether to include an Otter initialization cell in the output notebooks",
default=True,
description = "whether to include an Otter initialization cell in the output notebooks",
default = True,
)

check_all_cell: bool = fica.Key(
description="whether to include an Otter check-all cell in the output notebooks",
default=False,
description = "whether to include an Otter check-all cell in the output notebooks",
default = False,
)

class ExportCellValue(fica.Config):

instructions: str = fica.Key(
description="additional submission instructions to include in the export cell",
default="",
description = "additional submission instructions to include in the export cell",
default = "",
)

pdf: bool = fica.Key(
description="whether to include a PDF of the notebook in the generated zip file",
default=True,
description = "whether to include a PDF of the notebook in the generated zip file",
default = True,
)

filtering: bool = fica.Key(
description="whether the generated PDF should be filtered",
default=True,
description = "whether the generated PDF should be filtered",
default = True,
)

force_save: bool = fica.Key(
description="whether to force-save the notebook with JavaScript (only works in " \
description = "whether to force-save the notebook with JavaScript (only works in " \
"classic notebook)",
default=False,
default = False,
)

run_tests: bool = fica.Key(
description="whether to run student submissions against local tests during export",
default=True,
description = "whether to run student submissions against local tests during export",
default = True,
)

files: list = fica.Key(
description="a list of other files to include in the student submissions' zip file",
default=[],
description = "a list of other files to include in the student submissions' zip file",
default = [],
)

class RequireNoPDFAckValue(fica.Config):

message: str = fica.Key(
description="a message to show to students if a PDF is meant to be included in " \
description = "a message to show to students if a PDF is meant to be included in " \
"the submission but cannot be generated",
)

require_no_pdf_ack: Union[bool, RequireNoPDFAckValue] = fica.Key(
description="whether to require students to acknowledge that a PDF could not be " \
description = "whether to require students to acknowledge that a PDF could not be " \
"created if one is meant to be included in the submission zip file",
default=False,
subkey_container=RequireNoPDFAckValue,
default = False,
subkey_container = RequireNoPDFAckValue,
)

export_cell: ExportCellValue = fica.Key(
description="whether to include an Otter export cell in the output notebooks",
subkey_container=ExportCellValue,
description = "whether to include an Otter export cell in the output notebooks",
subkey_container = ExportCellValue,
)

class SeedValue(fica.Config):

variable: Optional[str] = fica.Key(
description="a variable name to override with the autograder seed during grading",
default=None,
description = "a variable name to override with the autograder seed during grading",
default = None,
)

autograder_value: Optional[int] = fica.Key(
description="the value of the autograder seed",
default=None,
description = "the value of the autograder seed",
default = None,
)

student_value: Optional[int] = fica.Key(
description="the value of the student seed",
default=None,
description = "the value of the student seed",
default = None,
)

seed: SeedValue = fica.Key(
description="intercell seeding configurations",
default=None,
subkey_container=SeedValue,
description = "intercell seeding configurations",
default = None,
subkey_container = SeedValue,
)

generate: AutograderConfig = fica.Key(
description="grading configurations to be passed to Otter Generate as an " \
description = "grading configurations to be passed to Otter Generate as an " \
"otter_config.json",
subkey_container=AutograderConfig,
subkey_container = AutograderConfig,
)

save_environment: bool = fica.Key(
description="whether to save the student's environment in the log",
default=False,
description = "whether to save the student's environment in the log",
default = False,
)

variables: Optional[Dict[str, str]] = fica.Key(
description="a mapping of variable names to type strings for serializing environments",
default=None,
description = "a mapping of variable names to type strings for serializing environments",
default = None,
)

ignore_modules: List[str] = fica.Key(
description="a list of modules to ignore variables from during environment serialization",
default=[],
description = "a list of modules to ignore variables from during environment serialization",
default = [],
)

files: List[str] = fica.Key(
description="a list of other files to include in the output directories and autograder",
default=[],
description = "a list of other files to include in the output directories and autograder",
default = [],
)

autograder_files: List[str] = fica.Key(
description="a list of other files only to include in the autograder",
default=[],
description = "a list of other files only to include in the autograder",
default = [],
)

plugins: List[str] = fica.Key(
description="a list of plugin names and configurations",
default=[],
description = "a list of plugin names and configurations",
default = [],
)

class TestsValue(fica.Config):

files: bool = fica.Key(
description="whether to store tests in separate files, instead of the notebook " \
description = "whether to store tests in separate files, instead of the notebook " \
"metadata",
default=False,
default = False,
)

ok_format: bool = fica.Key(
description="whether the test cases are in OK-format (instead of the exception-based " \
description = "whether the test cases are in OK-format (instead of the exception-based " \
"format)",
default=True,
default = True,
)

url_prefix: Optional[str] = fica.Key(
description="a URL prefix for where test files can be found for student use",
default=None,
description = "a URL prefix for where test files can be found for student use",
default = None,
)

tests: TestsValue = fica.Key(
description="information about the structure and storage of tests",
subkey_container=TestsValue,
enforce_subkeys=True,
description = "information about the structure and storage of tests",
subkey_container = TestsValue,
enforce_subkeys = True,
)

show_question_points: bool = fica.Key(
description="whether to add the question point values to the last cell of each question",
default=False,
description = "whether to add the question point values to the last cell of each question",
default = False,
)

runs_on: str = fica.Key(
description= "the interpreter this notebook will be run on if different from the " \
"default interpreter (one of {'default', 'colab', 'jupyterlite'})",
default="default",
validator=fica.validators.choice(["default", "colab", "jupyterlite"])
default = "default",
validator = fica.validators.choice(["default", "colab", "jupyterlite"])
)

python_version: Optional[Union[str, int, float]] = fica.Key(
description="the version of Python to use in the grading image (must be 3.6+)",
default=None,
description = "the version of Python to use in the grading image (must be 3.6+)",
default = None,
)

channel_priority_strict: bool = fica.Key(
description="whether to set conda's channel_priority config to strict in the setup.sh file",
default=True,
description = "whether to set conda's channel_priority config to strict in the setup.sh file",
default = True,
)

exclude_conda_defaults: bool = fica.Key(
description = "whether to exclude conda's defaults channel in the generated environment.yml file",
default = False,
)

lang: Optional[str] = None
Expand Down
1 change: 1 addition & 0 deletions otter/assign/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def run_generate_autograder(
assignment = assignment,
python_version = assignment.get_python_version(),
channel_priority_strict = assignment.channel_priority_strict,
exclude_conda_defaults = assignment.exclude_conda_defaults,
)

# clean up temp tests dir
Expand Down
1 change: 1 addition & 0 deletions otter/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def export_cli(*args, **kwargs):
@click.option("--token", help="Gradescope token for uploading PDFs")
@click.option("--python-version", help="Python version to use in the grading image")
@click.option("--channel-priority-strict", is_flag=True, help="Whether to set conda's channel_priority to strict in the setup.sh file")
@click.option("--exclude-conda-defaults", is_flag=True, help="Whether to exlucde conda's defaults channel from the environment.yml file")
@click.argument("files", nargs=-1)
def generate_cli(*args, **kwargs):
"""
Expand Down

0 comments on commit ea762ea

Please sign in to comment.