HiveBoard Docs Search the docs… Ctrl K Get HiveBoard
Browse the help centre
  1. Help centre
  2. Simulation codes

Adding your own code

Teach HiveBoard a simulation code it does not know, or replace a built-in one: one YAML spec in the engines folder of the data folder, then a restart.

5 min read HiveBoard 0.1.7 Updated Make it yours · lesson 6 of 8

In short

  • A simulation code is one YAML file, its spec. Put it in the engines folder of HiveBoard's data folder and start HiveBoard again.
  • A file whose id is that of a built-in code replaces that code whole.
  • Connections → Settings → Simulation codes shows the folder, every code that loaded, and every file that was refused, with the reason.
  • A file that fails a check is skipped whole, so a typo can never half-apply.

HiveBoard reads twenty codes out of the box, but nothing about a code is written into the program itself: each one is a YAML file, its spec, that says which files a job folder holds, how to recognise them, and what to read from them. To add a code — your group’s own program, or one HiveBoard does not carry — you write such a file and put it in the engines folder of HiveBoard’s data folder. No change to HiveBoard is needed.

The format is the one the built-in codes use, described key by key in the engine spec reference. This page is about where the file goes and how to tell whether it worked.

Where the file goes

Into the engines folder inside the data folder — normally ~/.hiveboard/engines/. The exact path is under Your own codes in Connections → Settings → Simulation codes, with a Copy button. Create the folder if it is not there yet.

  • Only files ending in .yaml are read (not .yml).
  • Save the file as UTF-8 text; a file in another encoding is refused.
  • One file per code. The file name does not matter; the id inside it does.

Adding a code, step by step

  1. Write the spec and save it as, say, mycode.yaml.
  2. Put it in the engines folder.
  3. Quit HiveBoard and start it again: specs are read once, at start-up. On Windows, quit from the tray icon’s menu, Quit HiveBoard.
  4. Open Connections → Settings → Simulation codes. Your code is in the table, marked yours, with Your own file under From.
  5. Every server set to all codes now looks for it. A server limited to some codes needs it ticked on its Software tab (codes per server).

A small example

A made-up program, MyCode, reads an input *.mci and writes an output *.mco that starts with MyCode version … and prints Total energy = … once per step. This spec recognises it, tells an optimisation from a single point, and draws progress, two numbers and a chart:

schema: 1
id: mycode
name: MyCode
short: MyCode
family: other
summary: Our group's own solver
appearance:
  hue: 30
  glyph: flask

files:
  input:
    patterns: ["*.mci"]
    note: Input deck
  output:
    patterns: ["*.mco"]
    note: Main output

detect:
  listing:
    strong: ["*.mci", "*.mco"]
  content:
    output: ['MyCode version \d']

reads:
  tail:
    file: output
    how: tail
    bytes: 20000
  energies:
    file: output
    how: grep
    needle: "Total energy ="
    max: 400
  nsteps:
    file: output
    how: count
    needle: "Total energy ="

kinds:
  - id: opt
    label: Optimisation
    glyph: relax
    when:
      input: '(?im)^\s*task\s*=\s*opt'
  - id: single
    label: Single point
    glyph: bolt

values:
  energy:
    from: energies
    regex: '=\s*(?P<v>-?\d+\.\d+)'
  energies:
    from: energies
    regex: '=\s*(?P<v>-?\d+\.\d+)'
    take: all
  steps:
    from: nsteps
    regex: '(?P<v>\d+)'
    type: int
  maxsteps:
    from: input
    regex: '(?i)maxsteps\s*=\s*(?P<v>\d+)'
    type: int
    default: 100

status:
  finished:
    from: tail
    regex: 'MyCode finished'

progress:
  - when: ["kind=opt"]
    done: steps
    total: maxsteps
    unit: step

metrics:
  - label: Energy
    value: "{energy:.6f} Ha"
  - label: Steps
    value: "{steps} / {maxsteps}"
    when: ["kind=opt"]

series:
  - label: Energy per step
    y: energies
    x_label: step
    y_label: "E − E_last (Ha)"
    transform: relative_last

headlines:
  - when: [finished]
    text: "Finished after {steps} steps."
  - when: ["kind=opt"]
    text: "Optimising: step {steps} of {maxsteps}."

What each part does:

  • files names the two roles, input and output; everything else refers to these roles, never to file names. Each note is what the Files tab shows in its What it is column.
  • detect says a folder holding *.mci or *.mco may be MyCode, and that the banner at the top of the output proves it.
  • reads fetches the end of the output, the lines holding Total energy = (the last 400) and a count of them. With the top of the input, that is all the summary command reads.
  • kinds calls a job an optimisation when its input says task = opt, and a single point otherwise (the last kind is the default).
  • values turns the text into numbers: the last energy, all of them for the chart, the step count, and the step limit from the input (100 when the input does not say).
  • progress, metrics, series and headlines say what the job pane shows.

With this file in place, a running job whose folder holds an input with task = opt and maxsteps = 50, and an output with three energies so far, is tagged MyCode · Optimisation. Its pane reads “Optimising: step 3 of 50.”, the progress bar stands at 6 %, the Energy and Steps cards show the last energy and 3 / 50, and the chart has three points.

Replacing a built-in code

A file whose id is that of a built-in code — qe, lammps, any of the twenty — replaces the built-in spec. It replaces it whole: nothing of the built-in spec is kept or merged, so your file has to say everything the code needs. In the catalogue that code then reads Your own file.

When a file is refused

Every spec is checked when HiveBoard starts. A file that fails a check is skipped whole — a typo cannot half-apply — and the reason is kept:

  • Settings → General says how many code files could not be loaded, with a link, see why.
  • Settings → Simulation codes opens with a card listing each refused file and what is wrong with it.

The message names the file, the place in it and the problem. A misspelt key, for example (wrapped here to fit):

mycode.yaml (mycode).reads.tail: unknown key(s)
['bites']. Known here: ['bytes', 'file', 'first',
'how', 'icase', 'max', 'needle'].

The usual causes are a misspelt key (unknown keys are refused, not ignored), a regular expression that only one of HiveBoard’s two builds would read the same way, a file-name pattern with a character a shell would act on, or a role, read or value that is used but never defined. Fix the file and start HiveBoard again. The rules are in the spec reference.

Removing a code

Delete the file, or move it out of the folder, and start HiveBoard again. A server limited to that code alone then recognises nothing until you choose its codes again on its Software tab.

On another computer

The engines folder is part of the data folder: copy it along with the rest. Two things do not carry it:

  • --portable copies your settings, keys and trusted hosts into the portable folder, but not engines (portable mode).
  • An export of your servers carries which codes each server looks for, not the specs. On import, a code that computer does not know is dropped from the server’s list (export and import).

Check yourself

2 quick questions on this page. Nothing is sent anywhere.

  1. You saved a corrected spec into the engines folder while HiveBoard was running. When does it take effect?

    • The next time HiveBoard starts
    • At the next refresh of the job list
    • When you open a job of that code
    • Immediately
    Show the answer

    The next time HiveBoard starts Specs are read once, at start-up; quit HiveBoard and start it again.

  2. Your file has the id qe, like the built-in Quantum ESPRESSO spec. What happens?

    • Your file replaces the built-in spec whole
    • The two are merged key by key
    • Yours is refused as a duplicate
    • Both are tried and the higher priority wins
    Show the answer

    Your file replaces the built-in spec whole A file whose id matches a built-in code replaces it; nothing of the built-in one is kept.

Try it in the app

On your own computer, with HiveBoard open. Tick them off as you go.

Lesson 6 of 8 in Make it yours Next lesson: Keyboard shortcuts

Written for HiveBoard 0.1.7, the version on the download page. Examples use a made-up cluster (Ember) and person (zoe). Something here not what you see? Report it from the app.

↑ ↓ to moveEnter to openEsc to close