Metadata-Version: 2.4
Name: molcrafts-molq
Version: 0.1.0
Summary: Modern job queue for local and cluster runners
Author-email: Roy Kid <lijichen365@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/molcrafts/molq
Project-URL: Documentation, https://molcrafts.github.io/molq
Project-URL: Repository, https://github.com/molcrafts/molq
Project-URL: Issues, https://github.com/molcrafts/molq/issues
Project-URL: Changelog, https://github.com/molcrafts/molq/blob/main/CHANGELOG.md
Keywords: job,queue,cluster,slurm,hpc,scheduler
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: System :: Distributed Computing
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.0
Requires-Dist: click>=8.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-mock; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: coverage[toml]; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: mkdocs; extra == "dev"
Requires-Dist: mkdocs-material; extra == "dev"
Requires-Dist: mkdocstrings[python]; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs; extra == "docs"
Requires-Dist: mkdocs-material; extra == "docs"
Requires-Dist: mkdocstrings[python]; extra == "docs"
Dynamic: license-file

# Molq: Molcrafts Queue Interface

[![Tests](https://github.com/molcrafts/molq/workflows/Tests/badge.svg)](https://github.com/molcrafts/molq/actions)
[![PyPI version](https://badge.fury.io/py/molq.svg)](https://badge.fury.io/py/molq)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

**Molq** is a unified and flexible job queue system designed for both local execution and cluster computing environments. It provides a clean, decorator-based API that makes it easy to submit, monitor, and manage computational tasks across different execution backends.

## ✨ Key Features

- **🎯 Unified Interface**: Single API for local and cluster execution
- **🐍 Decorator-Based**: Simple, Pythonic syntax using decorators
- **⚡ Generator Support**: Advanced control flow with generator-based tasks
- **🔌 Multiple Backends**: Support for local execution, SLURM clusters, and more
- **📊 Job Monitoring**: Built-in status tracking and error handling
- **💾 Resource Management**: Flexible resource allocation and cleanup
- **🔄 Job Dependencies**: Chain jobs and manage complex workflows
- **📧 Notifications**: Email alerts for job status changes

## 🚀 Quick Start

### Installation

```bash
pip install molq
```

### Basic Usage

```python
from molq import submit

# Create submitters for different environments
local = submit('dev', 'local')           # Local execution
cluster = submit('hpc', 'slurm')         # SLURM cluster

@local
def hello_world(name: str):
    """A simple local job."""
    job_id = yield {
        'cmd': ['echo', f'Hello, {name}!'],
        'job_name': 'greeting'
    }
    return job_id

@cluster
def train_model():
    """A GPU training job on the cluster."""
    job_id = yield {
        'cmd': ['python', 'train.py'],
        'cpus': 16,
        'memory': '64GB',
        'time': '08:00:00',
        'gpus': 2,
        'partition': 'gpu'
    }
    return job_id

# Run jobs
hello_world("Molq")
job_id = train_model()
```

### Command Line Integration

```python
from molq import cmdline

@cmdline
def get_system_info():
    """Execute command and capture output."""
    result = yield {'cmd': ['uname', '-a']}
    return result.stdout.decode().strip()

system_info = get_system_info()
print(system_info)
```

## 📖 Documentation

- **[Tutorial](https://molcrafts.github.io/molq/tutorial/getting-started/)** - Step-by-step guide
- **[API Reference](https://molcrafts.github.io/molq/api/)** - Complete API documentation
- **[Recipes](https://molcrafts.github.io/molq/recipes/machine-learning/)** - Real-world examples
- **[Examples](examples/)** - Practical code examples

## 🎯 Supported Backends

| Backend | Description | Status |
|---------|-------------|---------|
| **Local** | Local machine execution | ✅ Full support |
| **SLURM** | HPC cluster scheduler | ✅ Full support |
| **PBS/Torque** | Legacy cluster scheduler | 🚧 Basic support |
| **LSF** | IBM cluster scheduler | 🚧 Basic support |

## 🔧 Advanced Features

### Multi-Step Workflows
```python
@cluster
def analysis_pipeline():
    # Step 1: Preprocessing
    prep_job = yield {
        'cmd': ['python', 'preprocess.py'],
        'cpus': 8, 'memory': '32GB', 'time': '02:00:00'
    }

    # Step 2: Analysis (depends on preprocessing)
    analysis_job = yield {
        'cmd': ['python', 'analyze.py'],
        'cpus': 16, 'memory': '64GB', 'time': '08:00:00',
        'dependency': prep_job  # Wait for preprocessing
    }

    return [prep_job, analysis_job]
```

### Error Handling
```python
@cluster
def robust_job():
    try:
        return yield {'cmd': ['python', 'risky_script.py']}
    except Exception:
        # Fallback to safer approach
        return yield {'cmd': ['python', 'safe_script.py']}
```

## 🤝 Contributing

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

## 📝 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- Inspired by [Hamilton](https://hamilton.dagworks.io) for dataflow patterns
- Built for the scientific computing and HPC community
