Skip to main content

abstract_essentials

The lean core carved out of abstract_utilities.

Everything here is standard library, with one exception: .env lookups (get_env_value, get_env_path) are re-exported from abstract_security, the single source for them, so installing this package also installs abstract_security (python-dotenv, bcrypt, PyJWT). There are no from .imports import * chains and no submodule fan-out, which makes it a safe foundation for the rest of the abstract_* tree to build on without dragging in the monolith.

Why this exists

abstract_utilities is imported by nearly every abstract_* package, so its size and entanglement (star-exports across a dozen submodules) ripple everywhere. abstract_essentials is the ~50-function subset that is actually used in practice, extracted as a clean, explicit API.

Install

pip install abstract_essentials

Use

from abstract_essentials import make_list, get_any_value, safe_read_from_json, get_logFile

The public API is whatever is listed in abstract_essentials.__all__ ( json/path/file/string/list/type/log helpers).

Logging

get_logFile(name) is the one-call logger: a rotating file plus console output on stderr (stdout stays clean for program output and stdio/MCP servers).

from abstract_essentials import get_logFile
log = get_logFile(__name__)                    # file + stderr, INFO and up
log = get_logFile("jobs", level="debug")       # call again to reconfigure; no duplicate handlers
log = get_logFile("svc", console=False)        # file only (or file=False for console only)
log.log_path                                    # the file; opened on the first record

Files go to <active env>/.logs/abstract_essentials/ (the running interpreter's venv or conda env), else ~/.cache/abstract_essentials/logs. Process-wide switches: ABSTRACT_LOG_LEVEL, ABSTRACT_LOG_CONSOLE=0, ABSTRACT_LOG_FILE=0, ABSTRACT_LOG_DIR. set_logger_level(name, level, enabled) toggles single levels at runtime. A logger the application configured with its own handlers is left as is.

Migrating off abstract_utilities

abstract_utilities can become a thin compatibility shim that re-exports from here (see abstract_utilities_compat_shim.py shipped alongside this scaffold), so existing from abstract_utilities import X keeps working while new code imports from abstract_essentials.

ML/model MIME hints

MIME_TYPES['machine_learning'] and MEDIA_TYPES['machine_learning'] cover GGUF, safetensors, ONNX, PyTorch, TFLite, Keras and Core ML files, plus shared checkpoint, array and serialization extensions. The application/x-* model labels are local package conventions, not asserted IANA registrations.

from abstract_essentials import get_mime_type, derive_media_type, derive_media_types

get_mime_type('weights.SAFETENSORS')  # 'application/x-safetensors'
derive_media_type('weights.gguf')    # 'machine_learning'
derive_media_types('weights.bin')   # ('executable', 'machine_learning')
derive_media_types('weights.h5')    # ('data_science', 'pandas_data', 'machine_learning')

These functions inspect the filename only and accept paths or dotted extensions. Both category helpers are case-insensitive. The singular helper preserves the first-match order of existing categories; the plural helper retains ambiguity. Generic .bin, .ckpt, .pb, .model, and pickle files keep application/octet-stream: an extension does not establish model contents. JSON configs remain documents; a model directory's supporting files are not automatically models. Directory bundles are not detected by these helpers.

For discovery, use these mappings to shortlist candidates, then inspect content and retain detected format, container MIME, and extension agreement separately. For example, PyTorch checkpoints can use ZIP containers, while safetensors uses a length-prefixed JSON tensor header. A filename MIME hint is not proof that either parser will accept the file, nor permission to unpickle it.

The existing find_utils defaults derive their extension sets from this registry, so new ML extensions also enter its default exclusion set. Pass explicit scan filters when collecting model files.

License

MIT — putkoff / Abstract Endeavors.

Generic file and data helpers

The shared helpers formerly implemented in hugpy_resources now live here:

  • file_ops: atomic text writes, mode/ownership writes, encoding-aware reads, line ranges, exact edits, metadata, directory listings, trees, and POSIX locks.
  • path_utils: path resolution, confinement, repository-relative references, globs, and metadata snapshots that do not traverse symlinked directories.
  • json_utils: deterministic dumps/digest, surrogate-safe readable_dumps, and unique_pairs for rejecting duplicate JSON keys.
  • json_utils.structured: JSON/TOML/YAML reading and atomic JSON writing.
  • env_utils: environment values, home expansion and file parsing. read_env keeps the last duplicate; parse_env_file keeps the first nonempty value and handles export and paired quotes. These are deliberately distinct contracts.
  • terminal_utils, time_utils, sql_utils, argument_utils, numeric_utils, and callable_utils: terminal cell widths, UTC timestamps, SQL quoting, argument parsing, strict integers/statistics, and optional calls.

File encoding tables, terminal escape rules, structured-format extensions, boolean vocabularies, and confinement exception types can be supplied by the caller. Nothing imports Hugpy or reads its configuration. Apart from the abstract_security dependency for .env lookups, the package is stdlib-only; YAML needs PyYAML only when used, TOML needs Python 3.11+, and file_ops.exclusive loads POSIX fcntl only when called.

Dependency loading

Import helpers live in abstract_essentials.lazy_utils:

  • load_import("package:attribute") loads immediately and raises ImportError with the original cause. A bare package or trailing colon returns the module. Application adapters can supply error_type=MyError.
  • first_import(*paths) tries ordered compatibility alternatives and raises the last failure. It supports the same error_type option.
  • require("package", reason="feature") requires a module; is_available attempts the actual import and returns false for ImportError. Other import-time errors propagate so broken packages are distinguishable.
  • import_registry builds an unloaded export table; resolve_import imports and caches a requested export. local=original aliases an attribute; local= selects the module. Relative imports and parent roots are supported.
  • lazy_module("package", errors="raise") defers importing until first use and propagates failures. lazy_import("package", "attribute", errors="raise") resolves immediately and propagates failures.

Proxy behavior is a deliberate fallback: errors="proxy" returns a nullProxy when loading fails. That placeholder allows chained access, is false in boolean contexts, and logs and returns None when called without a fallback. Existing lazy_import and lazy_module calls retain this legacy default for compatibility; new callers should select their failure policy explicitly or use strict loaders. The lower-level legacy lazy_import_single and get_lazy_attr remain proxy-based.

Metadata

Release files for abstract-essentials 0.0.0.36

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

Source distribution (sdist)

Source distribution for abstract-essentials 0.0.0.36
File Size Uploaded Provenance Actions
abstract_essentials-0.0.0.36.tar.gz 88.1 kB Without provenance Details for abstract_essentials-0.0.0.36.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for abstract-essentials 0.0.0.36
File Interpreter ABI Platform Actions
abstract_essentials-0.0.0.36-py3-none-any.whl Python 3 none any Details for abstract_essentials-0.0.0.36-py3-none-any.whl

Total release size: 187.6 kB

Release files / abstract_essentials-0.0.0.36.tar.gz

Download URL abstract_essentials-0.0.0.36.tar.gz
Size 88.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c30baeeb424ce01730ef47063616998c564592328eec8dcc3e215c803c9c356f
BLAKE2b-256 checksum
How to use checksums
40cd29cb8a2730a3a7029afe2b348b221b26f289b334b9b949579abaca9f0651
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / abstract_essentials-0.0.0.36-py3-none-any.whl

Download URL abstract_essentials-0.0.0.36-py3-none-any.whl
Size 99.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
576ee4767011a7b33ba0c7d508dbe29c71fc3d911c59edf9987d3a4bf73e5445
BLAKE2b-256 checksum
How to use checksums
f62ed795f9c6d7bb519b846428d826b6ff4a3f0166e9abf351ed28d286f82bf7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for abstract-essentials 0.0.0.36

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.0.36 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