Giter VIP home page Giter VIP logo

bats-ai's Introduction

bats-ai

Develop with Docker (recommended quickstart)

This is the simplest configuration for developers to start with.

Initial Setup

  1. Run docker compose run --rm django ./manage.py migrate
  2. Run docker compose run --rm django ./manage.py createsuperuser and follow the prompts to create your own user

Run Application

  1. Run docker compose up
  2. Access the site, starting at http://localhost:8000/admin/
  3. When finished, use Ctrl+C

Application Maintenance

Occasionally, new package dependencies or schema changes will necessitate maintenance. To non-destructively update your development stack at any time:

  1. Run docker compose pull
  2. Run docker compose build --pull --no-cache
  3. Run docker compose run --rm django ./manage.py migrate

Develop Natively (advanced)

This configuration still uses Docker to run attached services in the background, but allows developers to run Python code on their native system.

Initial Setup

  1. Run docker compose -f ./docker-compose.yml up -d
  2. Install Python 3.10
  3. Install psycopg2 build prerequisites
  4. Create and activate a new Python virtualenv
  5. Run pip install -e .[dev]
  6. Run source ./dev/export-env.sh
  7. Run ./manage.py migrate
  8. Run ./manage.py createsuperuser and follow the prompts to create your own user

Run Application

  1. Ensure docker compose -f ./docker-compose.yml up -d is still active
  2. Run:
    1. source ./dev/export-env.sh
    2. ./manage.py runserver
  3. Run in a separate terminal:
    1. source ./dev/export-env.sh
    2. celery --app bats_ai.celery worker --loglevel INFO --without-heartbeat
  4. When finished, run docker compose stop
  5. To destroy the stack and start fresh, run docker compose down -v

Remap Service Ports (optional)

Attached services may be exposed to the host system via alternative ports. Developers who work on multiple software projects concurrently may find this helpful to avoid port conflicts.

To do so, before running any docker compose commands, set any of the environment variables:

  • DOCKER_POSTGRES_PORT
  • DOCKER_RABBITMQ_PORT
  • DOCKER_MINIO_PORT

The Django server must be informed about the changes:

  • When running the "Develop with Docker" configuration, override the environment variables:
    • DJANGO_MINIO_STORAGE_MEDIA_URL, using the port from DOCKER_MINIO_PORT.
  • When running the "Develop Natively" configuration, override the environment variables:
    • DJANGO_DATABASE_URL, using the port from DOCKER_POSTGRES_PORT
    • DJANGO_CELERY_BROKER_URL, using the port from DOCKER_RABBITMQ_PORT
    • DJANGO_MINIO_STORAGE_ENDPOINT, using the port from DOCKER_MINIO_PORT

Since most of Django's environment variables contain additional content, use the values from the appropriate dev/.env.docker-compose* file as a baseline for overrides.

Testing

Initial Setup

tox is used to execute all tests. tox is installed automatically with the dev package extra.

When running the "Develop with Docker" configuration, all tox commands must be run as docker-compose run --rm django tox; extra arguments may also be appended to this form.

Running Tests

Run tox to launch the full test suite.

Individual test environments may be selectively run. This also allows additional options to be be added. Useful sub-commands include:

  • tox -e lint: Run only the style checks
  • tox -e type: Run only the type checks
  • tox -e test: Run only the pytest-driven tests

To automatically reformat all code to comply with some (but not all) of the style checks, run tox -e format.

bats-ai's People

Contributors

bryonlewis avatar

Watchers

 avatar

bats-ai's Issues

UI Features

Log scale,
Annotation Pulse Width and kHz frequency
ability to toggle between log and linear scales for the spectrogram

What we want the User to see:

  • Start time
  • End time
  • Date of recording
  • Location (show on map)
  • Default species list (nice to have later), uses a Grid Cell number to map up to the species. Assume there is some python stuff to do lat/long to grid cell.

Map of where the annotations were recorded from

Uploaded Requirements:

  • Audio Files
  • Location
  • Equipment information

Nice to haveAdded in a default species list

Linking between DB and displaying specotrograms

Creating a way to link the DB values to the viewer.

  • Items aren't directly referenced in S3/MinIO so I need a way to connect the File name to the system.
  • A way to hopefully link the annotations with a species type.

Notes:
Below I have the structure of the tables and how to associate some of the data.

  • Projects - Top Level Item
  • Surveys - have a foreign key into projects
  • SurveyEvents -> foreign key into Surveys
  • AcousticBatch -> foreign key into SurveyEvent
  • AcousticFileBatch -> foreign key into AcoustBatchObject and AcousticFile
  • AcousticFile -> foreign key into a Project

Some Endpoints that will be needed:

  • /projects upper level item that has a header to the system
  • /survey - listing of the surveys
  • /survey_event - listing of survey_events
  • /acoustic_batch - listing of acoustic batches
  • /acoustic_file_batch - list of acoustic_file_batches
  • /acoustic_file - list of all acoustic files
  • species - list of all annotated species

Behavior:

  • Initially I would love to have an endpoint that could list audio files and when clicking on an audio file it would request the resigned URL for the wav file and provide the relevant species annotations and segments for that file.
    • This would require from the audio file getting the related audio file images to get the offset milliseconds and the frequency for the image.
    • I would then need to find the AcousticFileBatch to get the speciesObject to display the species

For an given audiofile I think I want the return to look like:

{
    "filename": "example.wav",
    "url": "presigned_S3/MinIO/URL",
    "survey": {
        "type": {
            "description":  "text descriptio",
            "mapColor": "#000000"
        }
    },
    "generated_image": "base64 image data",
    "project": {
        "key": "uuid-key",
        "name": "name of project",
        "decription": "description",
        "created": "ISO Date"
    },
    "annotations": [
        {
            "offset": "offset in ms",
            "frequency": "frequency center in ms"
        }
    ],
    "species": {
        "code": "code",
        "family": "family",
        "genus": "genus",
        "species": "species",
        "commonName": "commonname"

    }
}

Notes:
50ms windows on spectrogram from database
Offset is most likely the start time for that window.
Double check frequency to see if it is bottom/top/center.

DB-Rendering

Using new endpoints create a client side code for the following:

  • Listing available audio files in a list format. These files should include if they existing the s3/MinIO location as well as if they have annotations. If they have annotations it should list the species.
  • Create an API endpoint to get a list of all the species available which can be used for selection
  • When selecting an audio file it should be able to be loaded into the spectrogram for proper rendering and comparison with the image files that were generated.

Project listing with geospatial area and number of surveys.
You can click on a project to go to surveys filtered by the project.
Then each individual survey you can then see the number of files associated with each survey and geospatial information about it.
Clicking on the file takes you to more information about that file including the auto/manual species identification.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.