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
  • 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_name", i + 1)
        monitor.done("example_job_name")
    except Exception as e:
        monitor.error("example_job_name", 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 job history
pyjob db show  

# Show specific job by name
pyjob db show -n job_name

# Clear all job history
pyjob db clear

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.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyjob_cli-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d06556865a7b3f53b534b04e32020142aa25f0ccfc89f41b751c79112e91ff50
MD5 ac68d9c2bbc11ab8768902fdd64297e6
BLAKE2b-256 0a8021eea761003c7f06ddf014488fb0b9522c5124e8dc7bfb629dd817ac53da

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