Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

run_and_convert_notebook.sh 1.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  1. #!/bin/bash
  2. # Script to run and convert a single notebook
  3. NOTEBOOK_PATH="$1"
  4. ENV_NAME="$2" # Second argument is the environment name
  5. OUTPUT_DIR="documentation/source/"
  6. echo "processing $NOTEBOOK_PATH"
  7. # Check if the notebook path is empty
  8. if [ -z "$NOTEBOOK_PATH" ]; then
  9. echo "No notebook path provided."
  10. exit 0 # Exit successfully as there's nothing to do
  11. fi
  12. # Check if the notebook file exists
  13. if [ ! -f "$NOTEBOOK_PATH" ]; then
  14. echo "Notebook path does not exist: $NOTEBOOK_PATH"
  15. exit 1 # Exit with an error as the notebook path is invalid
  16. fi
  17. # Ensure the virtual environment is activated
  18. source "${ENV_NAME}/bin/activate"
  19. # Convert the notebook
  20. # An --stdout flag is used to print the output to the console (Helpful for debugging if notebook conversion fails)
  21. jupyter nbconvert --to markdown --execute --output-dir="$OUTPUT_DIR" "$NOTEBOOK_PATH" --stdout --ExecutePreprocessor.kernel_name="$ENV_NAME"
  22. # Check for errors
  23. if [ $? -ne 0 ]; then
  24. echo "Error processing $NOTEBOOK_PATH"
  25. exit 1
  26. fi
  27. echo "$NOTEBOOK_PATH processed successfully."
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...