Skip to content

Localizing baseband events on CANFAR

This is how to run the baseband localization pipeline on CANFAR for any number of events. You queue the events; Workflow starts the CANFAR sessions, runs the pipeline for each event, and cleans up afterwards. You don't spawn containers or deploy a YAML file per event.

It replaces the manual steps in CANFAR: running the baseband localization pipeline (spawning sessions with canfar.sessions.Session, then deploying a per-event config).

How it works

A single static config, baseband-localization-canfar (baseband_analysis/pipelines/cluster/canfar_localization_static.yaml), describes what to do for one event. Each event you queue becomes one run of it:

complete-localization: cluster-cli complete-localization --event-number <event> --site canfar --pull-dataset --tiedbeam-jobs 4 --files-per-group 1, in one CANFAR session (16 cores, the most CANFAR offers one session, and 40 GB):

  1. Pulls the raw data with datatrail (dtcli.workflow.pull_dataset, as datatrail pull chime.event.baseband.raw <event>) into /arc, then checks that every file is there. Files already on /arc aren't downloaded again, so an event staged beforehand (see Staging raw data) starts computing straight away.
  2. Runs initialize, refinement, localization, singlebeam and finalize, reading the raw data from /arc and writing everything else under /arc. Finalize uploads the results to frb-master.

A Work can change where the raw data comes from (see Parameters a Work can set): raw_dir: /scratch pulls the whole event into the session's local disk, which is faster to read (3.7 GB/s against 68 MB/s for one stream from /arc, 2026-11-01) and removed with the session; pull_dataset: false reads what's on /arc without calling datatrail. Datatrail deletes raw data on /arc after 60 days. Reading from /arc didn't slow the localization down: event 1182306499, staged first with datatrail-stage (632 files in 11 minutes), took 2 h 07 min end to end on v1.15.0, with refinement in about 66 minutes (2026-11-19).

The tiedbeam stages run as 4 processes at once (tiedbeam_jobs: 4), each on every 4th file, one file at a time (files_per_group: 1). They are limited by computing, not by reading the data, and each process does most of its work on one core, so this makes refinement about 2.4 times faster: 78 minutes instead of about 3 hours (tests on 2026-11-02). The 4 processes peak at about 30 GB of the session's 40. All sessions pull from CADC through the same link, about 300 MB/s in total, so when many events start together each pull takes longer (one alone took 11 minutes, four at once about 50 minutes each).

Workflow starts a fresh CANFAR session for the step and removes it when the step ends. Up to concurrency events (20) run at once; the rest wait in the queue, in order.

Staging raw data

To have an event's raw data on /arc before it's localized, for example to stage many events over a weekend, queue it on the static config datatrail-stage (canfar_datatrail_stage_static.yaml). It runs datatrail pull chime.event.baseband.raw <event> into /arc in a small session (4 cores, 8 GB), up to 4 events at once since all pulls share the same link:

Python
from workflow.definitions.work import Work

for event in [254781953, 254781954]:
    Work(
        pipeline="datatrail-stage",
        site="canfar",
        user="<your name>",
        event=[event],
        parameters={"event_number": event},
    ).deposit(return_ids=True)

Queuing an event for localization doesn't need it: the localization pulls whatever isn't on /arc yet.

Localizing events

You need workflow-core (pip install workflow-core) with the CHIME/FRB workspace active:

Bash
workflow workspace set chimefrb

Queue one event per Work. pipeline is the config's name, and parameters holds the event number for the pipeline steps:

Python
from workflow.definitions.work import Work

events = [254781953, 254781954, 254781955]

for event in events:
    work = Work(
        pipeline="baseband-localization-canfar",
        site="canfar",
        user="<your name>",
        event=[event],
        parameters={"event_number": event},
    )
    ids = work.deposit(return_ids=True)
    print(event, ids[0])

Note that the event number is given twice: event labels the item in Workflow, and parameters.event_number is what the steps use. Without parameters.event_number the item fails straight away with Static config baseband-localization-canfar requires parameters this Work doesn't give: event_number. ....

To have an event processed before others already in the queue, give it a higher priority (1 to 5, default 3), e.g. Work(..., priority=5).

Checking progress

The quickest view is workflow-web's Static Pipelines page: https://frb.chimenet.ca/workflow/web/CHIMEFRB/static-pipelines/baseband-localization-canfar. It shows whether the config is taking events, how many are queued and running, and a grid with one column per event and one row per step, colored by status. Click a square to see that step's details and its session logs; "Full logs" opens all of them.

What Where
Is the config taking events, how many are queued or running, how many succeeded https://frb.chimenet.ca/workflow/pipelines/v3/static_configs/baseband-localization-canfar/status
Is CANFAR reachable https://frb.chimenet.ca/workflow/pipelines/v3/health
Each event's pipeline, its steps and their session logs workflow-web Static Pipelines
A step's complete session logs /data/chime/intensity/processed/workflow/logs/baseband-localization-canfar/<pipeline id>/ on the frb-archiver, one file per step
Results of each step workflow-web Results, pipeline baseband-localization-canfar-localize
Localization products and per-stage logs /arc/projects/chime_frb/data/chime/baseband/processed/YYYY/MM/DD/astro_<event>/ (logs in logs/)
Final localization frb-master: master.events.get_event(<event>)["measured_parameters"]

The status endpoint returns, for example:

JSON
{
  "name": "baseband-localization-canfar",
  "concurrency": 20,
  "intake": "accepting",
  "intake_reason": null,
  "sites": { "canfar": "ok" },
  "queued": 14,
  "running": [
    { "id": "...", "associated_id": "254781953", "current_stage": 1 }
  ],
  "counts": { "running": 2, "success": 31, "failure": 1 }
}

The queued Work you deposited ends with the status of its event's pipeline (success or failure).

For operators, the managers' logs (docker service logs workflow_managers_v2) have every line for an event prefixed with its identifiers, e.g. [config=baseband-localization-canfar pipeline=<id> work=<queued Work id> event=254781953 stage=1 ...]. Grep for event=<event> or pipeline=<id>.

When something goes wrong

What you see Why What to do
Item failed with ... requires parameters this Work doesn't give: event_number The Work had no parameters.event_number Queue it again with the parameter
Step failed: CANFAR session ... stayed Pending longer than 3600s CANFAR couldn't start a 16-core session within an hour (busy) Queue the event again later
Step failed with Task ... was error/failed The session or the command failed Read the step's session logs (click it on the Static Pipelines page) and the per-stage logs on /arc
intake: paused, intake_reason: canfar is down: ... CANFAR's API isn't answering Nothing: events stay queued and start when CANFAR is back
Step failed: CANFAR unreachable for ...s ... assuming its compute stopped CANFAR was unreachable during the run (5 min before the step started computing, 1 h while computing) Queue the event again
Step failed with Task ... was failed, the logs ending at - Loading without an error The session ran out of memory (40 GB) loading a group of files, e.g. with files_per_group of 16 or more Keep files_per_group at 1 with tiedbeam_jobs: 4, or 2 with one job
Step failed early with a datatrail error datatrail couldn't pull the data (e.g. not yet replicated to CANFAR) Check in datatrail that the event's raw data is available at CANFAR, then queue again
Step failed: Could not start deployment canfar-localize ... CANFAR doesn't list the image tag for headless sessions (not labelled headless, a typo in version, or labelled only minutes ago) Check the tag (see Rolling out a new image), then queue the event again

Failed events aren't retried automatically, because each attempt starts new 16-core sessions. Re-queue them with the same snippet.

If CANFAR is down for more than about a week, events that were queued for more than 7 days are marked failed by Buckets' stale-work audit and need queuing again.

Changing the pipeline

There are two ways to change how events run:

  • For one event, in the Work you queue: the image version is a parameter of the config, and a Work can override it. Nothing else changes, and other events don't see it.
  • For every event from now on, by updating the config: edit canfar_localization_static.yaml and PUT it.

Try a change on one event first, then make it the default.

Parameters a Work can set

Parameter Default (config's parameters) What it does
event_number none (required) The event to localize
version v1.16.0 The image tag: the steps run on baseband-analysis:<version>
raw_dir "" (/arc) Where the raw data is pulled to and read from; /scratch for the session's local disk
pull_dataset true false reads what's already in raw_dir without calling datatrail
fast true false runs the production code paths; images before v1.16.0 need false

A Work's parameters override the defaults for that event only, e.g.:

Python
Work(
    pipeline="baseband-localization-canfar",
    site="canfar",
    user="<your name>",
    event=[event],
    parameters={"event_number": event, "version": "v1.15.0", "fast": False},
).deposit()

Each event's pipeline records the image it ran on, in its deployments:

Python
import httpx, json

r = httpx.get(
    "https://frb.chimenet.ca/workflow/pipelines/v2/configs",
    params={
        "database": "pipelines",
        "name": "baseband-localization-canfar",
        "query": json.dumps({"associated_id": str(event)}),
        "length": 1,
    },
)
item = r.json()[0]
print(item["status"], item["deployments"][0]["image"])  # e.g. success baseband-analysis:v1.15.0

If a Work leaves out a parameter with no default, the event fails straight away, saying which parameters are missing and which ones are optional.

Anything else (resources, concurrency, other complete-localization options) is fixed in the config. To vary it per event, add it to the config's parameters and use ${{ work.parameters.<key> }} where it goes. Only text values can take a parameter, so resources and site stay fixed.

Keep tiedbeam_jobs: 4 and files_per_group: 1. Larger groups don't make an event faster, since the time grows with the number of files either way (2, 4 and 8 took 0.91 to 0.96 minutes of refinement per GB in one process), and memory grows with them: each process needs about 2.6 GB plus about 4 GB per file it holds. 4 processes of 2 files, or 8 of 2, ran out of memory on a 40 GB session.

Rolling out a new image

This is the most frequent change.

  1. Release. Merging the release PR builds the image and pushes it to Docker Hub (chimefrb/baseband-analysis:<tag>) and to the private chimefrb project on CANFAR's Harbor, which headless sessions can't use.
  2. Copy it to chimefrb-public from a machine that can push to it:
Bash
tag=v1.15.0
docker pull --platform linux/amd64 chimefrb/baseband-analysis:$tag
docker tag chimefrb/baseband-analysis:$tag images.canfar.net/chimefrb-public/baseband-analysis:$tag
docker push images.canfar.net/chimefrb-public/baseband-analysis:$tag
  1. Register it for headless sessions: in Harbor, add the headless label to the new tag. CANFAR takes a few minutes to list it. Until then, a session on it fails with Could not start deployment .... To check, look for the tag in
Bash
curl -s --cert ~/.ssl/cadcproxy.pem "https://ws-uv.canfar.net/skaha/v1/image?type=headless" | grep baseband-analysis
  1. Try it on one event: queue an event you know with "version": "<tag>" (see above). Check on the Static Pipelines page that it ran on the new image and succeeded, and look at its localization in frb-master. Events queued without version keep running on the current default meanwhile.
  2. Make it the default: set parameters.version in the YAML, merge that, then update the config (below). Events queued afterwards run on the new image.

To roll back, update the config with the previous version. A single event can still run on any registered tag by giving version in its Work.

Updating the config

Python
import httpx, yaml

base = "https://frb.chimenet.ca/workflow/pipelines/v3/static_configs"
config = yaml.safe_load(open("baseband_analysis/pipelines/cluster/canfar_localization_static.yaml"))
r = httpx.put(f"{base}/{config['name']}", json=config)
print(r.status_code)  # 200

This replaces the whole definition: parameters' defaults, deployments (image, resources, environment), steps and concurrency. Events already running finish with the old definition. Events picked up afterwards use the new one, including the ones already waiting in the queue.

Always update from the YAML in the repository, so the config in production matches what's committed.

Don't delete and re-create the config to change it: deleting a static config also deletes all its pipelines, i.e. the record of every event it ran.

One-time setup (operators)

Before the config is created:

  • Image: images.canfar.net/chimefrb-public/baseband-analysis:<tag> exists and is registered for headless sessions, with a tag built with workflow.core 1.12.4 or later (keeps a failed step's output, no spinner in the logs) and datatrail-cli 1.2 or later (dtcli.workflow.pull_dataset with directory); v1.14.0 or later.
  • frb-master credentials: the pipeline reads event metadata from, and uploads results to, frb-master. The Workflow managers add their frb-master tokens (CHIME_FRB_ACCESS_TOKEN, CHIME_FRB_REFRESH_TOKEN) to every CANFAR session they start, the same tokens other CHIME/FRB services get when their stacks are deployed (see frb-devops). Don't put tokens in the config's environment: configs can be read back through the pipelines API.

  • datatrail on the CANFAR account: sessions run as the shared Workflow CANFAR account. The step creates its datatrail config (as datatrail config init --site canfar) if it's missing; it expects the account's CADC certificate at ~/.ssl/cadcproxy.pem.

  • Workflow: a pipelines release with CANFAR session_environment (workflow-pipelines #384), which also keeps each step's session logs, with the CANFAR deployer configured (certificate, workspace) as in workflow-pipelines' deployments docs. The image parameter needs workflow-pipelines with CHIMEFRB/workflow-pipelines#390 (${{ work.parameters.<key> }} in deployments) and #388 (parameters defaults).

Then create the config once:

Python
import httpx, yaml

config = yaml.safe_load(open("baseband_analysis/pipelines/cluster/canfar_localization_static.yaml"))
r = httpx.post("https://frb.chimenet.ca/workflow/pipelines/v3/static_configs/create", json=config)
print(r.status_code, r.text)  # 201 {"status": "Static Config created."}