Skip to main content

Python module to easily run scripts in modular frameworks Written by pedrohenriquecoimbra

Project description

FrameworkAPI, a Modular Framework Runner

Shows an illustrated sun in light mode and a moon with stars in dark mode.

A Python module for creating fully modular and extensible workflows by combining scripts in different languages, managing YAML-based configurations, and offering an API for seamless integration.


Features

🚀 Script Runner

Easily run scripts written in Python, R, or Julia with dynamic argument support.

  • Automatic Language Detection: Identify script type and invoke the appropriate runtime (e.g., python, Rscript, julia).
  • Flexible Argument Passing: Pass command-line arguments directly to scripts for parameterized execution.
  • Robust Error Handling: Logs and handles errors during script execution.

📜 YAML Configuration Handler

Effortlessly parse, validate, and manage YAML files with cross-references.

  • Dynamic Parsing: Load YAML configurations into Python objects.
  • Cross-Reference Resolution: Automatically resolve dependencies between keys within a single file or across multiple files.
  • Flexible Configuration Management: Merge or extend YAML files to build modular workflows.

🛠 High-Level API for Script Execution

A simple API to link scripts and configurations for easy execution.

  • Script Discovery: Fetch script paths and parameters from the YAML configuration.
  • Workflow Automation: Execute scripts dynamically based on configuration settings.
  • Extensibility: Add hooks for pre- and post-processing or extend functionality as needed.

Installation

pip install FrameworkAPI

Quickstart

1️⃣ Define Your Configuration (config.yaml)

scripts:
  preprocess:
    path: "scripts/preprocess.py"
    args:
      input_file: "data/raw.csv"
      output_file: "data/processed.csv"
  analyze:
    path: "scripts/analyze.R"
    args:
      input_file: "data/processed.csv"
      report_file: "results/report.html"

workflow:
  - preprocess
  - analyze

2️⃣ Run Scripts Using the API

from FrameworkAPI import FrameworkAPI

# Load configuration
framework = FrameworkAPI("config.yaml")

# Execute the entire workflow
framework.run_workflow()

# Or execute a single script by name
framework.run_script("preprocess")

3️⃣ Seamlessly Handle Multiple Languages

The module automatically detects the script type and runs the appropriate interpreter:

  • .pypython
  • .RRscript
  • .jljulia

Directory Structure

project/
├── config.yaml          # Your YAML configuration file
├── scripts/             # Directory for scripts
│   ├── preprocess.py    # Python script
│   ├── analyze.R        # R script
├── results/             # Output directory
└── main.py              # Main Python script

Advanced Features

  • Cross-References in YAML: Use references to reuse values across the configuration.

    data_dir: "data/"
    scripts:
      preprocess:
        input_file: "${data_dir}raw.csv"
        output_file: "${data_dir}processed.csv"
    
  • Custom Hooks: Add pre- or post-processing logic in Python for additional control.


Contributing

We welcome contributions! Please submit a pull request or open an issue for bug reports, feature requests, or questions.


License

This project is licensed under the MIT License.


Contact

Feel free to reach out for support or collaboration:


Happy scripting! ✨

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

frameworkapi-0.0.5.3.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

frameworkapi-0.0.5.3-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file frameworkapi-0.0.5.3.tar.gz.

File metadata

  • Download URL: frameworkapi-0.0.5.3.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.12

File hashes

Hashes for frameworkapi-0.0.5.3.tar.gz
Algorithm Hash digest
SHA256 0eff4e1d10551c72217d6bae3cab5a0606fd71785cedf29a0f2cd5ebdb8889e3
MD5 2e37c1c7c791f472192d5d1610d7a655
BLAKE2b-256 56e7de30ab8b45c12f4da408a66c44082dd52d2b7015f6adba35d9b3c3f27162

See more details on using hashes here.

File details

Details for the file frameworkapi-0.0.5.3-py3-none-any.whl.

File metadata

  • Download URL: frameworkapi-0.0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.12

File hashes

Hashes for frameworkapi-0.0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ba3acc031f97c55837b83a536bc1ac64c1aa8c5425f1b60b83d0bc14a1d32208
MD5 d5554c3d0d545ec8308a43cec1ad77da
BLAKE2b-256 5f64f4a3a8614223d6d1f983e6681913a60454bc5556e084a1478daa90eb5a13

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