Skip to content

Commit

Permalink
Fix release test pipeline (#962)
Browse files Browse the repository at this point in the history
* notebook file path update

* move symlink for prototype_evals.ipynb

* path for moved symlink

* add missed file to index

* simplify combine nb to docs testing script

* update combine nb script

* add ipytree to requirements.txt

* Update requirements.txt

* Update requirements.optional.txt

* Update requirements.optional.txt

* Update requirements.optional.txt

* remove py files

* remove extra files
  • Loading branch information
joshreini1 authored Mar 6, 2024
1 parent 6dfd13d commit 491bb10
Show file tree
Hide file tree
Showing 15 changed files with 1,269 additions and 4,326 deletions.
72 changes: 26 additions & 46 deletions .github/workflows/combine_nb_to_docs_testing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ rm -rf all_tools.ipynb
# IF MOVING ANY IPYNB, MAKE SURE TO RE-SYMLINK. MANY IPYNB REFERENCED HERE LIVE
# IN OTHER PATHS
ALL_NOTEBOOKS=(
langchain_quickstart.ipynb
llama_index_quickstart.ipynb
quickstart.ipynb
prototype_evals.ipynb
human_feedback.ipynb
groundtruth_evals.ipynb
logging.ipynb
custom_feedback_functions.ipynb
./getting_started/quickstarts/langchain_quickstart.ipynb
./getting_started/quickstarts/llama_index_quickstart.ipynb
./getting_started/quickstarts/quickstart.ipynb
./getting_started/quickstarts/prototype_evals.ipynb
./getting_started/quickstarts/human_feedback.ipynb
./getting_started/quickstarts/groundtruth_evals.ipynb
./tracking/logging/logging.ipynb
./evaluation/feedback_implementations/custom_feedback_functions.ipynb
)
echo "Merging notebooks to all_tools.ipynb: ${ALL_NOTEBOOKS[@]}"
nbmerge ${ALL_NOTEBOOKS[@]} --output all_tools.ipynb
Expand All @@ -28,51 +28,36 @@ printf "\n\n" >> break.md
cat gh_top_intro.md break.md ../trulens_explain/gh_top_intro.md > TOP_README.md

# Create non-jupyter scripts
OUT_DIR=./py_script_quickstarts
mkdir -p $OUT_DIR
NOTEBOOKS=(
quickstart.ipynb
langchain_quickstart.ipynb
llama_index_quickstart.ipynb
text2text_quickstart.ipynb
all_tools.ipynb
)

OUT_DIR=./getting_started/quickstarts/
if [ -f "all_tools.ipynb" ]; then
echo "converting notebook all_tools.ipynb to script"
jupyter nbconvert --to script --output-dir $OUT_DIR all_tools.ipynb
fi
# gnu sed/gsed needed on mac:
SED=`which -a gsed sed | head -n1`
echo "sed=$SED"

# Fix nbmerge ids field invalid for ipynb
$SED -i -e '/\"id\":/d' all_tools.ipynb

for NOTEBOOK in ${NOTEBOOKS[@]}
do
echo "converting notebook $NOTEBOOK to script"
jupyter nbconvert --to script --output-dir $OUT_DIR $NOTEBOOK
done
if [ -f "all_tools.ipynb" ]; then
echo "converting notebook all_tools.ipynb to script"
jupyter nbconvert --to script --output-dir $OUT_DIR all_tools.ipynb
fi

PY_FILES=(
$OUT_DIR/quickstart.py
$OUT_DIR/langchain_quickstart.py
$OUT_DIR/llama_index_quickstart.py
$OUT_DIR/text2text_quickstart.py
$OUT_DIR/all_tools.py
)
for FILE in ${PY_FILES[@]}
do
echo "fixing $FILE"
if [ -f "all_tools.py" ]; then
echo "fixing all_tools.py"
## Remove ipynb JSON calls
$SED'' -i -e "/JSON/d" $FILE
$SED'' -i -e "/JSON/d" all_tools.py
## Replace jupyter display with python print
$SED'' -i -e "s/display/print/g" $FILE
$SED'' -i -e "s/display/print/g" all_tools.py
## Remove cell metadata
$SED'' -i -e "/\# In\[/d" $FILE
$SED'' -i -e "/\# In\[/d" all_tools.py
## Remove single # lines
$SED'' -i -e "/\#$/d" $FILE
$SED'' -i -e "/\#$/d" all_tools.py
## Collapse multiple empty line from sed replacements with a single line
$SED'' -i -e "/./b" -e ":n" -e "N;s/\\n$//;tn" $FILE
done

$SED'' -i -e "/./b" -e ":n" -e "N;s/\\n$//;tn" all_tools.py
fi
# Move generated files to their end locations

# EVERYTHING BELOW IS LINKED TO DOCUMENTATION OR TESTS; MAKE SURE YOU UPDATE
Expand All @@ -82,10 +67,5 @@ done
mv README.md ../../trulens_eval/README.md
mv TOP_README.md ../../README.md

# Links are referenced in intro.md and gh_intro.md
# There are symlinks from ../../trulens_eval/generated_files/ to these scripts for testing
mkdir -p ../../trulens_eval/examples/quickstart/py_script_quickstarts/
mv ./py_script_quickstarts/*.py ../../trulens_eval/examples/quickstart/py_script_quickstarts/

# Trulens tests run off of these files
mv all_tools* ../../trulens_eval/generated_files/
mv ./getting_started/quickstarts/all_tools* ../../trulens_eval/generated_files/
1 change: 1 addition & 0 deletions docs/trulens_eval/getting_started/quickstarts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Quickstart notebooks in this section:
- trulens_eval/text2text_quickstart.ipynb
- trulens_eval/groundtruth_evals.ipynb
- trulens_eval/human_feedback.ipynb
- trulens_eval/prototype_evals.ipynb
1 change: 0 additions & 1 deletion docs/trulens_eval/prototype_evals.ipynb

This file was deleted.

Loading

0 comments on commit 491bb10

Please sign in to comment.