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.
Overview
This package is part of the larger Cave App framework. It provides utilities that are commonly used across different Cave applications, such as validation and logging. It is designed to be an easy to integrate library that can be used in any Cave application. It also serves to provide automated documentation and testing.
You can find the low level documentation for this package here.
Setup
Make sure you have Python 3.11.x (or higher) installed on your system. You can download it here.
Installation
pip install cave_utils
cave_utils development
Running Tests, Prettifying Code, and Updating Docs
Make sure Docker is installed and running.
-
Create a docker container and drop into a shell
./run.sh
-
Run all tests (see ./utils/test.sh)
./run.sh test
-
Prettify the code (see ./utils/prettify.sh)
./run.sh prettify
-
Update the docs (see ./utils/docs.sh)
./run.sh docs
-
Note: You can and should modify the
Dockerfileto test different python versions.
Using Local Hotloading With a Cave App
-
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 # Check if the app is functional before proceeding if [ "$(python ./manage.py check --deployment_type development | grep "System check identified no issues" | wc -l)" -eq "0" ]; then printf "Unable to start the app due to an error in the code. See the stacktrace above." 2>&1 | pipe_log "ERROR" rm -r "./tmp" exit 1 fi 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_utilsfrom the rootrequirements.txtfile -
In your
cave_app, setLIVE_API_VALIDATION_PRINT=Truein the.envfile- 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 in your Cave App and running tests
- Note: This is for very specific use cases, such as running tests or debugging in an interactive shell.
- Note: In general, we copy all included examples from the cave_app to the
cave_utils/test/api_examplesdirectory, so you can run tests against them without needing to run the cave_app.- These copied examples can be tested by running
./run.sh testin the cave_utils directory, which will run all tests in thecave_utils/test.- This includes
test_validator.pywhich runs all examples in thecave_utils/test/api_examplesdirectory
- This includes
- These copied examples can be tested by running
- 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 a New Release
- Make sure all tests are passing and the code is prettified.
- Make sure the documentation is up to date.
- Make sure the version number is updated in
setup.cfgandpyproject.toml. - Set up your virtual environment
python3 -m virtualenv venvsource venv/bin/activatepip install -r requirements.txt
- Update the release
source venv/bin/activate./publish.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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cave_utils-3.4.4.tar.gz.
File metadata
- Download URL: cave_utils-3.4.4.tar.gz
- Upload date:
- Size: 59.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31eaf27cfe4e3efa2569770946eae57cea182577ba1244f88c7c20b22f856cda
|
|
| MD5 |
2c64c17bf482abbd219393caaf7c2e64
|
|
| BLAKE2b-256 |
0b46495ea4c235bac192cf12b113c38f5228f0e73198d143e9baf2884d44b215
|
File details
Details for the file cave_utils-3.4.4-py3-none-any.whl.
File metadata
- Download URL: cave_utils-3.4.4-py3-none-any.whl
- Upload date:
- Size: 64.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ea936589ec4c58cbd70f130bf84bb12e3e399e8fd17a464a44593150d727352
|
|
| MD5 |
2e2f043bf79185b571bd611a4842bcc2
|
|
| BLAKE2b-256 |
3bf300dd9d6d88bdb905e974267bc5295b1e64dd439963c296714a93ccec1372
|