Skip to main content

argmerge

Description

Customize how program defaults and overrides from config files, environment variables, and CLI arguments "cross the threshold" into your program.

CI/CD
Package PyPI - Python Version
Meta types - Mypy

We retrieve each possible source of program arguments as Python dictionaries and then perform dictionary updates between each source before passing the final dictionary to the wrapped function. Effectively:

source_1: dict
source_2: dict

source_1.update(source_2)

function(**source_1)

Installation

We recommend using uv for package management.

uv add argmerge

If you're using pip you can run

pip install argmerge

Usage

Code Example

While designed for main functions, you can ddd the @threshold decorator to any program that interfaces with external variables or files.

from argmerge import threshold


@threshold
def main(first: int, second: str, third: float = 0.0):
    ...

Hierarchy

We determined the hierarchy based on (our perception of) developer experience. The intent is for higher priority sources to correspond to the quickest sources to change. For example, we perceive changing a CLI argument quicker than changing an environment variable - etc.

Level Rank
Developer-provided 100
CLI 40
Environment Variable 30
YAML File 20
JSON File 10
Python Function Default 0

FAQ

Why YAML over JSON?

We prioritized YAML above JSON is because we find it significantly easier to read because it has less "line noise". JSON contains copious amounts of brackets ({,}) and commas. These are the only two sources that can pass dictionaries in by default. Of course, passing in different Regular expressions for environment variables and CLI arguments could also capture dictionaries, if you want to figure that out.

Planned Future Work

For specific bite-sized work, you can take a look at our project's GitHub issues. ⚠️ Caution - this project is new and issues may be under-specified ⚠️

Validation

We want users to be able to validate the input arguments to their program using a PyDantic BaseModel. This would slot in after we collect the arguments from all the different sources.

Customizing @threshold

We provide ways to customize reading environment variables and CLI arguments with the env_prefix and cli_pattern parameters. If developers want to go a step further and pull values from external sources we haven't considered (like .cfg files), we would like to allow them to do so.

Databricks

Databricks offers a way to collect 'widgets' or 'secrets' in their notebooks at runtime and pass them into your program. This is cool. It also is higher-risk for not being able to exactly reproduce your workloads. This makes @threshold a very good candidate to merge arguments between the Databricks platform and other external sources. For example, though not recommended, it's possible to create widgets in a notebook that gets run in an asset bundle. Asset bundles can be run like CLI applications, which means you can pass arguments in from the CLI or the widgets.

Authentication

This is a tricky one, and we may not do it. Since we truly want to provide everything a program needs to run, this would include any authentication keys - think Database access keys or application API keys. The way we'd retrieve keys varies between cloud platforms, as well as non-cloud platforms. What may make the most sense is for us to build some sort of plugin system that allows users to bring their own authentication

Metadata

Release files for argmerge 0.0.4

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

Source distribution (sdist)

Source distribution for argmerge 0.0.4
File Size Uploaded Provenance Actions
argmerge-0.0.4.tar.gz 5.5 MB Without provenance Details for argmerge-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for argmerge 0.0.4
File Interpreter ABI Platform Actions
argmerge-0.0.4-py3-none-any.whl Python 3 none any Details for argmerge-0.0.4-py3-none-any.whl

Total release size: 5.5 MB

Release files / argmerge-0.0.4.tar.gz

Download URL argmerge-0.0.4.tar.gz
Size 5.5 MB
Tags Source
SHA-256 checksum
How to use checksums
60319c27b8f310dccd174fe898cb07b6aa02f0604d231a3b8fdce785ead6a40a
BLAKE2b-256 checksum
How to use checksums
90fe660289b19a69924613869ecbdf30b60a643661e660bfc2e509c4d109236d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / argmerge-0.0.4-py3-none-any.whl

Download URL argmerge-0.0.4-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
084759af8fdf56f482f777d38e34c9eb611355b725ef104814cb748aa2ec4db2
BLAKE2b-256 checksum
How to use checksums
c3ad40787e1136cad6b20a41f104a4d7d2d36f9fb3f536353e8a2ea5e7a10b65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for argmerge 0.0.4

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