syft-bg provides background services for SyftBox that handle email notifications and automatic approval of peer requests and job submissions. It includes a TUI dashboard, CLI commands, and a Pythonic API.
Installation
When to Use
Usesyft-bg when you need to:
- Receive email notifications for peer requests, job submissions, and job completions
- Automatically approve peer connection requests from trusted domains
- Automatically approve job submissions based on script hash and filenames
- Monitor SyftBox activity in real-time with a TUI dashboard
- Run SyftBox services as a background daemon
Quick Start
CLI Commands
syft-bg
Launch the TUI dashboard to monitor services interactively.syft-bg init
Interactive setup wizard or headless initialization.| Flag | Description |
|---|---|
--email, -e | Data Owner email address |
--syftbox-root | SyftBox directory path |
--yes, -y | Auto-confirm config overwrite |
--quiet, -q | No prompts, use defaults (implies —skip-oauth) |
--skip-oauth | Skip OAuth setup (tokens must exist) |
--notify-jobs/--no-notify-jobs | Job email notifications |
--notify-peers/--no-notify-peers | Peer email notifications |
--notify-interval | Notification check interval (seconds) |
--approve-jobs/--no-approve-jobs | Auto-approve jobs |
--jobs-peers-only/--no-jobs-peers-only | Only approve jobs from approved peers |
--approve-peers/--no-approve-peers | Auto-approve peers |
--approved-domains | Comma-separated domains for peer approval |
--approve-interval | Approval check interval (seconds) |
--filenames | Required filenames (comma-separated) |
--allowed-users | Allowed users (comma-separated emails) |
--credentials-path | Path to credentials.json |
--gmail-token | Path to existing Gmail token |
--drive-token | Path to existing Drive token |
syft-bg setup
Check environment for credentials, tokens, and configuration.syft-bg status
Show the status of background services.syft-bg start
Start all or specific background services.syft-bg stop
Stop all or specific background services.syft-bg restart
Restart all or specific background services.syft-bg logs
View logs for a specific service.syft-bg hash
Generate SHA256 hash for a script file (for auto-approval configuration).syft-bg install
Install systemd service for auto-start on boot (Linux only).syft-bg uninstall
Remove systemd service.syft-bg run
Run services in foreground for debugging.Pythonic API
Usesyft-bg from Python scripts or Jupyter notebooks.
Service Manager
Configuration
Configuration is stored at~/.syft-creds/config.yaml (or /content/drive/MyDrive/syft-creds/config.yaml in Colab).
Services
notify
Sends email notifications via Gmail when:- A peer requests to connect with you
- Your peer request is approved by someone
- A data scientist submits a job to you
- A job you submitted is approved
- A job completes (results ready)
approve
Auto-approves peers and jobs based on your configuration. Peer Auto-Approval: Auto-accept connection requests from trusted domains:OAuth Setup
Two OAuth flows are required:- Gmail →
gmail_token.json(send email permission) - Drive →
token_do.json(read/write files permission in Colab)
Getting credentials.json
- Go to Google Cloud Console → APIs & Services → Credentials
- Create OAuth 2.0 Client ID (Desktop app)
- Download as
credentials.json - Place at
~/.syft-creds/credentials.json
Interactive OAuth Flow
Headless Mode
Script Hash Validation
Restrict auto-approval to specific scripts by hash:config.yaml:
Systemd Integration
Auto-start syft-bg on boot (Linux):Logs
Logs are stored at~/.syft-creds/logs/:
Colab / Jupyter Usage
Dependencies
click>=8.0.0- CLI frameworkpyyaml>=6.0- Configuration parsingtextual>=0.40.0- TUI frameworkjinja2>=3.1.0- Email templatesgoogle-api-python-client>=2.95.0- Google API clientgoogle-auth>=2.22.0- Google authenticationgoogle-auth-oauthlib>=1.0.0- OAuth flowsyft-job- Job system integration
Related Packages
- syft-job - Job submission system