Local Deployment¶
Takeaway
Vitual Environment - Conda
Testing on Command Line Interface Software
Testing on Web Interface Software
Search how to download VSCode as your IDE. Search how to download Anaconda in your computer. Meanwhile, you will get a command line tool called conda. Use
conda --version
to check whether it exists on VSCode console.Create a virtual environment using
conda create --name geo python=3.9
.It would create a new Conda environment named “geo“ with Python version 3.9.Enter y to go on and then it is done quickly.
Activate your created virutal environment through
conda activate geo
. Once it is activated, the head your command line would change from (base) into (geo).Caution! Sometimes you will get a problem of Python dependency management. You will get the illusion that I did download the required dependency using pip, but why it told that I haven’t downloaded the related dependency yet when running the Python script.
It is caused by the not correct pip you use. Here is the solution to resolve. On MacOS, you can use
which -a pip
to check whether the pip used belongs to the virtual environment geo. The alike command on Windows Powershell isGet-command pip
.The result shows that the pip currently used belongs to your system environment. Because the first location is
/usr/local/bin/pip
. It means the highest prority. Also it indicates whenever you executepip install some-dependency
, the first location takes precedence. All the dependencies would be downloded to your system environment.This problem happens occasionally when you activate your virtual environment (geo) in (base) environment. Hence, you can resolve it by deactivating from (geo) and then deactivating from (base). Continually, you need to activate (geo) again.
Go into the directory requirments and download necessary dependencies to run Python code by executing
pip install -r development.txt
. Then wait until all dependencies are downloaded.Now you can test our command-line-interface (CLI) software locally by navigating to the directory geochemistrypi **and then execute ``python start_cli_pipeline.py``. You can press **ctrl + C to stop anytime in the middle.
Also, you can launch the backend server as well by using
python start_dash_pipeline.py
. Until now, you can copy the address http://0.0.0.0:8000 shown in the below picture and open it in the browser.This indicates that the backend server works normally.
Besides, you can append the suffix /docs to the backend server address http://0.0.0.0:8000 to make http://0.0.0.0:8000/docs. Then use this address to open our API interface in the browser.
Of course, you can open Dash page too by using the address http://0.0.0.0:8000/dash. But it is not recommended to use here because the functionality data uploading under the hood is binded with the frontend framework. No rush. More detail would be shown later on.
In order to activate the frontend server, you need to search how to download node.js (find the version suitable your computer) firstly. After installing Node.js, verify that npm is installed correctly. You can open a new terminal or command prompt on VSCode and use
npm --version
.Once you have Node.js and npm installed, you can use
npm install yarn
to install Yarn on your system.Then, you can navigate to the directory frontend and use
yarn install
to download related dependencies.Now, you can use
yarn start
to activate the frontend server. The webpage will pop out from your default brower automatically. When you modify the code related to backend or frontend. You don’t need compiled them. They would be complied automatically once the code changes. Any mistake would be monitored directly from the console. So keep both servers active if you want to do experiment.Hooray,this is the tiral webpage.