Skip to content
Snippets Groups Projects
Commit f3b13fa1 authored by Kwangjin Lee's avatar Kwangjin Lee
Browse files

fix the error

parent 58bf7fa4
No related branches found
No related tags found
No related merge requests found
Pipeline #261162 passed
......@@ -45,6 +45,9 @@ sync_notebooks:
# Create a manifest of all notebooks in content directory
- find ./content -name "*.ipynb" > notebooks_manifest.txt
# Create an error log file
- touch conversion_errors.log
- found_files=false
- |
while IFS= read -r notebook || [ -n "$notebook" ]; do
......@@ -55,24 +58,50 @@ sync_notebooks:
synced_dir="synced_files/$(dirname $relative_path)"
mkdir -p "$synced_dir"
jupytext --to notebook "$notebook" -o "${synced_dir}/$(basename ${notebook%.ipynb}).ipynb"
jupytext --to markdown "$notebook" -o "${synced_dir}/$(basename ${notebook%.ipynb}).md"
jupytext --to py:percent "$notebook" -o "${synced_dir}/$(basename ${notebook%.ipynb}).py"
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --to notebook --inplace "${synced_dir}/$(basename $notebook)"
# Validate notebook JSON structure
if python -c "import json; json.load(open('$notebook'));" 2>/dev/null; then
# Try conversion with error handling
if jupytext --to notebook "$notebook" -o "${synced_dir}/$(basename ${notebook%.ipynb}).ipynb" 2>>conversion_errors.log && \
jupytext --to markdown "$notebook" -o "${synced_dir}/$(basename ${notebook%.ipynb}).md" 2>>conversion_errors.log && \
jupytext --to py:percent "$notebook" -o "${synced_dir}/$(basename ${notebook%.ipynb}).py" 2>>conversion_errors.log; then
jupyter nbconvert --ClearOutputPreprocessor.enabled=True --to notebook --inplace "${synced_dir}/$(basename $notebook)" 2>>conversion_errors.log
echo "Successfully processed $notebook" >> conversion_errors.log
else
echo "Error processing $notebook - See conversion_errors.log for details" >&2
echo "Failed to convert $notebook" >> conversion_errors.log
fi
else
echo "Invalid or corrupted notebook: $notebook" >> conversion_errors.log
echo "Skipping invalid notebook: $notebook" >&2
fi
fi
done < notebooks_manifest.txt
if [ "$found_files" = false ]; then
echo "No notebooks found in content directory"
echo "No notebooks found in content directory" >> conversion_errors.log
fi
# Check if there were any conversion errors but some files were processed
if [ -s conversion_errors.log ] && [ -d "synced_files" ] && [ "$(ls -A synced_files)" ]; then
echo "Some files had conversion errors but others were processed successfully"
cat conversion_errors.log
exit 0
elif [ ! -d "synced_files" ] || [ ! "$(ls -A synced_files)" ]; then
echo "No files were successfully processed"
cat conversion_errors.log
exit 1
fi
artifacts:
paths:
- synced_files/
- notebooks_manifest.txt
- conversion_errors.log
expire_in: 1 hour
when: on_success
reports:
junit: conversion_errors.log
update_repo:
stage: update_repo
......@@ -117,6 +146,8 @@ update_repo:
exit 1
fi
# Deploy stages remain unchanged
deploy-draft-students:
stage: deploy
extends: .setup_env
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment