Skip to main content

Essential utilities that grow smart solutions - shared utilities for the smart* ecosystem

Project description

SmartSeeds 🌱

Essential utilities that grow smart solutions

SmartSeeds is a lightweight, zero-dependency Python library providing core utilities for the smart* ecosystem (smartswitch, smartasync, etc.). Think of it as the seeds from which smart solutions grow.

Part of Genro-Libs Python 3.10+ License: MIT PyPI version Documentation Status codecov

Features

  • extract_kwargs: Decorator for extracting and grouping keyword arguments by prefix
  • Three flexible styles: Prefix style, dict style, and boolean activation
  • Zero dependencies: Pure Python standard library
  • Full type hints: Complete typing support

Installation

pip install smartseeds

Quick Start

extract_kwargs Decorator

Extract kwargs by prefix into separate parameter groups - supports three convenient styles:

from smartseeds import extract_kwargs

@extract_kwargs(logging=True, cache=True)
def setup_service(name, logging_kwargs=None, cache_kwargs=None, **kwargs):
    print(f"Logging config: {logging_kwargs}")
    print(f"Cache config: {cache_kwargs}")
    print(f"Other: {kwargs}")

# Style 1: Prefix style (most explicit)
setup_service(
    name="api",
    logging_level="INFO",      # → logging_kwargs={'level': 'INFO'}
    logging_format="json",     # → logging_kwargs={'format': 'json'}
    cache_ttl=300,             # → cache_kwargs={'ttl': 300}
    timeout=30                 # → kwargs={'timeout': 30}
)

# Style 2: Dict style (compact)
setup_service(
    name="api",
    logging={'level': 'INFO', 'format': 'json'},
    cache={'ttl': 300}
)

# Style 3: Boolean activation (use defaults)
setup_service(
    name="api",
    logging=True,  # → logging_kwargs={} (empty dict for defaults)
    cache=True
)

Use in smart* Ecosystem

SmartSeeds is designed to be used by other smart* tools:

# In smartswitch, smartasync, etc.
from smartseeds import extract_kwargs

class Switcher:
    @extract_kwargs(logging=True, async_mode=True)
    def __init__(self, name=None, logging_kwargs=None, async_kwargs=None, **kwargs):
        # Plugin configuration extracted automatically
        if logging_kwargs:
            self.plug('logging', **logging_kwargs)
        if async_kwargs:
            self.plug('async', **async_kwargs)

Why extract_kwargs?

Traditional approaches to nested configuration have problems:

❌ Explicit parameters (verbose)

def connect(host, port, logging_level=None, logging_format=None, logging_file=None):
    logger = Logger(level=logging_level, format=logging_format, file=logging_file)

❌ Catch-all kwargs (unclear)

def connect(host, port, **kwargs):
    # What kwargs are valid? Users don't know!
    logger = Logger(**kwargs)

✅ extract_kwargs (clear + flexible)

@extract_kwargs(logging=True)
def connect(host, port, logging_kwargs=None):
    if logging_kwargs:
        logger = Logger(**logging_kwargs)

# All these work and are clear:
connect('localhost', 8000, logging_level='INFO')
connect('localhost', 8000, logging={'level': 'INFO'})
connect('localhost', 8000, logging=True)

Documentation

Full documentation available at: https://smartseeds.readthedocs.io

Part of the Smart* Family

SmartSeeds is part of the Genropy smart* toolkit:

License

MIT License - see LICENSE file for details.

Contributing

Contributions welcome! Please read our Contributing Guidelines first.

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

smartseeds-0.1.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

smartseeds-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file smartseeds-0.1.0.tar.gz.

File metadata

  • Download URL: smartseeds-0.1.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for smartseeds-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5fd518bc4bcaf4d6191fc189688b08b02c864b32fc1c6773529abcba0acc642a
MD5 98baa2a9a5df5b776794db12b9a680c4
BLAKE2b-256 6059254a6b2c6a6188ed2dce4b456df84480ba55c0b826495c38fece2eff2bc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for smartseeds-0.1.0.tar.gz:

Publisher: publish.yml on genropy/smartseeds

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smartseeds-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: smartseeds-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for smartseeds-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46af0281308bd46c432c9678677d3be5c11af426eb408bcde7258fee7f62ac8b
MD5 cafe2ce6df78e24d81109fc3949c9ff0
BLAKE2b-256 1a2aa972ad873a419e439be310cd71fb9517595481c770082a8fafb83c6cc61b

See more details on using hashes here.

Provenance

The following attestation bundles were made for smartseeds-0.1.0-py3-none-any.whl:

Publisher: publish.yml on genropy/smartseeds

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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