Local Deployment

Takeaway

  • Vitual Environment - Conda

  • Testing on Command Line Interface Software

  • Testing on Web Interface Software

  1. 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.

    image

  2. 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.

    image

    Enter y to go on and then it is done quickly.

    image

  3. Activate your created virutal environment through conda activate geo . Once it is activated, the head your command line would change from (base) into (geo).

    image

    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 is Get-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 execute pip install some-dependency, the first location takes precedence. All the dependencies would be downloded to your system environment.

    image

    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.

    image

  4. 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.

    image

    image

    image

  5. 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.

    image

    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.

    image

    This indicates that the backend server works normally.

    image

    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.

    image

    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.

    image

  6. 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.

    image

    Once you have Node.js and npm installed, you can use npm install yarn to install Yarn on your system.

    image

    Then, you can navigate to the directory frontend and use yarn install to download related dependencies.

    image

    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.

    image

    Hooray,this is the tiral webpage.

    9e5b73c488a9ae08ce881d66b03a1836