Skip to main content

A CLI tool for monitoring Python scripts

Project description

pyjob-cli

A command-line tool for monitoring progress of Python scripts with real-time progress tracking.

Features

  • Run multiple Python scripts concurrently with progress monitoring
  • Background execution support
  • Real-time progress tracking with UI
  • Persistent job state tracking
  • SQLite database for storing job history

Quick Start

  1. Initialize the database:
pyjob init
  1. Create a simple script:
# example_script.py

import time

def main(monitor):
    pages = 10
    
    monitor.add("example_job_name", pages)
    try:
        for i in range(pages):
            time.sleep(0.5) 
            monitor.update("example_job", i + 1)
        monitor.done("example_job")
    except Exception as e:
        monitor.error("example_job", str(e))
  1. Run your script:
pyjob run example_script.py

Usage

Basic Commands

# Initialize database
pyjob init

# Run a single script
pyjob run script.py

# Run multiple scripts concurrently
pyjob run script1.py script2.py script3.py

# Run in background mode
pyjob run --background script.py

# Show progress of running jobs in the background
pyjob show

Writing Compatible Scripts

Your scripts should follow these guidelines:

  1. Include a main function with the correct signature:
def main(monitor):
    # Your code here
    pass
  1. Use the monitor methods:
# Register your job
monitor.add("job_name", total_items)

# Update progress
monitor.update("job_name", current_progress)

# Mark as complete
monitor.done("job_name")

# Report errors
monitor.error("job_name", "error message")

Database

A database is created at ~/.pyjob/pyjob.db with the following table:

  • jobs: Individual jobs for each run

Database Commands

# Show all jobs
pyjob show_db  

# Show specific job by name
pyjob show_db -n name_of_job

Requirements

  • Python 3.12+

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

pyjob_cli-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyjob_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.5

File hashes

Hashes for pyjob_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9230644764cd37084189a7f38119438ba9d3516afbb2edebfc346ebad385830a
MD5 72a07c48c9d8ee822a004e0966893f2e
BLAKE2b-256 b3121047e70746a04c678636e8f15cf90de1568fda47cf14820cdc752b52d75a

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