Skip to main content

syft-bg

Background services for SyftBox: email notifications, running api calls, and approving peers.

Installation

pip install syft-bg

Python API docs — for python api docs, go here instead.

Quick Start

syft-bg init -e you@example.com          # Create config
syft-bg ensure-running notify approve    # Start services
syft-bg status                           # Check what's running

With custom settings:

syft-bg init -e user@example.com -r ~/SyftBox -t ~/token.json
syft-bg ensure-running notify approve

Python API

For notebooks and scripts, see the Python API docs.

Commands

syft-bg                        # TUI dashboard
syft-bg init -e <email>              # Create config
syft-bg ensure-running <services>    # Start services if not already running
syft-bg setup-status                 # Check environment (credentials, tokens, config)
syft-bg status                       # Show service status
syft-bg start [service]        # Start all or specific service
syft-bg stop [service]         # Stop all or specific service
syft-bg restart [service]      # Restart all or specific service
syft-bg logs <service>         # View logs (notify or approve)
syft-bg create-api             # Create an api
syft-bg remove-api             # Remove an api
syft-bg remove-peer            # Remove a peer from apis
syft-bg list-apis              # List apis
syft-bg install                # Install systemd service (auto-start on boot)
syft-bg uninstall              # Remove systemd service

Starting and Stopping Services

syft-bg start               # Start all services
syft-bg start notify        # Start a specific service
syft-bg stop                # Stop all services
syft-bg stop approve        # Stop a specific service
syft-bg restart             # Restart all services
syft-bg restart notify      # Restart a specific service

Use ensure-running to start services only if they aren't already running:

syft-bg ensure-running notify approve
syft-bg ensure-running notify approve --restart  # Force restart

Apis

An api is a job the data owner approved in advance, which peers call with their own arguments: client.api.<name>(...). A call sends only the arguments. The data owner's client adds the api's code, approves the call, and the approve service runs it, with the api's input and output policies. See docs/jobs.md.

Creating an api

Prefer building it from a job you have reviewed, with syft_bg.create_api_from_job(job). From the command line, an api pins run.sh and the rest of its code by content, and takes the files a call sends (such as the params JSON) by name. Paths are relative to the job submission root.

cd ./job   # a submission holding code/main.py, code/params.json, run.sh and config.yaml

syft-bg create-api code/main.py run.sh -b . -f code/params.json -p alice@uni.edu -n my_analysis

Managing apis and peers

syft-bg list-apis                 # list all apis
syft-bg list-apis -n my_analysis  # show one api
syft-bg remove-api my_analysis    # remove an api
syft-bg remove-peer alice@uni.edu # remove a peer from every api

CLI Flags for syft-bg init

Flag Description
--email, -e Data Owner email address
--syftbox-root, -r SyftBox directory path
--token-path, -t Path to OAuth token file

Environment Check

$ syft-bg setup-status

SYFT-BG ENVIRONMENT CHECK
==================================================

Checking credentials...
  ✓ credentials.json found at ~/.syft-bg/credentials.json

Checking authentication tokens...
  ✓ Gmail token: ~/.syft-bg/gmail_token.json
  ✓ Drive token: ~/.syft-bg/token_do.json

Checking configuration...
  ✓ Config file: ~/.syft-bg/config.yaml

--------------------------------------------------
✅ Environment ready! Run 'syft-bg start' to begin.

OAuth Setup

Two OAuth tokens are required (same credentials.json, separate tokens):

  1. Gmail → gmail_token.json (send email permission)
  2. Drive → drive_token.json (read/write files permission)

To get credentials.json:

  1. Go to Google Cloud Console → APIs & Services → Credentials
  2. Create OAuth 2.0 Client ID (Desktop app)
  3. Download as credentials.json
  4. Place at ~/.syft-bg/credentials.json

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)
  • A job is rejected (with reason sent to the data scientist)

DO notifications are threaded per job (new → approved/rejected → completed in one Gmail conversation).

approve

Runs api calls, and approves peers based on your config:

  • Peers: Auto-accept connection requests from approved domains, and from the peers of your apis
  • Jobs: Run api calls, which arrive approved. Jobs you approve by hand wait for you to run them

Configuration

Config stored at ~/.syft-bg/config.yaml (Colab: /content/drive/MyDrive/syft-creds/config.yaml).

do_email: you@example.com
syftbox_root: ~/SyftBox

notify:
  interval: 30
  monitor_jobs: true
  monitor_peers: true

approve:
  interval: 5
  jobs:
    enabled: true
    peers:
      alice@uni.edu:
        mode: strict
        scripts:
          - name: main.py
            hash: 'sha256:a1b2c3d4...'
          - name: utils.py
            hash: 'sha256:e5f6a7b8...'
      bob@co.com:
        mode: strict
        scripts:
          - name: main.py
            hash: 'sha256:c9d0e1f2...'
  peers:
    enabled: false
    approved_domains:
      - openmined.org

After editing, restart services:

syft-bg restart

Systemd Integration

Auto-start syft-bg on boot (Linux):

syft-bg install    # Creates ~/.config/systemd/user/syft-bg.service
systemctl --user enable syft-bg
systemctl --user start syft-bg

# Check status
systemctl --user status syft-bg

# Remove
syft-bg uninstall

Logs

syft-bg logs notify     # Notification service logs
syft-bg logs approve    # Approval service logs
syft-bg logs notify -f  # Follow logs in real-time

Log files stored at ~/.syft-bg/logs/.

Colab / Jupyter

See the Python API docs for programmatic usage. Drive credentials are handled natively in Colab.

Development

Run services in foreground for debugging:

syft-bg run-foreground --service notify   # Run notify in foreground
syft-bg run-foreground --service approve  # Run approve in foreground
syft-bg run-foreground --once             # Single check cycle, then exit

Metadata

Release files for syft-bg 0.3.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for syft-bg 0.3.13
File Size Uploaded Provenance Actions
syft_bg-0.3.13.tar.gz 75.5 kB Without provenance Details for syft_bg-0.3.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for syft-bg 0.3.13
File Interpreter ABI Platform Actions
syft_bg-0.3.13-py3-none-any.whl Python 3 none any Details for syft_bg-0.3.13-py3-none-any.whl

Total release size: 187.4 kB

Release files / syft_bg-0.3.13.tar.gz

Download URL syft_bg-0.3.13.tar.gz
Size 75.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a7a6a3127e2b5703ee500e9897e87b87b11a1d1c27b17c374806363a0fbf24d6
BLAKE2b-256 checksum
How to use checksums
e3c8822d87aa539cd325cc9e963a91b16203c839ce136c6cc0663eaa31f8d2d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / syft_bg-0.3.13-py3-none-any.whl

Download URL syft_bg-0.3.13-py3-none-any.whl
Size 112.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66cbcaab4e827446185fd5ba2cb85bc8310fa78a76e59af04277683dd52562f8
BLAKE2b-256 checksum
How to use checksums
09b14a16e26615c4ca30035940f01b6c267d2d5d96a3eec95fa40f9fb9f34322
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for syft-bg 0.3.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page