Sessions, shell functions and globals refactoring
Following the meeting we had yesterday, in order to clarify and solve discussions about sessions, shell (user) functions and globals refactoring, here are conclusions and corresponding tasks:
Guidelines
- we need to ensure BLISS stays 100% usable as a library
- basic rules to be followed: everything should be explicit, no calls to print
- differentiate shell functions and library functions
- a Session corresponds to an experimental setup
- groups devices and a setup file
- global variables usage should be limited
- in general we can always find an object to attach those to
- running multiple sessions is allowed (although probably not so useful)
- too difficult to do checks to forbid it
- the current session is the last one initialized (
.setup()
called)
Todo
-
create bliss.shell.standard
to put user/shell functions-
should include messages for user (see next task) -
can show dialogs -
there should be a corresponding function in bliss.common.standard
to do the 'real' job
-
-
replace print with calls to a new 'user print' function: lprint
- should rely on the logging facility
- a special formatter in BLISS shell will display all those messages
- no date, no time, no log level: just the message (like
print
)
- no date, no time, no log level: just the message (like
-
add a logbook
object in BLISS- should have a
.log_message()
method to send messages to be displayed - should be available from Flint, too
- for example, it could be extended with
.log_scan()
to put scan data in the form of a table or a .png plot
- for example, it could be extended with
- should have a
-
the BLISS map
has to be made global, process-wise- not attached to a session
-
no automatic default session anymore -
session.get_current()
will returnNone
if no session has been setuo - Q: how to create a new, empty session in library mode ?
- still possible to keep
DefaultSession
sofrom bliss.common.session import DefaultSession; new_session=DefaultSession()
would work ?
- still possible to keep
-
-
scans won't work if no session is currently defined -
Scan
object should take a session argument, to get access to scan saving
-
-
add .scan_saving
property in Session object- will be used for
SCAN_SAVING
in shell, from current session - will be used by scans
- will be used for
-
no SCAN_DISPLAY handling in Scan
object- should be implemented differently, only from shell
- monkey patching the class ?
- subclassing
Scan
in shell ? - reserving a callback that does nothing by default ?
- should be implemented differently, only from shell
-
add .active_measurement_group
property in Session object- will be used for
ACTIVE_MG
in shell, from current session
- will be used for
-
add .user_scan_meta
property to Session object- will be used for
USER_SCAN_META
in shell, from current session
- will be used for
-
add .scans
to Session object- will be used for
SCANS
global in shell only, from current session
- will be used for
-
Aliases to be attached to the global map - error to be raised in case of duplicated aliases from 2 different sessions
-
the default, empty session (when BLISS shell is started without specifying a session) to be called __DEFAULT__
- tmux will open a new terminal, but [F5] will still display scans from all default sessions => ok