Skip to content

Script Generator

kjwoodsISIS edited this page Jan 29, 2019 · 20 revisions

Note: See here for a more technical perspective on the script generator.

The purpose of this page is to collect requirements, ideas, suggestions, etc. for a Script Generator for IBEX. The requirements are listed in no particular order. Some of the requirements, ideas, suggestions may conflict with each other - that's fine, this is just a collection facility. When the time comes to create the Script Generator, we will review these ideas, identify a selection of these ideas to implement and turn them into user stories for implementation. If there are inconsistencies or conflicts, we'll resolve them when we make the selection (Note: resolution may mean reaching a compromise between two inconsistent requirements or dropping one in favour of another).

Script Generator Requirements

  1. Script Generator should be capable of working offline (i.e. stand-alone, remotely from IBEX). This has several advantages:
    1. the Script Generator can be given to visiting scientists to prepare their own scripts ahead of their visit to ISIS. This helps maximise the use of beam time (i.e. there are no delays while users write scripts).
    2. a separate Script Generator does not need to run on the IBEX control PC. This means that the IBEX control PC is not tied up whilst someone is writing scripts.
  2. Script Generator could be integrated with IBEX. This has the advantage of being able to use IBEX configs (to get information about blocks) and local genie_python libraries (to use instrument specific methods).
    1. a tightly integrated Script Generator would not be capable of running stand-alone (conflicts with the above requirement). Perhaps there is a looser degree of integration that could satisfy both requirements.
  3. Implementing the Script Generator as a web application might be one approach to creating a solution that satisfies the two previous requirements.
  4. The Script Generator should be capable of submitting scripts to the IBEX ScriptServer.
    1. this capability should only be available to users in the instrument control cabin (i.e. it should not be possible to submit scripts from remote locations).
    2. once a script has been sent from the Script Generator to the IBEX ScriptServer any modification (e.g. on-the-fly editing of the script, adjusting its position in the queue) should be done via IBEX ScriptServer.
  5. The Script Generator should allow the user to save a script to file.
  6. The Script Generator should allow the user to load a previously saved script.
  7. The Script Generator should allow the user to set a run title
  8. The Script Generator should allow the user to switch between detector & monitor type measurements (is this the same as switching between transmission & reflection measurements?). Maybe this is a requirement for LSS instruments only?
  9. The Script Generator should be able to estimate how long it will take to execute a script (maybe this is functionality that really ought to belong to the ScriptServer?).
  10. The following comments apply to Muon instruments:
    1. The vast majority of muon experiments involve looping over temperature and/or magnetic field.

    2. The Muon group are aware that MkScript (the old Script Generator) allows you to create nested loops, but they tend not to use this capability.

    3. Muon group tends to create scripts at the instrument control PC (i.e. they don't work offline)

    4. Muon group often runs a sequence of scripts, one after another:

      1. start a new run (i.e. BEGIN) /* this step is optional (see below) */
      2. run the first script
      3. run the second script
      4. ...
      5. run the final script
      6. stop the final run (i.e. END) /* this step is also optional (see below) */
      • Each script in the sequence may start and stop one or more runs.
      • Each script in the sequence may be terminated prior to completion(i.e. with Ctrl+C).
      • A run may be started prior to running the first script. For example: a run is started manually to check the data are of the expected form and estimating the collection time needed for the runs in the script, finalising the details of the script on that basis, and then executing the script with the first line being to collect a bit more data in the present experimental condition before changing the experimental conditions.
      • it may be convenient to end the run manually (e.g. if the final script were terminated prior to completion)
    5. The ability to run custom commands is handy. In fact, the following (logical) construction would be useful, if it could be supported:

my_custom_scan_setup_command()
for (min < scan_variable < max) {
set (scan_variable)
make_measurement()
next (scan_variable)
}
my_custom_scan_close_command()

  1. It would be nice if the scan loop (above) could be condensed to a single line (i.e. wrapped up in a general scan command).
    1. it could be difficult to unroll the loop inside such a command. Maybe this is acceptable because it could make things easier for end-users (who may lack programming skills).
  2. linear and log/exponential step sizes in scans would be useful. For example:
    • linear: 5, 10, 15, 20, ...
    • log/exponential: 1000, 100, 10, 1, ... or 2, 4, 8, 16, ...
  3. The MACS system allows users to change comments
  4. The MACS system allows users to change "metadata"
  5. The MACS system allows users to select variables from a list of block names (or, at least, their MACS equivalent).
  6. It would be nice if the Script Generator knew a little about device capabilities (e.g. 100K is a ridiculous temperature for a dilution fridge).

Muon group's view on Script Generator Requirements

The following are some comments made by the Muon group, regarding their views on desirable attributes of a Script Generator.

  1. Replicating something similar to or more capable than the existing editors we use is vital to operations.
  2. Dynamic scripting along the lines of MACS is an important feature for us. The Japanese muon instruments that have now entered the scope of the IBEX project because of the RIKEN handover (and technical changes since the original URD) have had this feature for ~20 years and should not fall back in capability.
  3. We don’t routinely generate scripts away from the instruments but it seems like a nice-to-have feature.
  4. Script queuing is important to us – this seems to be in hand already. Saving and loading scripts also.
  5. Making sure that the output of the script editor is straightforwardly human editable is important. The editor is unlikely to deal with every edge use case so this is a good way to deal with that. Our original editor up to mkscript3 has this feature, but MuonGUI is much worse for this.
  6. If the script editor is on an instrument control machine it should be aware of the range of control parameters currently available and highlight if the script asks for the impossible. I think MuonGUI is able to do this.
  7. The script duration should be estimated given reasonable assumptions that may be adjusted by the user. Counting time estimation is a good baseline requirement that is already fulfilled on our existing editors, some other control parameters that are predictable could be desirable to include.
  8. Progress indication is also useful and could go hand-in-hand with dynamic execution.
  9. The script editor should be able to define comments to be put in the data files. (Muon datasets have a consistent basic metadata format including comments. I’m not sure how standard this is in the NeXus definitions around ISIS.)
  10. There should be a way of including arbitrary cset comments so you can type in non-standard things as needed.

Script Generator Notes (SAG Meeting, 24-01-2019)

MUONS SCRIPT GENERATORS (Peter Baker)

  • old MkScript (circa 2000) - used by South Side muons & MARI
  • new MuonScript (circa 2012) - used by South Side muons
  • IMPORTANT: old MkScript generates OpenGenie files that are human-readable. New Script Generator must generate human-readable Python
  • MACS script generator - used by North Side muons (aka RIKEN)
    • dynamic scripting
    • "edit-on-the-fly"
    • can select SECI blocks, add to script
    • can unroll loops
  • NOTE: MACS script commands are actually pre-defined OpenGenie procedures
  • NOTE: New Script Generator needs to be able to distinguish between stepped and continuous ramps

DISCUSSION:

  • users/scientists want human-readable Python
  • single loops are fine
  • nested loops would be good, but some users will have problems with them
    • like to be able to expand implied loops - e.g. my_procedure( arg1, ...) [+]
  • All groups use linear scan progressions
    • some groups, especially muons, use logarithmic scan progressions too
  • ability to estimate time to execute script would be very handy
  • What happens if you stop a script mid-way through?
    • just stopping (and leaving the instrument "as is") is fine for most instruments
    • just stopping is probably not OK for reflectometers
      • if so, how should a reflectometer be "parked"? how to define that?
  • Need to sanity check scripts
    • check syntax, etc.
    • check parameters are in range (e.g. red box around invalid fields, warning dialog) get parameters from config files or similar.
  • Comments & annotation
    • need ability to annotate the NeXuS file (i.e. provide text that gets inserted into NeXuS file)
    • may also need ability to add comments to the scripts themselves (really needed, if script is transient).
    • NOTE: Muons NeXuS file has extra fields not used by neutron instruments BEGIN on a muon instrument, prompts users to enter extra information How will this be handled in Script Generator?

MOLECULAR SPECTROSCOPY (Ian Silverwood)

  • group is generally happy with scripting as it is
  • a simple Script generator would meet their basic needs
  • would like Script Generator to support "soft limits" (c.f. SECI).
    • prevent setting of "crazy" values
  • code snippet preview would be very useful
    • show what is about to be inserted into the script
    • the click "Confirm" (or "Add") to add it to the script
  • need to ensure that appropriate annotation is included when scanning
    • i.e. automatically generate the name of the run (based on suitable parameters)
    • users often forget to do this
  • nice to be able to hover over a PV and see a history to commands that changed it (may not be possible)
  • Plot planned temperature (or other variable) ramps
    • often easier to see errors by looking at ramps, rather than looking at code

ENGINEERING & IMAGING (Genoveva Burca)

  • important to preserve the ability to read motor positions from a file (already implemented for ENGIN-X).

EXCITATIONS (Russell Ewings, standing in for Tatiana Guidi)

  • tried Max Skoda's script generator
  • like that it customisable for different instruments (within LSS group)
  • highlight need to be able generate standardised experiment titles (for NeXuS file)
  • save generated Python to file
  • ability to copy/paste similar blocks of code
    • Ian: queried "when do you use cut/paste versus loops?" this is just the point where users forget to change Run/Experiment titles
  • need to execute special code on STOP?
  • once code has been executed, display it as "greyed out"
  • need to be able to save scripts, re-load scripts, play (execute) scripts
  • KEEP IT SIMPLE!
    • Script Generator is for novice & intermediate users
    • power users should be expected to write their own scripts

DISORDERED MATERIALS (Sabrina Gaertner)

  • a script generator is a good idea, but do we really need it?
    • most disordered materials experiments are very simple (loop over sample changer positions)
    • it is not difficult to write scripts for simple experiments
    • so what value is a Script Generator bringing?
  • if disordered materials experiments involve other types of loop, they get very complicated very quickly
    • not sure a Script Generator can help here.
  • the complexity of the sample environment does not correlate with users!
    • some inexperienced users need to have complex SE setups
  • Ian: nested loops are too complex for some users - leads to mistakes simulated runs would help a lot would it be possible to load a pre-written block of code for execution in a loop? - need to take care when executing arbitrary scripts! flow should be Generate -> Check -> Run - if there is an error, stop, edit the script, re-execute - Peter: that's not how muons operate.
  • Need to warn users if a generated script is saved, edited (externally) and re-loaded
    • no guarantee that Script Generator can handle a modified script (it may no longer fit the template)

CRYSTALLOGRAPHY (Ivan da Silva)

  • group has simple scripting needs
  • loops: sometimes with if/else, sometimes while (){}, or do {} while()
  • often want to adjust step-size on-the-fly
  • need to insert command to change titles (i.e. annotation)
  • need to use instrument specific commands (e.g. change Energy)

LSS – SANS (Diego Alba Venero)

LSS – REFLECTOMETRY (Diego Alba Venero standing in for Andrew Caruana)

List of requirements provided by Diego & Andrew:

  • object structure allowing to define sample parameters and methods -> sample object (this can include some error and logic checking for instance)
  • infrastructure to define instrument specific functions with multiple parameters, including the above sample object (there are both 'action' functions, like runScript or runTransmissions and also SE related functions, such as contrastChange, runNIMA, setEurotherm etc.)
  • ability to call other functions or script snippets
  • ability to edit by drag and drop, also during script execution
  • ability to play, pause and resume the 'script'
  • real time script output from GUI
  • ability to save and load scripts (both as Python and GUI state)
  • error and logic checking
  • script simulator
  • time estimation
  • Adding instrument specific functions should be easy and ideally, not require a rebuild

MUONS

  • see MUONS SCRIPT GENERATORS above

CHIP IRRADIATION

  • not represented at meeting

TOM WILLEMSEN:

  • Tom asked meeting if all were happy with the table/list view of existing script generators
    • reply was a very strong "Yes"
    • a Tree View might also be useful, but is not critical
  • Russell: would importing a CSV file from Excel be useful?
    • yes, could be very useful (Sabrina, Ian, Diego)
Clone this wiki locally