Skip to main content

Add your description here

Reason this release was yanked:

broken escape character

Project description

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

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

argmerge-0.0.1.tar.gz (5.5 MB view details)

Uploaded Source

Built Distribution

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

argmerge-0.0.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file argmerge-0.0.1.tar.gz.

File metadata

  • Download URL: argmerge-0.0.1.tar.gz
  • Upload date:
  • Size: 5.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for argmerge-0.0.1.tar.gz
Algorithm Hash digest
SHA256 214e0b0ec6de9bc92e7266e4b28ae0fe0dc251f96f53e19ae2ec34c66476652b
MD5 180726a25e146f2c060b9ffda00c18d1
BLAKE2b-256 612d6a5137fb5f506abc925f0bcebb38bb7fbfb243242d986b80b0093c3e51a6

See more details on using hashes here.

File details

Details for the file argmerge-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: argmerge-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for argmerge-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 efa76a3d151deef4ba4f3816ac8079fb179e3e35140f6cdb2fe710fa5a9a36df
MD5 2ed5e5fa8e4b89c409b8c92adc847f63
BLAKE2b-256 226e79319f5f550568bc50544edf9a676eefb9ee87ecc5b504a24dfc8873e4bb

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