Notebook connectors#
A connector is a plugin that adds a destination: a place NucleI can deliver a report, the scan data and a result description to, such as an electronic lab notebook (ELN). This page is for the administrator who installs the plugin and for the plugin author. Users send results from the Report Builder and the Task Manager.
Available connectors#
| Connector | Server | Notes |
|---|---|---|
| eLabFTW | Self-hosted or hosted eLabFTW, API v2 | Open source with a documented REST API. Delivers to a new or an existing experiment. |
The eLabFTW plugin is the elabftw plugin. Install it from the plugin manager like any other plugin. Nothing changes in the app until a plugin provides a destination: no Send to entry is shown while none is installed.
Set up eLabFTW#
- In eLabFTW, open Settings → API keys, create a key with Read/Write access and copy it.
- In NucleI, open Settings → Destinations and find eLabFTW. The connection is set up once here.
- Enter the Server address, for example
https://eln.example.org. A path is kept, sohttps://example.org/elabworks. - Paste the key into API key and press Save key. The field is cleared; the key is not shown again.
- Press Test. NucleI asks the server who the key belongs to and shows the account name.
- Press Choose to pick New experiment or an existing experiment. Leave it empty to create a new experiment each time.
- Send from the menus: Send to eLabFTW from the arrow next to Generate in the Report Builder, Share in the Data Browser (see below), or After the run → Send to on the acquisition page, or Destinations in an Export Results step or a batch report. They start from the connection saved in Settings; the send dialog shows it with a Change link.
Administrators can set the server and a default target for every user in the machine policy file. A locked entry makes those fields read-only; users still enter their own API key. See Result destinations.
Allow the plugin to reach the server#
A plugin can only reach hosts it has been granted. The first attempt to send to a new server is refused and the host appears in the plugin manager's pending requests; allow it there. A plugin whose signed capabilities already name the host needs no grant.
Where the key is kept#
The key is stored encrypted in the profile and is bound to the server address it was saved for. It is added to requests for that server only, over https or to the same computer. It is never written to a schedule, a settings file or a log, and the plugin never receives it. Changing the server address to another origin makes the stored key unusable until it is saved again for that address. Use a separate key per user, with the access you want NucleI to have.
Send scans without a report#
Send to eLabFTW is also offered under Share in the Data Browser, next to Share with Connect users…, and nothing is shown while no destination is installed:
- the Export menu of a scan (the Export button, or right-click a scan → Export scan…);
- right-click a project, group, sample or scan → Share → Send to eLabFTW, which sends each of its scans;
- the selection bar, after selecting two or more scans → Share → Send to eLabFTW;
- automatically: on the acquisition page, After the run → Send to → eLabFTW, or the Send to column of an experiment row in the Task Manager queue. Each scan the run saves is sent in the background, one at a time, and a failure shows a notification. Imported and reprocessed scans are not sent.
Each scan is delivered separately with its .nuclei file, peaks.csv and a result.json describing the scan, as for Export Results. No report is made, so the dialog does not ask for a format. The scan file is always sent here, whatever Include scan data was last set to.
What is delivered#
Each delivery carries:
| File | Role | When |
|---|---|---|
| The report (PDF or DOCX) | report |
Always from the report menu and batch reports; from Export Results when Report is ticked. |
The scan, as a .nuclei file |
scan |
When Include scan data is ticked; always when scans are sent without a report. |
peaks.csv |
peaks |
From Export Results when Peak table is ticked; always when scans are sent without a report. |
result.json |
metadata |
Always. From Export Results it is the run-result document; from reports it describes the report, project, operator and scans; for scans sent without a report it is the same document as for Export Results, without the run. |
For eLabFTW, a new experiment gets the title and a short summary, and every file is uploaded as an attachment with a comment naming its role. Sending to an existing experiment only adds attachments; its title and text are left as they are. Sending again adds the files again.
Each delivery is recorded in the audit log with the destination, server, target, file roles, a SHA-256 of the content and the outcome.
Writing a connector#
A connector is a class registered with @result_destination. It implements three methods and is given a connection to the user's server that adds the secret itself.
from nuclei_backend_stubs.plugin_system import result_destination
from nuclei_backend_stubs.plugin_system.destination_contract import (
DeliveryPayload, DeliveryReceipt, DestinationContext, DestinationError,
DestinationTarget, MultipartFile, ResultDestination,
)
@result_destination
class MyNotebook(ResultDestination):
destination_id = "my_notebook"
name = "My notebook"
credential_headers = ("Authorization",) # secret headers the user supplies
def authenticate(self, ctx: DestinationContext) -> str:
return ctx.http.request("GET", "/api/me").json()["name"]
def list_targets(self, ctx, parent_id="", query=""):
rows = ctx.http.request("GET", "/api/entries", query={"q": query}).json()
return [DestinationTarget(str(r["id"]), r["title"]) for r in rows]
def deliver(self, ctx, target_id, payload: DeliveryPayload) -> DeliveryReceipt:
for file in payload.files:
ctx.http.request("POST", f"/api/entries/{target_id}/files",
files=[MultipartFile("file", file.name, file.data, file.media_type)])
return DeliveryReceipt(url=f"{ctx.settings['server_url']}/entries/{target_id}", remote_id=target_id)
| Part | Contract |
|---|---|
authenticate(ctx) |
Returns the account or server name, or raises DestinationError. |
list_targets(ctx, parent_id, query) |
Returns DestinationTarget(id, name, has_children, selectable) entries beneath parent_id (empty for the top level). |
deliver(ctx, target_id, payload) |
Uploads payload.files (DeliveryFile with role, name, media_type, data) and payload.metadata; returns a DeliveryReceipt with the link. target_id is empty when the user chose none. |
ctx.settings |
The user's non-secret settings, including server_url, plus any fields the destination declares. |
ctx.http.request(method, path, ...) |
Sends a request to the user's server. path begins with /; JSON, raw bodies and multipart forms are supported. Redirects are returned, not followed. The secret is added by NucleI. |
DestinationError(message, key=...) |
The message is shown to the user; key names a translation when the application has one. |
A connector cannot open other connections and cannot read the secret. Connectors run in the plugin's sandbox like other plugins and need the same host grant.