Data Hub

Roll out watcher releases

Publish watcher versions to PyPI, advertise them per environment, set a minimum version, force mandatory updates, roll the fleet back, and see what each version adds.

ForAdministrators

Watchers update themselves to the version you choose for each environment under Settings → Watchers, which also lists every watcher with its version. These docs describe watcher 1.4.0 and later. Install and update the watcher covers installing the watcher on one PC and updating it by hand with self-update.

How watchers update themselves

Every watcher checks for an update about once an hour, whether it runs as a Windows service or in a terminal. Each time, it does this:

  1. Asks Data Hub for Latest version and compares it with its own version
  2. Upgrades only if Latest version is newer and the watcher is idle: no uploads in the last 5 heartbeats, and no run reported within five times its stability period. Mandatory update skips the idle check
  3. Installs the new version and restarts. A Windows service restarts through the Windows setting that restarts it after a crash
  4. Records update_started, then update_succeeded or update_failed, which the watcher’s Activity tab shows as Update started, Update finished, or Update failed

Automatic updates are off in the preview environment, so a pull request’s preview deployment can’t install code on lab PCs.

Cut a new release

ForEngineers

An engineer publishes a release by tagging a commit on production, and an admin then makes it the version watchers update to.

Bump the version in watcher/pyproject.toml and merge through staging to production.

Tag and push from production:

git checkout production && git pull
git tag watcher-v1.4.6 && git push origin watcher-v1.4.6

Approve the pypi deployment under Actions → Publish watcher in GitHub.

In Settings → Watchers, pick the new version under Latest version. The list comes from PyPI, so a release shows up as soon as PyPI publishes it. If PyPI can’t be reached, you can type the version instead. Each environment has its own setting, so set staging first and production once it looks good.

datahub.example.com/settings/watchersSettings Watchers page with Latest version and release controls, above the list of all watchers

Save Latest version only after the new version is on PyPI. If you save it earlier, every watcher tries to update, fails, and records update_failed.

Release settings

FieldPurpose
Latest versionThe version watchers update to. Leave it blank to pause automatic updates.
Minimum supported versionOptional. A watcher older than this has its heartbeats rejected with 426 Upgrade Required, so it shows as unresponsive until it updates. It still checks for updates every hour, so it upgrades itself as long as Latest version is newer. Leave it blank for no minimum.
Mandatory updateMoves every watcher to Latest version at its next hourly check, without waiting until it’s idle, and also moves newer watchers back. See Mandatory updates. Has no effect while Latest version is blank.

Watch the rollout

Below the release form, the All watchers heading shows “N out of M on the latest version”. It’s green when every active watcher runs that version or a newer one, and amber while some are behind. The Version column shows each watcher’s version, and a watcher’s own page says Up to date, or Update available with the latest version. See Manage the watcher fleet.

Mandatory updates

Turning on Mandatory update makes every watcher move to Latest version at its next hourly check, even if it’s busy uploading. Without it, a watcher only upgrades to a newer version, and only once it’s idle.

A forced update in the middle of an acquisition can lose data, so keep Mandatory update for these cases:

  • A security fix
  • A change that stops older watchers from working with Data Hub
  • A rollback, or a bad version that does more harm running than a restart mid-upload would

Roll back

Watchers never move to an older version on their own, so a rollback needs Mandatory update:

If Minimum supported version is above the version you’re rolling back to, lower it first. Otherwise the rolled-back watchers can’t check in.

Set Latest version to the older version for each affected environment, and turn on Mandatory update.

Wait for the next hourly check, and watch the Version column in All watchers. The heading count treats a newer version as current, so it can read green before every watcher has moved back.

Turn Mandatory update off once every watcher runs the older version.

The newer version stays on PyPI, but Data Hub no longer offers it.

What each version adds

Some Data Hub features need a minimum watcher version. To turn a feature on for every PC, set Latest version to at least the version that adds it.

1.4.5

  • A file the watcher gives up on reads Upload failed, with the reason. That covers a requested file that isn’t on the instrument PC, for example because its run folder was renamed or moved, and a file whose upload failed three times
  • Data Hub records one Couldn’t upload event per run and reason, instead of one error per file
  • In auto mode, a file whose upload fails reads Upload failed at once, and the watcher tries it again the next time it starts
  • Files an auto-mode watcher is about to upload read Waiting to upload. Files it reports without uploading, such as the ones already on the PC after a settings change that matches more files, read Not uploaded

1.4.3

  • When the watch folder disappears while the watcher runs, for example because a network drive drops, the watcher goes back to Waiting: folder not found and starts watching again once the folder is back. Files waiting to upload aren’t dropped, and a network share that stops answering no longer freezes the watcher
  • A stop during start-up, including during the scan of a large folder, ends cleanly with a stopped status and event, for data-hub-watcher watch and for the Windows service
  • A watcher whose registration was deleted on Data Hub stops after three heartbeats in a row get that answer, about 3 minutes, and says to run data-hub-watcher init. watch exits with code 3, the Windows service stays stopped, and starting the watcher again is refused with the same message. Any other error doesn’t stop it
  • Heartbeat counts aren’t lost when a heartbeat fails
  • Events that haven’t been sent are kept across a restart, a crash, or a Data Hub outage, and sent afterwards. Events that Data Hub refuses, or fails to take three times in a row, are dropped, and an events_dropped event says how many
  • A file of 100 MB or more that changes while it uploads is uploaded as it is then, instead of failing
  • A file requested again right after its request was cancelled gets three new tries
  • A watcher that finds a run deleted on Data Hub records one event for it and leaves the run alone until it restarts, or until Data Hub accepts an upload someone requested for one of the run’s files

1.4.2

  • Once the watcher is running, a stop finishes within about 25 seconds, even when Data Hub isn’t answering. The watcher sends its events before its final heartbeat, and starts no new file or upload part once a stop is requested
  • A watcher that stops to install an automatic update tells Data Hub why, so files someone requested with Upload stay requested while it comes back. The Windows service hands each update to its upgrade task only once
  • The Windows service writes a config or env file it can’t load to watcher.log, and reads DATA_HUB_WATCHER_LOG_LEVEL from its env file
  • A file the instrument keeps open after its last write uploads once the instrument lets go of it. The watcher tries it every minute, and a request for it from the run page stays requested

1.4.1

  • Restarting or shutting down a Windows PC stops the watcher service cleanly. The watcher sends a final heartbeat, so it shows as Stopped, and files someone requested with Upload stay requested and upload once the PC is back. Data Hub cancels those requests if the watcher isn’t back within about 15 minutes; see When the PC restarts or shuts down
  • In auto mode, the files of a run reported just before a restart, a power cut, or a crash upload after the next start. Older watchers can leave them on Not uploaded; they can be uploaded from the run page
  • A run whose ID contains #, ?, or another character with a special meaning in a web address gets its own files. Older watchers send them to another run or don’t upload them

1.4.0

  • Admins can change the watcher’s settings from Data Hub. The watcher picks up a saved change within about a minute and applies it, or rejects it and keeps its current settings when a check fails, such as a folder that doesn’t exist
  • After a change that matches more files, the watcher reports the files already on the PC but doesn’t upload them
  • A watcher whose folder is missing at start-up keeps running and shows Waiting: folder not found, so the folder can be fixed from Data Hub

1.3.0 and earlier

These docs no longer describe watchers before 1.4.0. Update them to the latest version.

  • 1.3.0: a large file uploads several parts at once, and several requested files upload side by side, within the instrument.upload_parallelism setting. The watcher asks again for a part’s upload link after a connection or server error, and the file_uploaded event records the file’s size and upload times
  • 1.2.2: a run report that fails because Data Hub can’t be reached, or returns a server error, is retried until it goes through
  • 1.2.1: Upload works on instruments that upload automatically, and an automatic upload cut off by a restart or an update is retried at the next start, on up to three starts
  • 1.2.0: files of 100 MB or more upload in 64 MB parts, and files larger than 5 GB can upload
  • 1.1.0: when a run gathers files from several folders, every file with the same name is kept, and later copies get a short tag in the name, such as sample~3f9a1c2b.tif. Adds the data-hub-watcher state forget command

Files that a watcher before 1.1.0 skipped because of a duplicate name don’t upload on their own after the update. To upload them, stop the watcher, run data-hub-watcher state forget --prefix your_folder_name/ on the instrument PC, where your_folder_name/ is the folder in the watch folder that held the skipped files, and start the watcher again.

When an update fails on a PC

If update_started is followed by update_failed, or a watcher never updates, send the PC’s operator to Troubleshoot a watcher and Install and update the watcher.

On this page