opengeos / whitebox-python

WhiteboxTools Python Frontend

Home Page:https://pypi.org/project/whitebox/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using previous versions of WhiteboxTools

rickedanielson opened this issue · comments

  • whitebox version: 1.5.0
  • Python version: 3.6.10
  • Operating System: Ubuntu 20.04

Description

I would like to use WhiteboxTools v1.5.0 in order to use

https://github.com/NCAR/wrf_hydro_gis_preprocessor

but unforuntately, I can't pin WhiteboxTools to v1.5.0, despite
being aware of issues like this:

https://stackoverflow.com/questions/67495221/conda-environment-has-access-to-system-modules-how-to-prevent

What I Did

My steps to reproduce on Ubuntu 20.04 are:

rm -rf ~/miniconda3 ~/.condarc ~/.conda ~/.continuum
bash Miniconda3-py38_4.12.0-Linux-x86_64.sh
conda init
conda config --add channels conda-forge
conda create -n wrfh_gis_env -c conda-forge python=3.6 gdal netCDF4 numpy pyproj whitebox=1.5.0
conda activate wrfh_gis_env
(wrfh_gis_env) > python

from whitebox.whitebox_tools import WhiteboxTools
print(' Using {0}'.format(WhiteboxTools().version().split('\n')[0]))
Using WhiteboxTools v2.1.0 by Dr. John B. Lindsay (c) 2017-2021

Please note that outside of wrfh_gis_env, I do not have access
to WhiteboxTools v2.1.0:

python3.8

from whitebox.whitebox_tools import WhiteboxTools
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'whitebox'

Does anyone know how I might pin WhiteboxTools to v1.5.0?

PS - Even from inside wrfh_gis_env, it's still not clear where v2.1.0 comes from:

conda activate wrfh_gis_env
(wrfh_gis_env) > python

import whitebox as ; print(.path)
['/home/soft/miniconda3/envs/wrfh_gis_env/lib/python3.6/site-packages/whitebox']

conda deactivate
cd /home/soft/miniconda3/envs/wrfh_gis_env/lib/python3.6/site-packages/whitebox
ls -al

drwxrwxr-x 4 4096 Jun 28 15:54 WBT
-rw-rw-r-- 1 25866248 Jun 28 15:54 WhiteboxTools_linux_amd64.zip
-rw-rw-r-- 2 221 Jun 6 2021 init.py
drwxrwxr-x 2 4096 Jun 28 15:58 pycache
-rw-rw-r-- 2 3904 Jun 6 2021 automation.py
-rw-rw-r-- 2 416 Jun 6 2021 cli.py
-rw-rw-r-- 2 3831 Jun 6 2021 download_wbt.py
-rw-rw-r-- 2 2469 Jun 6 2021 example.py
drwxrwxr-x 2 4096 Jun 28 15:54 img
drwxrwxr-x 2 4096 Jun 28 15:54 plugins
drwxrwxr-x 2 4096 Jun 28 15:54 testdata
-rw-rw-r-- 2 58608 Jun 6 2021 wb_runner.py
-rw-rw-r-- 2 44 Jun 6 2021 whitebox.py
-rw-rw-r-- 2 6146 Jun 6 2021 whitebox_example.py
-rwxr-xr-x 1 29133144 Jun 28 15:54 whitebox_tools
-rw-rw-r-- 2 401432 Jun 6 2021 whitebox_tools.py

grep 2.1.0 *
Binary file WhiteboxTools_linux_amd64.zip matches
Binary file whitebox_tools matches

cat init.py

-- coding: utf-8 --

"""Top-level package for whitebox."""

author = """Qiusheng Wu"""
email = 'giswqs@gmail.com'
version = '1.5.0'

from .whitebox_tools import WhiteboxTools
from .wb_runner import Runner

The whitebox Python package is just a wrapper, and it will always download the latest WhiteboxTools backend during the first time use. I don't think you need to pin the version. The new version should work the same way as the old new. Try it on local computer before doing things in the cloud. If it works fine locally, the. The problem probably lies in the setup of your cloud environment

Do you want me to download the version of WBT that I need (there seem to be subtle and important differences between v1.5.0 and v2.1.0)? Any hints where that would come from and where it would it go? I'm not in the cloud, just a conda environment.

I am not sure what differences you are referring to. All tools available in v1.5.0 are also available in v2.1.0. The WBT binaries hosted on whiteboxgeo.com are always the latest version. There is no way to retrieve older versions. Again, try the tool on your local computer and post specific error messages here so that we can figure out whether it is a WBT backend issue or Python frontend issue.

I know whiteboxgeo.com is not serving v1.5.0, but "git checkout v1.5.0" is still possible, so I presume an older backend can always be substituted (not sure which files though, any hints?) Just for reference, I'm not sure where I confuse that I'm working in a cloud (all errors above are from a thinkpad, my local machine). Also, WBT output is being used as input to a hydrologic model, where it may be important which version of WBT I use. If this is all too unfamiliar, we can close. I suspect it's a hard issue.

Here is a copy of WBT v1.5.0 that I kept on an old computer. You can unzip the file the replace the WBT binary whitebox_tool in the following path with the v1.5.0 binary.

~/.conda/envs/geo/lib/python3.x/site-packages/whitebox/

Thank you, although I'm afraid that, having substituted my existing WBT directory for your zipped WBT directory (i.e., within my /home/soft/miniconda3/envs/wrfh_gis_env/lib/python3.6/site-packages/whitebox dir), I continue to receive "Using WhiteboxTools v2.1.0 by Dr. John B. Lindsay (c) 2017-2021". Maybe this isn't simply a frontend or backend issue(?)

For reference, my /home/soft/.conda dir only contains one file (environments.txt) and that only contains:

/home/soft/miniconda3
/home/soft/miniconda3/envs/wrfh_gis_env

Not the WBT directory. There is a binary outside the WBT directory. That's the one you need to replace

Yes, this works (and was an easier experiment without the need to recompile v1.5.0). Thanks for the confirmation.