Skip to main content

Repeatedly synchronize local workspace with a (slow) remote machine

Project description

LiveSync

Repeatedly synchronize local workspace with a (slow) remote machine. It is available as PyPI package and hosted on GitHub.

PyPI version PyPI - Downloads GitHub commit activity GitHub issues GitHub license

Use Case

VS Code Remote Development and similar tools are great as long as your remote machine is powerful enough. But if your target is a Raspberry Pi, Jetson Nano/Xavier/Orin, Beagle Board or similar, it feels like coding in jelly. Especially if you run powerful extensions like Pylance, GitHub Copilot or Duet AI. LiveSync solves this by watching your code for changes and just copying the modifications to the slow remote machine. So you can develop on your own machine (and run tests there in the background) while all your changes appear also on the remote. It works best if you have some kind of reload mechanism in place on the target (NiceGUI, FastAPI or Flask for example).

Usage

BASH

livesync <source> <username>@<host>

LiveSync uses rsync (SSH) to copy the files, so the <username>@<host> must be accessible via SSH (ideally by key, not password or passphrase, because it will be called over and over).

Press CTRL-C to abort the synchronization.

Positional arguments:

  • <source> local folder
  • <target> target user, host and path (e.g. user@host:~/path; path defaults to source folder name in home directory)
  • <rsync_args> arbitrary rsync parameters after "--"

Options:

  • --ssh-port SSH_PORT SSH port on target (default: 22)
  • --on-change ON_CHANGE command to be executed on remote host after any file change (default: None)
  • --mutex-interval MUTEX_INTERVAL interval in which mutex is updated (default: 10 seconds)
  • --ignore-mutex ignore mutex (use with caution) (default: False)
  • --no-watch don't keep watching the copied folders for changes after the sync (default: False)

Python

Simple example (where robot is the ssh hostname of the target system):

from livesync import Folder, sync

sync(
    Folder('.', 'robot:~/navigation'),
    Folder('../rosys', 'robot:~/rosys'),
)

The sync call will block until the script is aborted. Only if watch=False is used, the sync call will end after copying the folders to the target once. The Folder class allows to set the port and an on_change bash command which is executed after a sync has been performed. Via the rsync_args build method you can pass additional options to configure rsync.

Advanced example:

import argparse
from livesync import Folder, sync

parser = argparse.ArgumentParser(description='Sync local code with robot.')
parser.add_argument('robot', help='Robot hostname')

args = parser.parse_args()

touch = 'touch ~/robot/main.py'
sync(
    Folder('.', f'{args.robot}:~/navigation', on_change='touch ~/navigation/main.py'),
    Folder('../rosys', f'{args.robot}:~/rosys').rsync_args(add='-L', remove='--checksum'),
    mutex_interval=30,
)

Notes

  • We suggest you have some auto-reloading in place on the (slow) target machine, like NiceGUI.
  • Only one user per target host should run LiveSync at a time. Therefore LiveSync provides a mutex mechanism.
  • You can create a .syncignore file in any source directory to skip additional files and directories from syncing.
  • If a .syncignore file doesn't exist, it is automatically created containing .git/, __pycache__/, .DS_Store, *.tmp, and .env.

Installation

python3 -m pip install livesync

Development

For development we suggest to use the following instructions instead of the normal pip installation:

git clone git@github.com:zauberzeug/livesync.git
cd livesync
python3 -m pip uninstall livesync # remove previous installed version
python3 -m pip install -e .

Now you can change the code and call the livesync command from your $PATH variable with the modified code.

Testing

We have build a small testing infrastructure with two docker containers. See tests/README.md for details.

Releases

Just create and push a new tag with the new version name (v0.2.1 for example). After a successful build a new release will be created. This should be edited to describe the changes in the release notes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

LiveSync-0.3.4.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

LiveSync-0.3.4-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file LiveSync-0.3.4.tar.gz.

File metadata

  • Download URL: LiveSync-0.3.4.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for LiveSync-0.3.4.tar.gz
Algorithm Hash digest
SHA256 1748c4b2ce7820a6307b0e984a2d7844d74fa8f4a0c4d8f0e6b9a05a3aea34bb
MD5 30b7d6e3be732fe38433e0cccacaadc8
BLAKE2b-256 bfd6fed2ee6f4b1ec828c8c5c4775d3d4384599dc4bc349416a67d3ba2ef312d

See more details on using hashes here.

File details

Details for the file LiveSync-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: LiveSync-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for LiveSync-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 aa6d529fc281a82b6640171f566b6c20b3d29edc3fb51cf5e1bbd5f2b13b448b
MD5 983dac245e33d647448ab964fa19f5fc
BLAKE2b-256 f4fec5bfc498121735833ad21bb1b65ad52daf913c9a18b71d672c71c38074c0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page