Skip to content

yo-le-zz/Procyl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Procyl v1.0.0

A lightweight, intelligent worker system for creating, compiling, running, and managing Python-based processes.

Procyl simplifies the management of isolated Python workers with automatic dependency detection, environment management, and parallel execution support.

✨ Features

  • πŸ”§ Automatic Dependency Detection - Scans code for external packages (not stdlib)
  • 🎯 Smart Environment Management - One-time environment setup via procyl.prepare()
  • πŸš€ Multiple Execution Modes - Python source, PyInstaller, or Nuitka compilation
  • ⚑ Parallel Execution - Run workers multiple times simultaneously
  • πŸ“Š Rich Metadata - Access worker info via .data property
  • πŸ›‘οΈ Verification - Built-in worker integrity checks
  • πŸ“¦ Minimal Footprint - Lightweight, disk-efficient design
  • πŸ”„ Version Control - Support for specific package versions and requirements files

πŸ“¦ Installation

pip install procyl

For compilation support:

pip install procyl[compile]

πŸš€ Quick Start

1. Create Workers

Workers are Python functions executed in isolated processes:

import procyl

# Create a simple worker
worker = procyl.create(
    "greet",
    '''
import sys
print(f"Hello, {sys.argv[1]}!")
'''
)

2. Prepare Environment

Install all dependencies used by workers:

# Automatic - scans all workers
procyl.prepare()

# With specific versions
procyl.prepare(constraints={
    "requests": "==2.32.3",
    "numpy": ">=2.3,<3"
})

# From requirements file
procyl.prepare(requirements="requirements.txt")

3. Access Worker Metadata

print(worker.data.hash)              # Code hash
print(worker.data.compiler)          # Compiler used
print(worker.data.compiled)          # Compilation status
print(worker.data.dependencies)      # External dependencies
print(worker.data.python_version)    # Python version
print(worker.data.platform)          # Platform info
print(worker.data.path)              # Artifact path
print(worker.data.size)              # Artifact size
print(worker.data.running)           # Is running?

4. Verify Workers

result = worker.verify()
print(result)
# {
#     'name': 'greet',
#     'valid': True,
#     'issues': [],
#     'dependencies': ['requests', 'numpy']
# }

5. Run Workers

# Single execution
output = procyl.run("greet", args=["Alice"])

# Multiple parallel executions
results = worker.run(count=8, args=["Bob"])
for output in results:
    print(output)

πŸ“š API Reference

procyl.create()

Create a new worker.

worker = procyl.create(
    name: str,                          # Worker name
    code: str,                          # Python code
    icon: Optional[str] = None,         # Icon path
    args: Optional[List[str]] = None,   # Default arguments
    compiler: str = "auto",             # python/pyinstaller/nuitka/auto
    output_dir: Optional[str] = None,   # Output directory
    timeout_seconds: Optional[int] = None,
    auto_delete_after: Optional[int] = None,
    compile_args: Optional[List[str]] = None,
)

Returns: Worker object

procyl.prepare()

Prepare the Python environment with dependencies.

success = procyl.prepare(
    constraints: Optional[Dict[str, str]] = None,
    requirements: Optional[str] = None,
)

Parameters:

  • constraints: Dict of package version constraints
  • requirements: Path to requirements.txt file

Returns: bool - Success status

worker.data

Access worker metadata (read-only).

Properties:

  • hash - SHA256 hash of code (16 chars)
  • compiler - Compiler used
  • compiled - Whether compiled
  • created_at - Creation timestamp
  • last_build - Last build timestamp
  • dependencies - Set of external package names
  • python_version - Python version
  • platform - Platform string
  • path - Path to artifact
  • size - Artifact size in bytes
  • pid - Process ID (if running)
  • running - Whether currently running

worker.verify()

Verify worker integrity.

result = worker.verify()
# Returns dict with:
# - 'name': worker name
# - 'valid': boolean
# - 'issues': list of issues
# - 'compiled': (optional)
# - 'artifact_size': (optional)
# - 'dependencies': (optional)

worker.run()

Execute worker once or multiple times in parallel.

results = worker.run(
    count: int = 1,                     # Number of parallel executions
    args: Optional[List[str]] = None,   # Arguments (overrides default)
)

Returns: List[str] - List of outputs

procyl.run()

Execute a worker by name.

output = procyl.run(
    name: str,
    args: Optional[List[str]] = None,
)

procyl.status()

Get worker status.

status = procyl.status(name: str)

procyl.delete()

Delete a worker.

result = procyl.delete(name: str)

procyl.precompile()

Compile a worker ahead of time.

result = procyl.precompile(
    name: str,
    output_dir: Optional[str] = None,
    compiler: Optional[str] = None,
    thread: bool = False,
)

πŸ“ File Structure

.procyl/                    # Created by prepare()
β”œβ”€β”€ env/                    # Python venv
β”‚   β”œβ”€β”€ bin/               # Python executables
β”‚   β”œβ”€β”€ lib/               # Installed packages
β”‚   └── ...
β”œβ”€β”€ .metadata/             # Worker metadata
└── metadata.json          # Environment info

πŸ” Automatic Dependency Scanning

Procyl automatically scans code for external dependencies using AST analysis:

worker = procyl.create("demo", '''
import requests
import numpy as np
import sys           # stdlib - ignored
import os            # stdlib - ignored

print("Hello")
''')

print(worker.data.dependencies)
# Output: {'requests', 'numpy'}

🎯 Use Cases

Multi-threaded Workers

worker = procyl.create("compute", "print(sum(range(1000)))")
results = worker.run(count=8)
print(f"Computed {len(results)} times in parallel")

Version-Pinned Dependencies

procyl.prepare(constraints={
    "tensorflow": "==2.13.0",
    "numpy": "<2.0"
})

Compiled Executables

worker = procyl.create("app", code)
procyl.precompile("app", compiler="pyinstaller", output_dir="./dist")

πŸ“ Examples

See examples/demo.py for a comprehensive example:

python examples/demo.py

πŸ§ͺ Testing

Run tests:

pytest tests/test_core_v1.py -v

Run verification:

python verify.py

πŸ“„ Documentation

πŸ“„ License

MIT

πŸ‘€ Author

yolezz


Procyl v1.0.0 - Intelligent Python Worker Management

About

Procyl is a lightweight Python execution layer for managing isolated workers as named tasks. It lets you define and run Python code snippets as independent units, similar to shell commands, with runtime or optional compiled execution. It focuses on simple process management for automation and tooling workflows.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages