cave-utils


Namecave-utils JSON
Version 2.3.0 PyPI version JSON
download
home_pageNone
SummaryPython wrapper for api use in the cave_app
upload_time2024-08-23 13:41:17
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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](https://www.python.org/downloads/).

### Installation

```
pip install cave_utils
```


# Running Validator Tests

## Example:
1. 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)
    ```

2. Run the following command:
    `cave test test_init.py`


# cave_utils development

## Using Local Hotloading

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

2. Remove `cave_utils` from the root `requirements.txt` file

3. In your `cave_app`, set `LIVE_API_VALIDATION_PRINT=True` in the `.env` file
    - This will validate your data every time an API command is called for each session

4. 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 running `cave_app`

## Using interactive mode and running tests

1. 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`
2. Then install cave utils in the docker container:
    `pip install -e /cave_utils`
3. Then run some tests (eg `validate_all_examples.py`):
    `python cave_api/tests/validate_all_examples.py`

# Generate Documentation

1. Set up your virtual environment
    - `python3 -m virtualenv venv`
    - `source venv/bin/activate`
    - `pip install -r requirements.txt`
2. Update the docs
    - `source venv/bin/activate`
    - `./update_documentation.sh`

# Generate a New Release

1. Set up your virtual environment
    - `python3 -m virtualenv venv`
    - `source venv/bin/activate`
    - `pip install -r requirements.txt`
2. Update the version number in:
    - `setup.cfg`
    - `pyproject.toml`
3. Update the release
    - `source venv/bin/activate`
    - `./update_version.sh`

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cave-utils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Connor Makowski <conmak@mit.edu>",
    "download_url": "https://files.pythonhosted.org/packages/8f/aa/58ac7c7fc4980da97f45a13453c9058eec8a48941a6e1a03059e2eabc1bd/cave_utils-2.3.0.tar.gz",
    "platform": null,
    "description": "Cave Utilities for the Cave App\n==========\nBasic utilities for the MIT Cave App. This package is intended to be used by the Cave App and the Cave API.\n\nSetup\n----------\n\nMake sure you have Python 3.9.x (or higher) installed on your system. You can download it [here](https://www.python.org/downloads/).\n\n### Installation\n\n```\npip install cave_utils\n```\n\n\n# Running Validator Tests\n\n## Example:\n1. In your cave_app, update the following file:\n\n    `cave_api/tests/test_init.py`\n    ```\n    from cave_api import execute_command\n    from cave_utils.socket import Socket\n    from cave_utils.validator import Validator\n\n\n    init_session_data = execute_command(session_data={}, socket=Socket(), command=\"init\")\n\n    x = Validator(init_session_data)\n\n    x.log.print_logs()\n    # x.log.print_logs(level=\"error\")\n    # x.log.print_logs(level=\"warning\")\n    # x.log.print_logs(max_count=10)\n    ```\n\n2. Run the following command:\n    `cave test test_init.py`\n\n\n# cave_utils development\n\n## Using Local Hotloading\n\n1. In your `cave_app`, update the following file:\n\n    `utils/run_server.sh`\n    ```\n    #!/bin/bash\n\n    SCRIPT_DIR=$( cd -- \"$( dirname -- \"${BASH_SOURCE[0]}\" )\" &> /dev/null && pwd )\n    APP_DIR=$(dirname \"$SCRIPT_DIR\")\n\n    pip install -e /cave_utils\n\n    source ./utils/helpers/shell_functions.sh\n    source ./utils/helpers/ensure_postgres_running.sh\n    source ./utils/helpers/ensure_db_setup.sh\n\n    python \"$APP_DIR/manage.py\" runserver 0.0.0.0:8000 2>&1 | pipe_log \"INFO\"\n    ```\n\n2. Remove `cave_utils` from the root `requirements.txt` file\n\n3. In your `cave_app`, set `LIVE_API_VALIDATION_PRINT=True` in the `.env` file\n    - This will validate your data every time an API command is called for each session\n\n4. Use the following command to run your `cave_app`:\n    `cave run --docker-args \"--volume {local_path_to_cave_utils}/cave_utils:/cave_utils\"`\n    - As you edit `cave_utils`, any changes will be hotloaded into your running `cave_app`\n\n## Using interactive mode and running tests\n\n1. Run cave_app in interactive mode mounting cave_utils as a volume:\n    `cave run --docker-args \"--volume {local_path_to_cave_utils}/cave_utils:/cave_utils\" -it`\n2. Then install cave utils in the docker container:\n    `pip install -e /cave_utils`\n3. Then run some tests (eg `validate_all_examples.py`):\n    `python cave_api/tests/validate_all_examples.py`\n\n# Generate Documentation\n\n1. Set up your virtual environment\n    - `python3 -m virtualenv venv`\n    - `source venv/bin/activate`\n    - `pip install -r requirements.txt`\n2. Update the docs\n    - `source venv/bin/activate`\n    - `./update_documentation.sh`\n\n# Generate a New Release\n\n1. Set up your virtual environment\n    - `python3 -m virtualenv venv`\n    - `source venv/bin/activate`\n    - `pip install -r requirements.txt`\n2. Update the version number in:\n    - `setup.cfg`\n    - `pyproject.toml`\n3. Update the release\n    - `source venv/bin/activate`\n    - `./update_version.sh`\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python wrapper for api use in the cave_app",
    "version": "2.3.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/mit-cave/cave_utils/issues",
        "Homepage": "https://github.com/mit-cave/cave_utils"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "756e72184f4b36b9ae2374b088720df844a24fdb10222aee3a6874a55da96f82",
                "md5": "bb0e22783dd4d2e1322fbc82c0c27dd9",
                "sha256": "fe2d588c629711e2a5d4201b0a60b216037bb6246e2ccaa5f2d7719601fb3ea7"
            },
            "downloads": -1,
            "filename": "cave_utils-2.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bb0e22783dd4d2e1322fbc82c0c27dd9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 54792,
            "upload_time": "2024-08-23T13:41:14",
            "upload_time_iso_8601": "2024-08-23T13:41:14.050463Z",
            "url": "https://files.pythonhosted.org/packages/75/6e/72184f4b36b9ae2374b088720df844a24fdb10222aee3a6874a55da96f82/cave_utils-2.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8faa58ac7c7fc4980da97f45a13453c9058eec8a48941a6e1a03059e2eabc1bd",
                "md5": "79fb53807c511d71922a75e909a839e4",
                "sha256": "b2fb022440be41b400504b19c260787b45286de07ad09daac2b8db431426dc31"
            },
            "downloads": -1,
            "filename": "cave_utils-2.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "79fb53807c511d71922a75e909a839e4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 54284,
            "upload_time": "2024-08-23T13:41:17",
            "upload_time_iso_8601": "2024-08-23T13:41:17.254919Z",
            "url": "https://files.pythonhosted.org/packages/8f/aa/58ac7c7fc4980da97f45a13453c9058eec8a48941a6e1a03059e2eabc1bd/cave_utils-2.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-23 13:41:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mit-cave",
    "github_project": "cave_utils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "cave-utils"
}
        
Elapsed time: 0.30604s