You may start the server locally or using a docker container, the requirements for each setup are listed below.
Make sure you have all requirements installed on your computer. Then, you may start the server using either a Docker container or in your local machine.
Export these environment variables:
export MINIO_ENDPOINT=localhost:9000
export MINIO_ACCESS_KEY=minio
export MINIO_SECRET_KEY=minio123
export MYSQL_DB_HOST=mysql
export MYSQL_DB_NAME=platiagro
export MYSQL_DB_USER=root
export MYSQL_DB_PASSWORD=
export JUPYTER_ENDPOINT=http://localhost:8888
export KF_PIPELINES_ENDPOINT=127.0.0.1:31380/pipeline
export KF_PIPELINES_NAMESPACE=anonymous
(Optional) Start a MinIO instance:
docker run -d -p 9000:9000 \
--name minio \
--env "MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY" \
--env "MINIO_SECRET_KEY=$MINIO_SECRET_KEY" \
minio/minio:RELEASE.2018-02-09T22-40-05Z \
server /data
(Optional) Start a MySQL server instance:
docker run -d -p 3306:3306 \
--name mysql \
--env "MYSQL_DATABASE=$MYSQL_DB_NAME" \
--env "MYSQL_ROOT_PASSWORD=$MYSQL_DB_PASSWORD" \
--env "MYSQL_ALLOW_EMPTY_PASSWORD=yes" \
mysql:8.0.3
(Optional) Start a Jupyter Notebook instance:
docker run -d -p 8888:8888 \
--name jupyter \
jupyter/base-notebook \
start-notebook.sh --NotebookApp.token=''
Then, build a docker image that launches the API server:
docker build -t platiagro/projects:0.2.0 .
Finally, start the API server:
docker run -it -p 8080:8080 \
--name projects \
--env "MINIO_ENDPOINT=$MINIO_ENDPOINT" \
--env "MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY" \
--env "MINIO_SECRET_KEY=$MINIO_SECRET_KEY" \
--env "MYSQL_DB_HOST=$MYSQL_DB_HOST" \
--env "MYSQL_DB_NAME=$MYSQL_DB_NAME" \
--env "MYSQL_DB_USER=$MYSQL_DB_USER" \
--env "MYSQL_DB_PASSWORD=$MYSQL_DB_PASSWORD" \
--env "JUPYTER_ENDPOINT=$JUPYTER_ENDPOINT" \
platiagro/projects:0.2.0
Export these environment variables:
export MINIO_ENDPOINT=localhost:9000
export MINIO_ACCESS_KEY=minio
export MINIO_SECRET_KEY=minio123
export MYSQL_DB_HOST=localhost
export MYSQL_DB_NAME=platiagro
export MYSQL_DB_USER=root
export MYSQL_DB_PASSWORD=
export JUPYTER_ENDPOINT=http://localhost:8888
export KF_PIPELINES_ENDPOINT=127.0.0.1:31380/pipeline
export KF_PIPELINES_NAMESPACE=anonymous
(Optional) Create a virtualenv:
virtualenv -p python3 venv
. venv/bin/activate
Install Python modules:
pip install .
(Optional) Initialize database:
platiagro-init-db
Then, start the API server:
python -m projects.api.main
Install the testing requirements:
pip install .[testing]
Export these environment variables:
export MINIO_ENDPOINT=localhost:9000
export MINIO_ACCESS_KEY=minio
export MINIO_SECRET_KEY=minio123
export MYSQL_DB_HOST=localhost
export MYSQL_DB_NAME=platiagro
export MYSQL_DB_USER=root
export MYSQL_DB_PASSWORD=
export JUPYTER_ENDPOINT=http://localhost:8888
export KF_PIPELINES_ENDPOINT=localhost:5000
export KF_PIPELINES_NAMESPACE=anonymous
Use the following command to run all tests:
pytest
Use the following command to run lint:
flake8 --max-line-length 127 projects/
See the PlatIAgro Projects API doc for API specification.