Skip to main content

Minimalist, Type-Safe DevOps Library for Python

Project description

pykit-dev

Minimalist, Type-Safe DevOps Library for Python

Python 3.9+ License: MIT Code Style: Ruff Type Checked

Standardize your daily DevOps scripts with a clean, unified API.
Built for professionals who need reliability, structured logging, and zero-boilerplate.


⚡ Features

  • 🛡️ Robust Runner: Execute shell commands with built-in retries, timeouts, and safe result handling.
  • ⚙️ Environment Manager: Strict validation, type casting (int, bool, float), and precedence handling (System > .env > Default).
  • 💓 Health Checks: One-line checks for HTTP endpoints, TCP ports, and system processes.
  • 📝 Unified Logger: Professional JSON/Text logging out-of-the-box, ready for Splunk/Datadog.
  • 📐 Type Safe: 100% typed code base compatible with MyPy and VSCode Pylance.

🚀 Installation

pip install pykit-dev

📚 Quick Start

1. Command Execution (Runner)

Execute commands confidently with retry logic and detailed results.

from pykit_dev.runner import run, CommandExecutionError

try:
    # Run with automatic retries and timeout
    result = run("curl https://api.example.com", retry=2, timeout=5)

    print(f"Status: {result.exit_code}")
    print(f"Output: {result.stdout}")

except CommandExecutionError as e:
    print(f"Failed after retries: {e}")

2. Environment Management (Env)

Forget manual os.getenv casting and checking.

from pykit_dev.env import env

# Load from .env file (optional)
env.load(".env")

# Type-safe retrieval
db_url = env.require("DATABASE_URL")             # Raises error if missing
debug = env.get("DEBUG", default=False, cast=bool) # Returns True/False, not "true"
max_conn = env.get("MAX_CONN", default=10, cast=int)

3. Health Checks

Verify dependencies before starting your application.

from pykit_dev.health import health, HealthCheckFailed

try:
    health.http("https://api.github.com")
    health.tcp("localhost", 5432)
    health.process(1234) # Check by PID
    print("✅ System Healthy")

except HealthCheckFailed as e:
    print(f"❌ Health Check Failed: {e}")

4. Professional Logging

from pykit_dev.core.logger import logger

logger.info("Deployment started", {"env": "production"})
# Output: {"timestamp": "...", "level": "INFO", "message": "Deployment started", "extra": {"env": "production"}}

🛠️ Utilities

from pykit_dev.utils import start_timer, slugify

timer = start_timer()
# ... task ...
print(f"Elapsed: {timer.stop()}s")

🤝 Contributing

Contributions are welcome! Please ensure all code passes mypy and pytest.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

Distributed under the MIT License. See LICENSE for more information.


Maintained by @F9-o

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

pykit_dev-0.1.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

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

pykit_dev-0.1.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pykit_dev-0.1.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pykit_dev-0.1.0.tar.gz
Algorithm Hash digest
SHA256 83ca16df5e3c23dab70b7b0c3392b770a811d5fc670b291ae3f3ff12d5a082a2
MD5 8f096db622a610facf880fd24bf0c6f4
BLAKE2b-256 4c4965cdeabdf59b3ceda9cf76cc058c66c0aa8127e814022a097906f2b7b97b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pykit_dev-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pykit_dev-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe0db76398ade87d2576f7f04ddfef716ea6905faefb6525f90f23adb2da8834
MD5 089f9fc69ff265705cc62554c1ef022c
BLAKE2b-256 28c737261122de16f48bff90ccb79e9ccd8ef962e157592f81f93023c3363d31

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