Skip to content

NachbarStrom/python-nachbarstrom-dl-segmentation

Repository files navigation

tms-nachbarstrom-python

Repo for the Python functions of Nachbarschaftstrom.

Get the files

  • Get the source code:
sudo apt-get update -y
git clone https://github.com/tomasruizt/tms-nachbarstrom-python
cd tms-nachbarstrom-python/

If not running on Google Cloud

  • Prepare a folder for the credentials:
mkdir cred
  • If running on Azure, you can find a machine address e.g. 'the-machine-address' to connect to.
  • Put the Google service credentials on the server. For example, by copying them from your machine to the server:
scp -i private_key google_service_credentials.json 
the-machine-address:~/tms-nachbarstrom-python/cred

Setup the environment

  • Run the setup script for 'Ubuntu 16.04 LTS', or follow its steps, if you are on another platform.
bash install_environment.sh
  • Your new Python environment is located in the 'env-prod/' folder.
  • Activate your Python environment. If you are on Windows, replace the command with 'env-prod/Scripts/activate'.
source env-prod/bin/activate
  • Set your environment variables, for example API keys.
  • Finally, you can start the server either in 'production' mode or in 'develop' mode.

For production:

nohup sudo --preserve-env $(which python3) -m nachbarstrom.inference.web_server.app >>logs 2>>logs &
  • Here preserve-env is used to keep the environment variables when using sudo.
  • We use -m to call the app.py as a module.
  • >>logs 2>>logs redirects all output to the logs file.
  • The & command detaches the process from the command line.

For development:

sudo --preserve-env $(which python3) -m nachbarstrom.inference.web_server.app --develop

Testing

Make sure your Python environment is active.

  • Run unit tests. The option 'rs' stands for report skipped.
python -m pytest -rs
  • Integration tests: Usually launched on the 'develop', but not necessarily.
python -m pytest -rs --integration

Stopping the server

sudo killall python3

Development tips

Lint the code:

pylint app.py

Use static type checker:

mypy --ignore-missing-imports app.py

About

Repo for the Python functions of Nachbarschaftstrom

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •