Skip to main content

🏭 Foundational infrastructure for Foundry components.

Project description

🏭 Foundry Python Core

License CI Quality Gate Security Maintainability Technical Debt Code Smells Dependabot Renovate enabled Coverage Ruff Pyright Copier

Foundational infrastructure for Foundry components.

Prerequisites

Install mise (task runner and dev tool manager):

brew install mise

Or follow the installation guide for other methods. Then activate mise in your shell profile.

Usage

Initialise the context at application startup

Call set_context() once, before any library code runs, then call boot() to initialise logging, the SSL trust chain, and optional Sentry integration:

# main.py
from aignostics_foundry_core.foundry import FoundryContext, set_context
from aignostics_foundry_core.boot import boot

set_context(FoundryContext.from_package("myproject"))
boot()

FoundryContext.from_package() derives everything from package metadata and environment variables:

  • name, version, version_full — from importlib.metadata
  • environment — from MYPROJECT_ENVIRONMENTENVVERCEL_ENVRAILWAY_ENVIRONMENT"local"
  • is_container, is_cli, is_test, is_library — detected automatically
  • env_prefix ("MYPROJECT_") — used by every settings class in the library

Access the context from any module

from aignostics_foundry_core.foundry import get_context

ctx = get_context()
print(f"Running {ctx.name} v{ctx.version_full} in {ctx.environment}")
# → Running myproject v1.2.3+main---run.12345 in staging

get_context() raises RuntimeError with a clear message if set_context() was never called.

Pass context explicitly in tests

Never call set_context() in tests. Pass a FoundryContext directly to each function via its optional context parameter instead:

from aignostics_foundry_core.foundry import FoundryContext
from aignostics_foundry_core.log import logging_initialize

ctx = FoundryContext(name="myproject", version="0.0.0", version_full="0.0.0", environment="test")
logging_initialize(context=ctx)

All public library functions (logging_initialize, sentry_initialize, boot, load_modules, etc.) accept an optional context keyword argument and fall back to get_context() when it is None.

Health API

from aignostics_foundry_core.health import Health, HealthStatus

health = Health(status=HealthStatus.UP)

Further Reading

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

aignostics_foundry_core-0.3.0.tar.gz (49.0 kB view details)

Uploaded Source

Built Distribution

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

aignostics_foundry_core-0.3.0-py3-none-any.whl (59.3 kB view details)

Uploaded Python 3

File details

Details for the file aignostics_foundry_core-0.3.0.tar.gz.

File metadata

  • Download URL: aignostics_foundry_core-0.3.0.tar.gz
  • Upload date:
  • Size: 49.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for aignostics_foundry_core-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3d88d95e0a0a770f4066deadcfade025fb8fdb2b73ff9b5e0e9c5018a0747796
MD5 b49a03faaf54b4e84db347b5c987e506
BLAKE2b-256 a0e2e73f2e0378a428608e8db507eec63a13949fde3b5c5e7117879fca1cf653

See more details on using hashes here.

File details

Details for the file aignostics_foundry_core-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: aignostics_foundry_core-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 59.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for aignostics_foundry_core-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39c51f604705607ac23dcecaa000a15a700f1c7c3cf0908632589a8ff86df1f0
MD5 189495d7160e379cb098e4a4c20ba4c0
BLAKE2b-256 fbef627c096fc72b55b877ca8f10862ab07f92aad70a8c727574c0ea4096e5be

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