Skip to content

`load_script` function refactoring, default-plugin objects, and more tests

Matias Guijarro requested to merge session_load_script into master

Fix #205 (closed)

load_script()

@beteva reported problems with load_script function.

Doing things like:

setup.py
--------
a=1
load_script("myscript")

myscript1.py
------------
a+=1

lead to a NameError (since a is not known in the myscript module)

(this example is the simplest to reproduce the problem, it was more complicated than this in reality)

So, this merge request changes load_script to behave like Python's execfile. This makes a lot of sense: we can do from bliss.sessions.XXX import myscript1 or load_script("myscript", session="XXX") and we finally have the same options as Python offers: either the import mechanism or execfile. load_script is needed because it provides a helper to get the code of the script; indeed, code can be on the beacon host !

Just like execfile, now load_script always reloads the file (the reload option has been removed).


default plugin objects

Without explicit include-objects, a session loads all objects except other sessions.

However, sometimes we need configuration objects, eg. YML files to contain configuration for a procedure for example, like kb_focus:

plugin: default
name: kb1
bpm:
   device: $md3bv
   counter: y
slits:
   - axis: $ts1vo
     position: 0
   - axis: $ts1vg
     position: 2
   - axis: $ts1hg
     position: 0.2
scan:
   axis: $ts1ho
   rel_max: 1
benders:
   upstream: $bm1v1
   downstream: $bm1v2

This remove the need for complicated setup lines in the setup file, for example. When starting KB alignment one can just specify kb1 as config...

The problem is that kb1 also becomes a session object -- in general we do not want to see those objects in the global namespace except explicitely requested.

This merge request removes default-plugin objects from sessions by default.


tests

This merge request adds some tests to make sure everything works as expected :)

In particular it adds a test for prdef, which is currently broken. This is related to issue #178 (closed)

Edited by Matias Guijarro

Merge request reports