# TEST PIPELINE ##############################################################
- Internal use only
##############################################################################


# INSTALL ####################################################################
export VEDODIR=$HOME/Projects/vedo
export VEDOLOGFILE=$VEDODIR/output_vedo_test.txt

cd $VEDODIR
pip install -q -e .
pip install treelib
pip install colorcet
pip install scikit-image
pip install scikit-learn
pip install nevergrad -U
pip install pyefd -U
pip install iminuit -U
pip install meshio -U
pip install morphomatics -U
pip install pygeodesic -U
pip install pygmsh -U
pip install pymeshlab -U
pip install pymadcad -U
pip install pyshtools -U
pip install rtree
pip install trimesh -U
pip install -q trame==2.5.2
pip install qtpy
pip install magic-class -U
pip install tetgenpy -U
pip install gustaf -U
pip install fast-simplification -U
#pip install pyacvd -U
#pip install pymeshfix -U


# ENABLE/DISABLE DRY RUN ###########################################################
sed -i "s/dry_run_mode = 0/dry_run_mode = 2/g" $VEDODIR/vedo/settings.py  #->DISABLE
sed -i "s/dry_run_mode = 2/dry_run_mode = 0/g" $VEDODIR/vedo/settings.py  #->ENABLE
####################################################################################

pytest tests

cd $VEDODIR/tests/common && ./run_all.sh 
cd $VEDODIR/tests/issues && ./run_all.sh 
cd $VEDODIR/tests/snippets && ./run_all.sh 

# EXAMPLES ##########################################################################
cd $VEDODIR/examples && time ./run_all.sh 2>&1 | tee $VEDOLOGFILE && alert "scan done."

grep -aA 1 "Error" $VEDOLOGFILE
grep -aA 3 "Trace" $VEDOLOGFILE
grep -aA 3 "ailure" $VEDOLOGFILE
grep -aA 3 "invalid" $VEDOLOGFILE
code $VEDOLOGFILE  #### inspect logfile
# (Try normal run too with visualization to make sure all is ok)


# TUTORIALS ##################################################################
cd ~/Projects/server/vedo-embo-course/scripts && ./run_all.sh 
cd ~/Projects/server/vedo-bias-course/scripts && ./run_all.sh 
cd ~/Projects/server/vedo-epug-tutorial/scripts && ./run_all.sh 


# TRIMESH #####################################################################
cd $VEDODIR/examples/other/trimesh && ./run_all.sh

# DOLFIN #####################################################################
# conda create -n fenics -c conda-forge fenics
# conda activate fenics
# conda install conda-forge::mshr
cd $VEDODIR
conda activate fenics
pip install -qe .
cd $VEDODIR/examples/other/dolfin && ./run_all.sh
conda deactivate

# OTHERS #####################################################################
cd $VEDODIR
python ~/Dropbox/documents/Medical/RESONANCIA.py
vedo https://vedo.embl.es/examples/data/panther.stl.gz
vedo https://vedo.embl.es/examples/geo_scene.npz
vedo --convert data/290.vtk --to ply && vedo data/290.ply

# NOTEBOOKS ###################################################################
cd $VEDODIR/examples/notebooks/
jupyter notebook > /dev/null 2>&1
# test colab
https://colab.research.google.com/drive/

##########################
# Check on OSX and Windows


# VEDO PROJECTS ###############################################################
cd $VEDODIR
pip install .

cd ~/Projects/server/trackviewer
    ./main_test.py
################
cd ~/Projects/clonal_analysis/clone_viewer3
    ./clone_viewer_gio3d.py
################
cd ~/Projects/server/rio_organoid
    python main4.py
    python piv_read_fw2_C3.py
################
cd ~/Projects/server/cell_density
   analyse_density.py test_image.png test_image_gfp.png
   edu_histogram.py test_image.png
################
cd ~/Projects/new_yalla/limb_opti_here
   python result_viz3.py
################
cd ~/Projects/server/welsh_embryo_stager
   python stager.py pics/E14.5_L3-03_HL2.5X.jpg
################
cd ~/Projects/oocytes
   python step5.py
################
cd ~/Projects/umap_viewer3d
   python main6.py
################
cd ~/Projects/napari-vedo-bridge
    # conda create -y -n napari-env -c conda-forge python=3.9
    # conda activate napari-env
    # python -m pip install "napari[all]"
    conda activate napari-env
    cd $VEDODIR && pip install -q . && cd -
    pip install -e .
    python $VEDODIR/examples/other/napari1.py # then open plugins ...
    conda deactivate
################
cd ~/Projects/server/brainrender/examples
    python cell_density.py
    python streamlines.py
    python volumetric_data.py
################
cd ~/Projects/clonal_analysis
    python -m analysis_plots2d
    python tc_morph11_2d.py
################
cd ~/Projects/server/gustaf
    git pull
    pip install -e .
    cd examples
    python run_all_examples.py
################
cd ~/Projects/server/splinepy
    git pull
    pip install -e .
    cd examples
    python run_all_examples.py
################
cd ~/Projects/server/tetgenpy/examples
    python plc_to_tets.py
################
cd ~/Projects/4d-gene-reconstruction/useful_scripts
    python plc_to_tets.py
################
cd ~/Projects/abm_playground/
    python cell_sim.py

rm $VEDOLOGFILE


# DOCUMENTATION ###############################################################
# mount_staging
# pip install pdoc
cd $VEDODIR
pip install -qe .
cd $VEDODIR/docs/pdoc
./build_html.py 

# check web page examples
cd $VEDODIR
code docs/examples_db.js
cp docs/examples_db.js www/examples_db.js
code www/index.html


# RELEASE #####################################################################
cd $VEDODIR

# check version and status
code vedo/version.py
git status
git commit -am 'release'
git push

# (optionally) python -m pip install -U packaging
# upload to pypi (add in ~/.pypirc):
# [pypi]
# username = __token__
# password = your-pypi-token

rm -rf dist/
python -m build
python -m twine upload dist/*
# View at:
# https://pypi.org/project/vedo/

# make github release
cd $VEDODIR
code CHANGELOG.md
code vedo/version.py  # edit to add +dev0
https://repology.org/project/vedo/badges


# SITES ######################################################################
https://vedo.embl.es/
https://vedo.embl.es/docs
https://vedo.embl.es/fonts
https://github.com/marcomusy/vedo
https://forum.image.sc/search?q=vedo%20order%3Alatest


