Compare commits

...
Author SHA1 Message Date
Andrew Ferlitsch 965c31de42 fix: argument handling improvements 2022-09-27 20:04:50 +00:00
+27 -7
View File
@@ -9,10 +9,12 @@ parser.add_argument('--notebook-dir', dest='notebook_dir',
default=None, type=str, help='Notebook directory')
parser.add_argument('--notebook', dest='notebook',
default=None, type=str, help='Notebook to review')
parser.add_argument('--errors', dest='errors',
default=False, type=bool, help='Report errors')
parser.add_argument('--errors-csv', dest='errors_csv',
default=False, type=bool, help='Report errors as CSV')
parser.add_argument('--notebook-file', dest='notebook_file',
default=None, type=str, help='File with list of notebooks to review')
parser.add_argument('--errors', dest='errors', action='store_true',
default=False, help='Report errors')
parser.add_argument('--errors-csv', dest='errors_csv', action='store_true',
default=False, help='Report errors as CSV')
parser.add_argument('--errors-codes', dest='errors_codes',
default=None, type=str, help='Report only specified errors')
parser.add_argument('--desc', dest='desc',
@@ -67,6 +69,7 @@ def parse_notebook(path):
# cell 2 is title and links
if not cell['source'][0].startswith('# '):
report_error(path, 1, "title cell must start with H1 heading")
title = ''
else:
title = cell['source'][0][2:].strip()
check_sentence_case(path, title)
@@ -287,7 +290,10 @@ def check_text_cell(path, cell):
'Vertex Private Endpoint': 'Vertex AI Private Endpoint',
'Tensorflow': 'TensorFlow',
'Tensorboard': 'TensorBoard',
'Google Cloud Notebooks': 'Vertex AI Workbench Notebooks'
'Google Cloud Notebooks': 'Vertex AI Workbench Notebooks',
'Bigquery': 'BigQuery',
'Pytorch': 'PyTorch',
'Sklearn': 'scikit-learn'
}
for line in cell['source']:
@@ -417,6 +423,20 @@ elif args.notebook:
print("Error: not a notebook:", args.notebook)
exit(1)
parse_notebook(args.notebook)
elif args.notebook_file:
if not os.path.isfile(args.notebook_file):
print("Error: file does not exist", args.notebook_file)
else:
with open(args.notebook_file, 'r') as f:
notebooks = f.readlines()
for notebook in notebooks:
notebook = notebook.strip()
if not os.path.isfile(notebook):
print("Error: notebook does not exist", notebook)
else:
parse_notebook(notebook)
else:
print("Error: must specify a directory or notebook")
exit(1)
print("Error: must specify a directory or notebook")
exit(1)