Command-line interface for StatShed status dashboard
Project description
StatShed CLI
Command-line interface for the StatShed status dashboard.
Installation
pip install statshed-cli
For rich terminal output:
pip install statshed-cli[rich]
Usage
Submit Job Status
# Submit a success status
statshed submit -g nightly-builds -j backend-tests -s success -m "All tests passed"
# Submit an error status
statshed submit -g nightly-builds -j backend-tests -s error -m "3 tests failed"
# Submit a progress status
statshed submit -g nightly-builds -j backend-tests -s progress -m "Running tests..."
Check System Health
statshed health
List Groups
statshed groups
List Jobs in a Group
statshed jobs nightly-builds
View/Update Configuration
# View global config
statshed config
# Update global config
statshed config --progress-timeout 10 --staleness-timeout 48
# View group config
statshed group-config nightly-builds
# Update group config
statshed group-config nightly-builds --progress-timeout 15
Configuration File
The CLI reads configuration from these locations (in order of precedence):
- Path specified via
--configorSTATSHED_CONFIGenvironment variable ./statshed.yaml(current directory)~/.config/statshed/statshed.yaml/etc/statshed/statshed.yaml
Example configuration:
url: http://localhost:7828
output_format: table
color: auto
timeout: 10
submit:
syslog: false
strict: false
Environment Variables
STATSHED_URL: API server URLSTATSHED_CONFIG: Path to configuration fileNO_COLOR: Disable colored output
Exit Codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Health check returned unhealthy status |
| 2 | API error |
| 3 | Connection error |
| 4 | Timeout error |
| 5 | Configuration error |
| 10 | Invalid arguments |
| 11 | Resource not found |
Shell Completion
StatShed CLI provides shell completion for Bash, Zsh, and Fish. The completion includes:
- Command and option names
- Dynamic group name completion (queries the API)
- Dynamic job name completion (when group is specified)
- Status value completion (
success,error,progress)
Installation
Bash:
# Create the completions directory if it doesn't exist
mkdir -p ~/.local/share/bash-completion/completions
# Generate and install the completion script
statshed completion bash > ~/.local/share/bash-completion/completions/statshed
# Reload your shell or source the file
source ~/.local/share/bash-completion/completions/statshed
Zsh:
# Create the completions directory if it doesn't exist
mkdir -p ~/.zfunc
# Add to .zshrc if not already present:
# fpath+=~/.zfunc
# autoload -Uz compinit && compinit
# Generate and install the completion script
statshed completion zsh > ~/.zfunc/_statshed
# Reload completions
autoload -Uz compinit && compinit
Fish:
# Create the completions directory if it doesn't exist
mkdir -p ~/.config/fish/completions
# Generate and install the completion script
statshed completion fish > ~/.config/fish/completions/statshed.fish
Dynamic Completion
The shell completion queries the StatShed API to provide contextual suggestions:
- When completing group names (
--groupor group arguments), available groups are fetched from the server - When completing job names (
--job), jobs from the specified group are fetched - If the server is unavailable, completion falls back to basic suggestions
Set STATSHED_URL environment variable if your server is not at the default location:
export STATSHED_URL=https://statshed.example.com
Common Use Cases
CI/CD Pipeline (GitHub Actions)
jobs:
build:
steps:
- name: Report build start
run: |
statshed submit -g ci-builds -j "${{ github.repository }}" \
-s progress -m "Build started: ${{ github.sha }}"
- name: Build
run: make build
- name: Report build success
if: success()
run: |
statshed submit -g ci-builds -j "${{ github.repository }}" \
-s success -m "Build passed: ${{ github.sha }}"
- name: Report build failure
if: failure()
run: |
statshed submit -g ci-builds -j "${{ github.repository }}" \
-s error -m "Build failed: ${{ github.sha }}"
Cron Job Status Reporting
For safe use with set -eu (script exits on error), use the default lenient mode:
#!/bin/bash
set -eu
# Submit commands won't cause script to exit on API errors
statshed submit -g backups -j database -s progress -m "Starting backup"
# Do the actual backup
pg_dump mydb > /backups/mydb.sql
# Report success
statshed submit -g backups -j database -s success -m "Backup completed"
For manual error handling with strict mode:
#!/bin/bash
if ! statshed submit --strict -g backups -j database -s progress; then
echo "Warning: Could not report status to dashboard"
fi
pg_dump mydb > /backups/mydb.sql
backup_status=$?
if [ $backup_status -eq 0 ]; then
statshed submit -g backups -j database -s success
else
statshed submit -g backups -j database -s error -m "Backup failed with code $backup_status"
fi
Interactive Terminal Usage
# Check overall health with rich output
$ statshed health
# List groups with status summary
$ statshed groups
# Drill into a specific group
$ statshed jobs nightly-builds
# Check group-specific timeout configuration
$ statshed group-config nightly-builds
# Update group timeout (builds can take longer)
$ statshed group-config nightly-builds --progress-timeout 30
Script Integration with Error Logging to Syslog
Enable syslog logging for daemon/cron scenarios where stderr may not be monitored:
# ~/.config/statshed/statshed.yaml
url: https://statshed.example.com
submit:
syslog: true
syslog_facility: local0
Troubleshooting
Connection Refused
Error: Could not connect to http://localhost:7828: Connection refused
Cause: The StatShed backend is not running or is running on a different port.
Solution:
- Verify the backend is running:
curl http://localhost:7828/health - Check the URL with
--urlor in config file - Set
STATSHED_URLenvironment variable
Request Timeout
Error: Request to http://localhost:7828/health timed out after 10s
Cause: The server is slow or unresponsive.
Solution:
- Increase timeout in config file:
timeout: 30 - Check server health and load
- Enable retries:
retries: 3
Group/Job Not Found
Error: Group 'nonexistent' not found
Cause: The group doesn't exist in the database.
Solution:
- Groups are auto-created on first status submission
- Submit a status to create the group:
statshed submit -g newgroup -j newjob -s success
Invalid Configuration File
Configuration error: Invalid YAML in config file ...
Cause: The YAML config file has syntax errors.
Solution:
- Validate your YAML with a linter
- Check for proper indentation (spaces, not tabs)
- Ensure string values are properly quoted if they contain special characters
Shell Completion Not Working
Cause: Completion script not installed or shell not reloaded.
Solution:
- Regenerate the completion script for your shell
- Ensure it's in the correct location (see Shell Completion section)
- Reload your shell or source the script
Development
# Install development dependencies
uv sync --extra dev
# Run tests
pytest
# Run tests with coverage
pytest --cov=statshed_cli
# Format code
ruff format .
# Lint code
ruff check .
# Type check
mypy statshed_cli
Building a Debian Package
Building the Package
From the project root directory:
# Build the package (binary only, no source package signing)
dpkg-buildpackage -us -uc -b
# Or use debuild for a cleaner build environment
debuild -us -uc -b
The built .deb file will be placed in the parent directory (../).
Installing the Package
sudo dpkg -i ../statshed-cli_*.deb
# Install any missing dependencies
sudo apt install -f
Updating the Version
Before building a new release, update debian/changelog:
# Add a new changelog entry (interactive)
dch -i
# Or specify the new version directly
dch -v 1.0.3-1 "Description of changes"
## License
CC0-1.0 (Public Domain Dedication)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file statshed_cli-1.0.2.tar.gz.
File metadata
- Download URL: statshed_cli-1.0.2.tar.gz
- Upload date:
- Size: 49.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76313165f0310cb31c9a6fa92565fbab2d93306c0cd9db1d718092b65a9687bd
|
|
| MD5 |
e132ecce818307f5024246842cdaea39
|
|
| BLAKE2b-256 |
3d1b4b98dcaa4d8c9550f88623c3b4e4bd4689b7d47592f70f21fd8d6a63a0b8
|
Provenance
The following attestation bundles were made for statshed_cli-1.0.2.tar.gz:
Publisher:
release.yml on statshed/statshed-pycli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
statshed_cli-1.0.2.tar.gz -
Subject digest:
76313165f0310cb31c9a6fa92565fbab2d93306c0cd9db1d718092b65a9687bd - Sigstore transparency entry: 1682608326
- Sigstore integration time:
-
Permalink:
statshed/statshed-pycli@409c799c8e12f219fd6724f506d2ce43173efc39 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/statshed
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@409c799c8e12f219fd6724f506d2ce43173efc39 -
Trigger Event:
push
-
Statement type:
File details
Details for the file statshed_cli-1.0.2-py3-none-any.whl.
File metadata
- Download URL: statshed_cli-1.0.2-py3-none-any.whl
- Upload date:
- Size: 35.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cbef0b672b045655b40cb9676a59dbcad4325f762efd6f18c38e4523a2bcb1c
|
|
| MD5 |
07a50a2cece880cb7363ff4f64672107
|
|
| BLAKE2b-256 |
9130334c5eb72ec9f7de4073693c18db92c92073bc1fc157a8e8772aef11e5a0
|
Provenance
The following attestation bundles were made for statshed_cli-1.0.2-py3-none-any.whl:
Publisher:
release.yml on statshed/statshed-pycli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
statshed_cli-1.0.2-py3-none-any.whl -
Subject digest:
9cbef0b672b045655b40cb9676a59dbcad4325f762efd6f18c38e4523a2bcb1c - Sigstore transparency entry: 1682608329
- Sigstore integration time:
-
Permalink:
statshed/statshed-pycli@409c799c8e12f219fd6724f506d2ce43173efc39 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/statshed
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@409c799c8e12f219fd6724f506d2ce43173efc39 -
Trigger Event:
push
-
Statement type: