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
  • Progress tracking with UI
  • Database for storing job run history

Quick Start

  1. Initialize the database:
pyjob db 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)
            raise Exception("This is an example error message")
    except Exception as e:
        monitor.error("example_job_name", str(e))

    monitor.done("example_job_name")
  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

# Initalize the database
pyjob db init

# Show all job history
pyjob db show  

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

# Show error message by job id
pyjob db show -e job_id

# 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.2-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyjob_cli-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b0210c33b0e0c702c9c995e57147448862006c62cc609f10fa4a36cb59e0b74d
MD5 c959f6a19da7cd1499f6e2641f967220
BLAKE2b-256 9fd7cdd53931548a724d4f0184d24c5ce2ce21a418741c8fbffb7c9869969b76

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