Python wrapper for api use in the cave_app
Project description
Cave Utilities for the Cave App
Basic utilities for the MIT Cave App. This package is intended to be used by the Cave App and the Cave API.
Setup
Make sure you have Python 3.9.x (or higher) installed on your system. You can download it here.
Installation
pip install cave_utils
Running Validator Tests
Example:
-
In your cave_app, update the following file:
cave_api/tests/test_init.py
from cave_api import execute_command from cave_utils.socket import Socket from cave_utils.validator import Validator init_session_data = execute_command(session_data={}, socket=Socket(), command="init") x = Validator(init_session_data) x.log.print_logs() # x.log.print_logs(level="error") # x.log.print_logs(level="warning") # x.log.print_logs(max_count=10)
-
Run the following command:
cave test test_init.py
cave_utils development
Using Local Hotloading
-
In your
cave_app
, update the following file:utils/run_server.sh
#!/bin/bash SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) APP_DIR=$(dirname "$SCRIPT_DIR") pip install -e /cave_utils source ./utils/helpers/shell_functions.sh source ./utils/helpers/ensure_postgres_running.sh source ./utils/helpers/ensure_db_setup.sh python "$APP_DIR/manage.py" runserver 0.0.0.0:8000 2>&1 | pipe_log "INFO"
-
Remove
cave_utils
from the rootrequirements.txt
file -
In your
cave_app
, setLIVE_API_VALIDATION_PRINT=True
in the.env
file- This will validate your data every time an API command is called for each session
-
Use the following command to run your
cave_app
:cave run --docker-args "--volume {local_path_to_cave_utils}/cave_utils:/cave_utils"
- As you edit
cave_utils
, any changes will be hotloaded into your runningcave_app
- As you edit
Using interactive mode and running tests
- Run cave_app in interactive mode mounting cave_utils as a volume:
cave run --docker-args "--volume {local_path_to_cave_utils}/cave_utils:/cave_utils" -it
- Then install cave utils in the docker container:
pip install -e /cave_utils
- Then run some tests (eg
validate_all_examples.py
):python cave_api/tests/validate_all_examples.py
Generate Documentation
- Set up your virtual environment
python3 -m virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
- Update the docs
source venv/bin/activate
./update_documentation.sh
Generate a New Release
- Set up your virtual environment
python3 -m virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
- Update the version number in:
setup.cfg
pyproject.toml
- Update the release
source venv/bin/activate
./update_version.sh
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cave_utils-2.3.0.tar.gz
.
File metadata
- Download URL: cave_utils-2.3.0.tar.gz
- Upload date:
- Size: 54.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2fb022440be41b400504b19c260787b45286de07ad09daac2b8db431426dc31 |
|
MD5 | 79fb53807c511d71922a75e909a839e4 |
|
BLAKE2b-256 | 8faa58ac7c7fc4980da97f45a13453c9058eec8a48941a6e1a03059e2eabc1bd |
File details
Details for the file cave_utils-2.3.0-py3-none-any.whl
.
File metadata
- Download URL: cave_utils-2.3.0-py3-none-any.whl
- Upload date:
- Size: 54.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe2d588c629711e2a5d4201b0a60b216037bb6246e2ccaa5f2d7719601fb3ea7 |
|
MD5 | bb0e22783dd4d2e1322fbc82c0c27dd9 |
|
BLAKE2b-256 | 756e72184f4b36b9ae2374b088720df844a24fdb10222aee3a6874a55da96f82 |