Skip to content

Commit 71b3f7d

Browse files
committed
add allow-fail option to export script
1 parent 8ee8367 commit 71b3f7d

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

scripts/export.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,40 @@ def main():
5050
default=None,
5151
metavar="DIR"
5252
)
53+
parser.add_argument(
54+
"--allow-fail",
55+
action="store_true",
56+
help="Skip and continue if an export fails",
57+
)
5358

5459
args = parser.parse_args()
5560

5661
for filepath in args.filepaths:
5762

58-
# dir_path = Path(__file__).resolve().parent.parts
59-
fullpath = Path(filepath).resolve()
60-
61-
if Path(filepath).is_file():
62-
output_folder: Path = fullpath.parent if args.output_dir is None else Path(args.output_dir)
63-
print(f"Exporting notebook {filepath} to {output_folder}")
64-
export_notebook(Path(filepath), output_folder, args.skip)
65-
elif Path(filepath).is_dir():
66-
output_folder: Path = fullpath if args.output_dir is None else Path(args.output_dir)
67-
print(f"Exporting all notebooks in {filepath} to {output_folder}")
68-
export_all(Path(filepath), output_folder, args.skip)
69-
else:
70-
raise RuntimeError(f"{filepath} not found")
63+
try:
64+
# dir_path = Path(__file__).resolve().parent.parts
65+
fullpath = Path(filepath).resolve()
66+
67+
if Path(filepath).is_file():
68+
output_folder: Path = fullpath.parent if args.output_dir is None else Path(args.output_dir)
69+
print(f"Exporting notebook {filepath} to {output_folder}")
70+
export_notebook(Path(filepath), output_folder, args.skip)
71+
elif Path(filepath).is_dir():
72+
output_folder: Path = fullpath if args.output_dir is None else Path(args.output_dir)
73+
print(f"Exporting all notebooks in {filepath} to {output_folder}")
74+
export_all(Path(filepath), output_folder, args.skip)
75+
else:
76+
raise RuntimeError(f"{filepath} not found")
77+
except Exception as err:
78+
print(f"ERROR exporting {filepath}")
79+
if not args.allow_fail:
80+
raise
81+
7182

72-
# Print markdown list if requested
73-
if args.print_md_list:
74-
print("Markdown format list:")
75-
print_md_list(output_folder)
83+
# Print markdown list if requested
84+
if args.print_md_list:
85+
print(f"Markdown format list for {output_folder}:")
86+
print_md_list(output_folder)
7687

7788

7889
def export_all(filename: Path, output_folder: Path, skip: bool) -> None:

0 commit comments

Comments
 (0)