feat: skip notebook option (#2411)

This commit is contained in:
Andrew Ferlitsch
2023-10-23 19:37:37 +00:00
committed by GitHub
parent e5bfc74c11
commit e5a50be51e
+19 -1
View File
@@ -6,6 +6,7 @@
--notebook: review the specified notebook
--notebook-dir: recursively traverse the directory and review each notebook enocuntered
--notebook-file: A CSV file with list of notebooks to review.
--skip-file: a CSV file with list of notebooks to skip.
# options for error handling
--errors: Report detected errors.
@@ -52,6 +53,8 @@ parser.add_argument('--notebook', dest='notebook',
default=None, type=str, help='Notebook to review')
parser.add_argument('--notebook-file', dest='notebook_file',
default=None, type=str, help='File with list of notebooks to review')
parser.add_argument('--skip-file', dest='skip_file',
default=None, type=str, help='File with list of notebooks to skip')
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',
@@ -178,6 +181,7 @@ class FixCode(Enum):
# globals
last_tag = ''
skip_list = []
def parse_dir(directory: str) -> int:
@@ -186,7 +190,7 @@ def parse_dir(directory: str) -> int:
directory: The directory path.
Returns the numbern of errors
Returns the number of errors
"""
exit_code = 0
@@ -213,6 +217,8 @@ def parse_dir(directory: str) -> int:
continue
exit_code += parse_dir(entry.path)
elif entry.name.endswith('.ipynb'):
if entry.name in skip_list:
continue
tag = directory.split('/')[-1]
if tag == 'automl':
tag = 'AutoML'
@@ -1335,6 +1341,18 @@ if args.web:
print(' </tr>')
print(' </thead>')
print(' <tbody class="list">')
if args.skip_file:
if not os.path.isfile(args.skip_file):
print("Error: file does not exist", args.skip_file)
exit(1)
else:
with open(args.skip_file, 'r') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
notebook = row[0]
skip_list.append(notebook)
if args.notebook_dir:
if not os.path.isdir(args.notebook_dir):