Content text lab0-0.pdf
CS236299 Lab 0-0: Environment Setup May 2, 2023 [ ]: # Initialize Otter import otter grader = otter.Notebook() [1]: # Please do not change this cell because some hidden tests might depend on it. import os # Otter grader does not handle ! commands well, so we define and use our # own function to execute shell commands. def shell(commands, warn=True): """Executes the string `commands` as a sequence of shell commands. Prints the result to stdout and returns the exit status. Provides a printed warning on non-zero exit status unless `warn` flag is unset. """ file = os.popen(commands) print (file.read().rstrip('\n')) exit_status = file.close() if warn and exit_status != None: print(f"Completed with errors. Exit status: {exit_status}\n") return exit_status shell(""" ls requirements.txt >/dev/null 2>&1 if [ ! $? = 0 ]; then rm -rf .tmp git clone https://github.com/cs236299-2023-spring/lab0-0.git .tmp mv .tmp/tests ./ mv .tmp/requirements.txt ./ rm -rf .tmp fi pip install -q -r requirements.txt """) 1
[notice] A new release of pip is available: 23.0 -> 23.1.2 [notice] To update, run: python3.8 -m pip install --upgrade pip 1 Course 236299 1.1 Lab 0-0 – Environment setup The goal of this lab is to make sure that you have properly setup your environment following the instructions at https://github.com/nlp-236299/data/tree/master/requirements. If you encounter any issues, don’t hesitate to ask in the course piazza. [2]: import otter import torch import nltk import dateparser import cryptography import mysql.connector import datasets import tokenizers import transformers import wget 1.2 Version Check Fill in the missing code in the below cell, and test your solution by running the grader.check(“version_check”) function two cells below. There’s also a cell at the end of the notebook to run all of the unit tests. [3]: #TODO - define `otter_version` to be otter.__version__. otter_version = otter.__version__ # SOLUTION [ ]: grader.check("version_check") 1.3 Shell Command Run the grader.check(“shell_cmd”) function below to make sure that shell() function works for you. [6]: #TODO - define `cmd` to be 'echo "abc"'. cmd = 'echo "abc"' # SOLUTION [ ]: grader.check("shell_cmd") 2
1.4 Submission Instructions This lab should be submitted to Gradescope at https://rebrand.ly/lab0-0-submit, which will be made available some time before the due date. Make sure that you have passed all public tests by running grader.check_all() below before submitting. Note that there will be hidden tests that are different from the public tests in future labs. In the following labs and problem sets, you’ll use this environment to solve real problems. 2 End of lab 0 To double-check your work, the cell below will rerun all of the autograder tests. [ ]: grader.check_all() 3