Skip to main content

oori's miscellaneous python toolkit

Project description

Utiloori - oori's miscellaneous toolkit

Utiloori is primarily developed by the crew at Oori Data. We offer software engineering services around LLM applications.

PyPI - Version PyPI - Python Version

Table of contents:

print ansi colors in terminal

Wraps text in ANSI color codes (and terminators) for printing colored text to console.

Some terminals, notably VSCode's, try to be clever about not displaying unreadable text; they might override the font color you specify if you specify a background color that is too similar to the font color. For example, if you specify a black font color on a red background, VSCode will override the font color to white.

colors

the following "standard" ansi colors are supported:

  • black
  • red
  • green
  • yellow
  • blue
  • purple
  • cyan
  • white

usage

from utiloori.ansi_color import ansi_color

print string with green font:

green_string = ansi_color('lorem', 'green')
print(green_string)

print string with purple background (with default, white font):

purple_bg_string = ansi_color('ipsum', bg_color='purple')
print(purple_bg_string)

print string with red font on a blue background:

red_on_blue_string = ansi_color('dolor', 'red', 'blue')
print(red_on_blue_string)

Spin up a PostgreSQL vector database using Docker with a custom config

Locally

  1. Clone the repository.
  2. From the root, run:
docker compose -f compose.PGvector.yml up -d --build

(you can remove --build if you don't want to rebuild the image) 3. Now you have PGv database running on localhost:5432 and an adminer interface on localhost:8080

On a remote host

  1. Clone the repository on your local machine.
  2. Copy pg_configs/postgresql.conf to /etc/postgresql.conf (or another absolute path) on the remote host.
    • If you choose another absolute path, make sure to modify compose.PGv_remote.yml as follows:
  volumes:
    # This is in the remote itself, not in the repo. See pg_configs for references
    - <custom_path_here>:/etc/postgresql.conf
  1. Set up a remote docker context and switch to it.
docker context create <context_name> --docker host=ssh://<user>@<remote_host_ip>

docker context use <context_name>
  1. Run:
docker compose up -f compose.PGv_remote.yml
  1. Now you have PGv database running on <remote_host_ip>:5432 and an adminer interface on <remote_host_ip>:8080

Configurable:

  • All the options in pg_configs/postgresql.conf, by default max_connections to 200 and shared_buffers to 128mb
  • Inside of compose.PGvector.yml or compose.PGv_remote.yml
    • POSTGRES_USER: The username used to connect to the database.
    • POSTGRES_PASSWORD: The password used to connect to the database.
    • POSTGRES_DB: The name of the database created.
    • Ports can be configured inside compose.PGvector.yml

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

utiloori-0.2.0.tar.gz (18.9 kB view hashes)

Uploaded Source

Built Distribution

utiloori-0.2.0-py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page