Skip to main content

Shared runtime for the oh-my-* Flask services: settings DB, Claude CLI gateway, timezone, base-url, scheduler.

Project description

oh-my-common

Shared runtime for the oh-my-* Flask services. Extracted so each split-out service (oh-my-rss / oh-my-msg / oh-my-write) shares one implementation instead of drifting copies. Per the split design, each service keeps its own settings DB — this package is the code layer, not a shared store.

Modules

  • settings — SQLite settings client + secret resolution. get_setting/put_setting/get_all, the provider_tokens cache (get/set/clear_cached_token), and resolve_secret(key, env_key) with precedence service-namespace > global > env. Convenience: resolve_claude_token(), resolve_openai_key(). Config via env: SETTINGS_DB (path), OMI_SERVICE_NS (this service's namespace, e.g. clipboard).
  • claude — Claude CLI gateway: resolve_claude_bin, claude_text, run_claude_capture, gate_ai, claude_status, extract_json, estimate_tokens, estimate_cost, MODEL_PRICING. Flask-free.
  • tzlocal_tz()/now_local()/today_local() from OMI_TZ_OFFSET (hours, default +8).
  • urlsrequest_base_url() (honors X-Forwarded-Proto/Host). Imports flask lazily.
  • schedulermake_scheduler(ENABLED_ENV) → a guarded BackgroundScheduler (returns None when ENABLED_ENV=0, so extra gunicorn workers don't double-run). Imports apscheduler lazily.

Usage

import os
os.environ.setdefault('OMI_SERVICE_NS', 'clipboard')
from oh_my_common import get_setting, claude_text, resolve_openai_key, now_local

key, src = resolve_openai_key()
text = claude_text('Summarize: ...', model='sonnet')

Install

pip install oh-my-common            # core (stdlib only)
pip install 'oh-my-common[flask,scheduler]'   # + request_base_url + make_scheduler

Distribution into Docker services is TBD — see the migration plan. Options: publish to a registry, vendor into each monorepo, or a git dependency.

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

oh_my_common-0.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oh_my_common-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file oh_my_common-0.1.0.tar.gz.

File metadata

  • Download URL: oh_my_common-0.1.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for oh_my_common-0.1.0.tar.gz
Algorithm Hash digest
SHA256 17ce23757c3898eef97e5ee6bdca5a2413c0d067aa1ae536a2d5df3d0f83a40b
MD5 114a47f2bacf4e60cf29100373c1c47c
BLAKE2b-256 54ba6bccaa978e437c77c7709908c1dbcc09a132cec13270a38d61240f2d2b2e

See more details on using hashes here.

File details

Details for the file oh_my_common-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: oh_my_common-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for oh_my_common-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be95e80fdbbc444885ac160205385e67313eb0e3b7ec7eb241c19bef9e5dd4d8
MD5 28ae57dd18acb06d1df5683a636ceba7
BLAKE2b-256 c4b977e9ae8b55e5576d29378fc198c4c04588ecf4170028f6e40a7825cd4315

See more details on using hashes here.

Supported by

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