Skip to main content

hixumo-hive

Your Python app's values from Hixumo Hive, without a .env file: Django, FastAPI, Flask, Celery or a script. Python 3.10 or newer; no other package is needed, and no Node.js.

pip install hixumo-hive
import os

from hixumo_hive import load_hive

load_hive()

database_url = os.environ["DATABASE_URL"]

With HIVE_TOKEN (an access token) in the server's environment. Hive is asked once, when the app starts, however often load_hive is called. Nothing polls: a changed value reaches the app at its next start. Under hive run (a laptop, a test) the values are there already and Hive is not asked at all.

Call it before the modules that read os.environ as they are imported. A package's own __init__.py runs before the modules in it, too. In an async app, call it as the app starts, or await asyncio.to_thread(load_hive).

No code

python -m hixumo_hive run -- gunicorn app:app

The command runs with the values in its environment, and takes this process's place: signals and the exit code are its own. Its workers find the values there, so Hive is asked once for all of them. HIVE_TOKEN and the snapshot settings are not passed on to it. When the values cannot be read, the command does not start, one line says why, and the exit code is 1. HIVE_OPTIONAL=1 lets it start with nothing to read from; anything else, a refusal or a setting that is wrong, still stops it.

Or import hixumo_hive.register first: it loads the values as it is imported, with HIVE_OPTIONAL too.

Frameworks

  • Django: the first lines of settings.py (the file loaded first, when the settings are split), above everything in it that reads os.environ. manage.py, WSGI, ASGI and Celery all load the settings; what their own files read before that (DJANGO_SETTINGS_MODULE, for one) cannot come from Hive. For a build step with nothing to read from (collectstatic), use load_hive(optional=True), and os.environ.get(...) for the keys the settings read.
  • FastAPI, Flask: above the app's own imports, in the file the server loads. Linters may report the imports below it (E402): say so there, or use "No code".
  • Workers: with several, each worker asks once when it loads the app. gunicorn --preload and "No code" ask once for all. A development server's reloader (runserver, flask run --debug) keeps the values it started with: restart it for new ones. So does whatever starts itself again from a process that loaded them (gunicorn --preload with USR2, os.exec…): restart the process that loaded them.

load_hive(...)

Option Default Does
required Keys that must be there and not empty; else missing_keys, all of them named, and nothing is set
environment HIVE_ENV The environment it must be (its name, any case, or its id); another is wrong_environment
inject True Put the values in os.environ
override True Hive's values win over what os.environ has, as in hive run; False keeps what is there
optional False With nothing to read from, an empty result instead of no_source. Never hides a refusal
token HIVE_TOKEN An access token. Given in code, HIVE_SNAPSHOT is left out
api_url HIVE_API_URL, else the one built in The Hive API's address. Given in code, HIVE_SNAPSHOT is left out
snapshot, snapshot_use HIVE_SNAPSHOT, HIVE_SNAPSHOT_USE See "Snapshots"
timeout 20.0 Seconds for the whole read, tries and waits included (1 to 120)

It gives a Hive: environment, source (hive, snapshot, run or none), created_at (a snapshot's), values (read-only), get(key, default), require(key) (raises when missing or empty), hive[key], key in hive, keys(), len(hive). Printing it shows how many keys there are, never a value. It cannot be pickled, and is no Mapping on purpose: error trackers walk those.

A HiveError has a code and a sentence; neither holds a value, a token or a key, and nor do the local variables of its traceback: no_source, bad_token, bad_options, token_refused, tokens_off, not_found, paused, refused, rate_limited, unreachable, not_hive, wrong_environment, missing_keys, missing_key, unfit_value, snapshot_missing, snapshot_key, snapshot_unreadable, snapshot_package, unexpected. A call that does not get through is tried three times within timeout; a refusal never is. A failed read is answered again for 5 seconds before Hive is asked again (after a 429, for as long as Hive asked, a minute at most). Ctrl+C, or what a signal handler raises (a task's time limit), is never one of these: it goes to whoever waits for it.

  • Forks, spawned processes and commands find the values in the environment they inherit and ask for nothing, when the process that starts them has loaded the values (with inject, the default): HIVE_LOADED there (names and a hash, never a value) says what was loaded, and with what. The SDK for Node.js understands it too. One that has another HIVE_TOKEN, HIVE_SNAPSHOT or HIVE_API_URL of its own reads with that instead. multiprocessing's fork server (Linux's default from Python 3.14) is such a starting process: load the values before it starts, or each child asks.
  • Values named like a setting (HIVE_TOKEN, HIVE_API_URL, HIVE_ENV, HIVE_SNAPSHOT…) are values: get() has them, and they are never put in os.environ.
  • The token stays in the environment. hive run and "No code" take it out of their command's; load_hive runs inside the app and leaves it, so the app's child processes inherit it.
  • Proxies and certificates: HTTPS_PROXY and NO_PROXY are kept to (through a tunnel: the proxy sees no token), and certificates are Python's own (SSL_CERT_FILE for others; on macOS, python.org's Python needs its "Install Certificates.command" run once).

Snapshots: no call to Hive at run time

For functions that start often (serverless), or a start that must not depend on Hive. The build saves the environment's values in one encrypted file with the Hive CLI (it needs Node.js there), and the app opens it:

npx @hixumo/hive snapshot key                     # once: keep it as the secret HIVE_SNAPSHOT_KEY
npx @hixumo/hive snapshot --env production        # in the build: writes hive.snapshot.json
pip install "hixumo-hive[snapshot]"               # with the cryptography package, which opens it

At run time: HIVE_SNAPSHOT=hive.snapshot.json and HIVE_SNAPSHOT_KEY, the same code as above, and no HIVE_TOKEN. Ship the file with the app. The cryptography package has compiled code: install it for the platform the app runs on.

HIVE_SNAPSHOT_USE=offline (with HIVE_TOKEN) asks Hive first and uses the snapshot only when Hive cannot answer (the network, an error on its side, too many requests), with one line on stderr. A refusal Hive gives (a revoked token, tokens turned off, a paused space) is never answered from it.

  • AES-256-GCM with a key made from 32 random bytes; no password is taken as a key.
  • Its values change with the next build.
  • Revoking a token does not reach a snapshot already made: for that, make a new key and change the values it held.

Licence

Not open source. It may be installed and run, unchanged, to use Hixumo Hive, and included (unchanged except by bundling or minifying) in your own application that uses Hixumo Hive; copying, changing or redistributing it otherwise needs Hixumo's permission. See LICENSE.

Metadata

Release files for hixumo-hive 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hixumo-hive 0.0.1
File Size Uploaded Provenance Actions
hixumo_hive-0.0.1.tar.gz 27.6 kB Without provenance Details for hixumo_hive-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hixumo-hive 0.0.1
File Interpreter ABI Platform Actions
hixumo_hive-0.0.1-py3-none-any.whl Python 3 none any Details for hixumo_hive-0.0.1-py3-none-any.whl

Total release size: 59.6 kB

Release files / hixumo_hive-0.0.1.tar.gz

Download URL hixumo_hive-0.0.1.tar.gz
Size 27.6 kB
Tags Source
SHA-256 checksum
How to use checksums
bad1501b390ccbf71c5dec57361aaff5c3375f42c1472ccd5b966e8659fecf59
BLAKE2b-256 checksum
How to use checksums
cb60bb73dbc6afefca90db4a9e6d3c560debcc9616faf9821c252b0492286d9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / hixumo_hive-0.0.1-py3-none-any.whl

Download URL hixumo_hive-0.0.1-py3-none-any.whl
Size 32.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d930a0bdefc27174e2c57331085a9691eb4f42201d6c2c53ef78676979facf4
BLAKE2b-256 checksum
How to use checksums
6ff1b57d26007cbde716b5cfead1d7bba4e4da43a843a884f410d98a642d91fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for hixumo-hive 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page