N.I.N.A. Sync Plugin

The PSF Guard Sync plugin connects N.I.N.A. and its Target Scheduler catalog to a PSF Guard server. It uploads saved lights and calibration frames, pushes scheduler captures, pulls plans and reviewed grades back, and syncs Target Scheduler's flat coverage, without copying database files by hand.

Optional connection for a server or NAS. If you use N.I.N.A., this plugin is the recommended way to exchange data with your PSF Guard server. With Target Scheduler, you can also sync plans and grades while Target Scheduler runs the captures. The upcoming Director plugin is separate and in early beta.

Install the plugin

PSF Guard hosts a N.I.N.A. plugin repository. Add it once, and the plugin installs and updates from within N.I.N.A.:

  1. In N.I.N.A., open Options → General. Under Plugin Repositories, click + and add this URL:
    https://nina-plugins.psf-guard.com/
  2. Open Plugins → Available, find PSF Guard Sync, install it, and restart N.I.N.A.
The plugin needs Windows x64, N.I.N.A. 3.2.0.9001 or newer in the 3.2 line, and PSF Guard 0.9.0 or newer, the first release that pairs. Flat-coverage sync needs PSF Guard 0.9.6 or newer. Catalog sync needs a separate Target Scheduler installation with schema 22 or newer. Direct image uploads do not need Target Scheduler. The repository lives at nina-plugins.psf-guard.com.

Pair N.I.N.A. with a catalog

For a new catalog in 0.12, open Settings → Databases → Import from Target Scheduler and choose Use the PSF Guard Sync plugin. Add a shared image folder or an empty folder for uploads, then click Create catalog for plugin. The pairing controls open automatically; no local TS database file is required. For an existing catalog, click its Edit button instead.

Generate a one-use pairing code for the newly created plugin catalog.
Generate a fresh code for each client. This example uses a disposable test catalog.
  1. In PSF Guard, open Settings → Databases and edit the destination catalog.
  2. To receive image files, tick Accept remote image uploads, choose a Receive directory from the catalog's image folders, and pick a Folder layout: Receive directory keeps every upload in that folder; Match catalog files each one into folders laid out like the rest of the catalog. Save the catalog.
  3. Click Generate pairing code under Connect PSF Guard Sync in N.I.N.A., and copy the code.
  4. In N.I.N.A., open Plugins → Installed → PSF Guard Sync. Enter the Server URL, paste the code into One-time pairing code, and click Pair. The server returns the catalog ID, shown under Catalog ID, and a credential for this N.I.N.A. profile.
  5. Click Test connection, then choose what to upload and sync.

A remote server needs an https:// URL. Plain http:// works only for a loopback address such as http://127.0.0.1:3000.

A pairing code works once and expires after an hour. Each pairing makes its own catalog-scoped credential: the server keeps only its digest, and the plugin keeps it in Windows Credential Manager and never shows it. A pairing belongs to one N.I.N.A. profile and one server URL; change either and pair again. Pairing turns on scheduler sync for the catalog. It does not turn on image uploads or choose the receive directory.

Paired clients, in the same editor, lists each paired profile by machine and profile name. Revoke cuts off one and leaves the others alone.

Only editors can generate pairing codes or revoke clients. In Settings they sit in the catalog's editor, which needs database management because it lets you set the catalog's folders. See Server Accounts.
PSF Guard Sync settings in N.I.N.A., showing the server URL, pairing controls and capture automation options.
Enter the server URL and pairing code under Connection. This example profile has not been paired. From the Sync plugin repository, version 0.4.0.17.

Recover a lost pairing

Pairing status reads Paired when the profile is ready. Two other states need a new code:

Reset pairing clears this profile's credential and catalog. It keeps the server URL, the other settings and the queued jobs. Pairing again with the same catalog restores its queue; click Retry blocked to resume blocked jobs. Pairing with another catalog does not move the old catalog's jobs to it. Pair stays clickable while no manual operation runs; a missing code or a bad URL shows an error in the status area.

Use a manual API key

The plugin only pairs; it has no field for a manual key. A manual key serves other clients, such as another PSF Guard:

  1. Edit the catalog and click Generate beside Remote API key. Copy the key now: it is not shown again after saving.
  2. Tick Accept remote scheduler sync, and Accept remote image uploads to receive files. Save the catalog.
  3. Give the client the server URL and the key. If it asks for the catalog ID, copy it from the database list or its ?db= URL.

A new manual key replaces only the previous manual key. Paired clients keep working, and revoking a paired client leaves the manual key alone.

How the plugin works

The plugin listens for N.I.N.A.'s image-saved events and has two capture paths. Direct image mode queues the saved FITS or XISF file for upload. Target Scheduler mode waits for the matching acquiredimage row, then queues a bundle with the capture metadata, project, target and plan. Network work runs in the background and never holds up N.I.N.A.'s image save. If the server is offline, the plugin keeps the queue and retries later.

What the server does with an upload

Review staged catalog changes

Each catalog push makes a preview on the server before anything changes. Settings → Sync → Staged previews lists them, including those from remote N.I.N.A. installations, with the catalog, operation, source, change counts and expiry. Expand What would change for the field changes and grade transitions, up to 400 lines.

Nothing changes until a preview is applied. With Apply remote previews automatically on in the plugin, the plugin applies each preview at once. Otherwise most pushes wait until you apply the preview, discard it, or it expires after 30 minutes. Sequencer reconcile instructions and the PSF Guard target sync trigger always apply their previews, even with automatic apply off.

Configure the plugin

After pairing, set the rest in Plugins → Installed → PSF Guard Sync. Settings belong to the active N.I.N.A. profile, and every capture automation option starts off.

  1. Tick Enable PSF Guard for this N.I.N.A. profile. Automatic work and the sequencer instructions need it.
  2. Under Saved-image automation, choose any of Automatically push saved light records, Automatically upload saved images for lights, and, below it, Also upload calibration frames for bias, darks, dark-flats and flats.
  3. Set the Target Scheduler database. The default is %LOCALAPPDATA%\NINA\SchedulerPlugin\schedulerdb.sqlite.
  4. Leave Apply remote previews automatically on to apply each catalog preview at once, or turn it off to review previews in PSF Guard. Sequencer reconciliation always applies its preview.
  5. Tick Include Target Scheduler thumbnails to send thumbnails. Tick Pull the merged catalog back after full reconcile to download the merged catalog, without thumbnails, after PSF Guard applies a full reconcile, and merge it into Target Scheduler.

Click Test connection before turning on automatic work. It checks the server URL, the stored credential and the catalog. With automatic image upload on, it also checks that the catalog accepts uploads.

Pairing does not enable capture automation. Turning off the profile's enable switch stops new automatic work and sequencer sync, but queued transfers can resume when N.I.N.A. starts. To stop local transfers, close N.I.N.A.; to block the paired client's access, revoke its pairing in PSF Guard. Manual commands remain available while profile automation is off.

PSF Guard Sync settings in N.I.N.A., showing queue recovery, Target Scheduler database settings, catalog actions and activity.
Set the Target Scheduler database and review the catalog options before running a transfer. From the Sync plugin repository, version 0.4.0.17.

Hold image uploads

Defer image uploads until released stores each image upload without sending it. Target Scheduler records still sync at once. To send the held uploads for this profile's server and catalog, click Start queued uploads, or run Start PSF Guard uploads at the end of a target or session. The release covers uploads queued before it and does not wait for them to finish; later captures wait for the next release. Keep each FITS or XISF file at its path until its upload finishes.

Run catalog actions by hand

Back up the Target Scheduler database before your first pull. Pulling the full catalog can change capture records as well as plans and grades.

Use the sequencer instructions

The plugin adds a PSF Guard Sync category to N.I.N.A.'s advanced sequencer. Every item needs Enable PSF Guard for this N.I.N.A. profile and a paired profile. All but Check PSF Guard connection, Start PSF Guard uploads and PSF Guard image upload also need a Target Scheduler database.

InstructionWhat it does
Check PSF Guard connectionChecks the server URL, credential and catalog. Place it near the start; an offline server triggers the instruction's error handling.
Start PSF Guard uploadsReleases held image uploads and reports how many, without waiting for them. Place it at the end of a target or session.
Pull PSF Guard planningPulls projects, targets, templates and exposure plans into Target Scheduler. Run it before a Target Scheduler container starts, since a running container may not reload plans from disk.
Push PSF Guard planningSends Target Scheduler's projects, targets, templates and plans, and waits for the preview or its apply.
Pull PSF Guard gradesPulls reviewed grades and reject reasons, matched by image GUID, and recounts accepted frames per plan. It also syncs flat coverage; see below.
Push PSF Guard gradesSends reviewed Target Scheduler grades and reject reasons, and waits for the preview or its apply.
Reconcile PSF Guard catalogUploads a full Target Scheduler snapshot, waits for the preview, and applies it even when automatic apply is off. Use it at the end of a session. With pull-back on, it then pulls the merged catalog back.
Reconcile current target with PSF GuardReconciles the current target's project, plans, captures and optional thumbnails. Place it near the end of the target's container. The plugin refuses a name that matches more than one Target Scheduler target, ignoring case.
TriggerWhat it does
PSF Guard target syncReconciles the current target after a set number of completed light exposures. The count restarts when the target changes.
PSF Guard exposure syncWaits for the save and the Target Scheduler row, then pushes that one capture and its parent records. Its Upload image switch then uploads the file, or holds it when uploads are deferred.
PSF Guard image uploadWaits for the save, then uploads the light or calibration frame, or holds it when uploads are deferred. Its Upload lights and Calibration switches save with the sequence, so it works without profile-wide uploads or Target Scheduler. A file a profile-wide upload already queued is not sent twice.

Reconcile instructions and PSF Guard target sync wait two seconds for Target Scheduler's last write, take one read-only snapshot, and wait until the server applies the preview, even with automatic apply off. Per-capture pushes from Automatically push saved light records carry on in the background queue and retry on errors; turn that setting off when a trigger should be the only catalog sync. To sync and upload the same light from a sequence, use PSF Guard exposure sync with Upload image, not two separate triggers, so the row reaches PSF Guard before the file.

Sync Target Scheduler flat coverage

Pull grades, Pull PSF Guard grades and every applied reconcile send Target Scheduler's flat history to the paired catalog. They also remove the coverage rows you invalidated in PSF Guard:

  1. In PSF Guard, open the Calibration page from the header, or Open Calibration under the catalog in Settings → Databases, and choose Scheduler flats.
  2. Select the suspect coverage records, enter a Reason, and click Invalidate coverage. It needs an editor.
  3. Run Pull PSF Guard grades before the next Target Scheduler flats instruction. Target Scheduler then sees those flats as missing and can take them again under its usual rules.
Select scheduler records to invalidate, then give a reason. This confirmation was canceled.
Select scheduler records to invalidate, then give a reason. This confirmation was canceled.

Recover refused uploads

PSF Guard refuses uploads for a deleted project or a removed reject and explains how to recover. A plugin version with this support holds the upload without retrying; older versions show a blocked job. Another capture that shares the same file name can still upload.

  1. In PSF Guard, allow the deleted project back or restore the rejected frame.
  2. In the plugin settings, choose Retry refused uploads.

To stop trying to upload those files, choose Forget refused uploads. This removes the held queue entries; image files stay on disk. Sending project deletions to the rig also needs a plugin version with project deletion support.

Fix common problems

ResultCheck
Pairing code is unknown, expired, or already usedGenerate a new code on the destination catalog. A code works once, for one hour.
Pair reports an errorEnter the code and a full server URL. A remote server needs https://; http:// works only for loopback.
Credential missing; pair with a new codeThe credential left Windows Credential Manager. Pair with a new code, then click Retry blocked. See Recover a lost pairing.
401 or “Bearer token required”The plugin has no saved credential, or its client was revoked. Pair with a new code and run Test connection.
403 invalid key or wrong catalogCredentials belong to one catalog. Click Reset pairing and pair with a code from the intended catalog.
403 scheduler sync disabledTick Accept remote scheduler sync on that catalog. Upload permission alone does not grant catalog sync.
Image upload unavailableTick Accept remote image uploads and choose a Receive directory. Pairing does not turn uploads on.
404 under /api/sync/v1Upgrade PSF Guard to 0.9.0 or newer. For a preview, a 404 can also mean its 30 minutes ran out or it was already applied.
“Flat coverage was not synced”Upgrade PSF Guard to 0.9.6 or newer. Catalog sync still works.
Reconcile refuses the thumbnailsThey pass 256 MiB. Turn off Include Target Scheduler thumbnails, or reconcile one target.
Current-target reconcile refuses the targetTarget Scheduler has more than one target with that name. Give each a unique name.
Large preview times out at a proxyUpgrade the plugin and server, so the plugin starts a background preview job and polls it.
“Bundle digest is missing or invalid”Upgrade both, so pulls check the raw response against X-Content-SHA256 instead of re-serializing the JSON.
Queued work does not drainRun Test connection, check that N.I.N.A. reaches the server URL, and leave the plugin running. Blocked jobs wait for Retry blocked; held uploads wait for Start queued uploads.
To sync two SQLite files, or two PSF Guard servers, without the plugin, use Rejects & Sync.

More projects from theatr.us