diff --git a/lisa/__init__.py b/lisa/__init__.py index c2959c337414d3a208812e5921896272851dff53..6a05e8af4d3fa89054fc996ce446213063e5e902 100644 --- a/lisa/__init__.py +++ b/lisa/__init__.py @@ -1,3 +1,16 @@ from lisa.version import __version__ +# Put all the code inside one function, to allow easy cleanup of the namespace +# at the end. We definitely don't want to expose these things to the outside +# world +def f(): + import os + if os.getenv('LISA_DO_NOTEBOOK_SETUP'): + from lisa.utils import jupyter_notebook_setup + jupyter_notebook_setup() + +f() +del f + + # vim :set tabstop=4 shiftwidth=4 textwidth=80 expandtab diff --git a/lisa/env.py b/lisa/env.py index 4d8c1d25f902a8374a28c5669001e14b6b7af7b3..9fed3fc85d66271617bc484f738135a8151f1c99 100644 --- a/lisa/env.py +++ b/lisa/env.py @@ -61,10 +61,10 @@ class TargetConf(MultiSrcConf, HideExekallID): .. code-block:: python TargetConf({{ - 'name': 'myboard', - 'host': 192.0.2.1, - 'usname': 'foo', - 'password': 'bar', + 'name': 'myboard', + 'host': 192.0.2.1, + 'usname': 'foo', + 'password': 'bar', }}) Or alternatively, from a YAML configuration file: @@ -84,10 +84,10 @@ class TargetConf(MultiSrcConf, HideExekallID): .. code-block:: YAML target-conf: - # "!env: ENV_VAR_NAME" can be used to reference an - # environment variable. - name: !env:str BOARD_NAME - port: !env:int PORT + # "!env: ENV_VAR_NAME" can be used to reference an + # environment variable. + name: !env:str BOARD_NAME + port: !env:int PORT # It is possible to include another YAML file as a whole node in # the current YAML document. @@ -99,7 +99,7 @@ class TargetConf(MultiSrcConf, HideExekallID): * file foo.yml:: target-conf: - name: myboard + name: myboard * file bar.yml:: @@ -111,23 +111,23 @@ class TargetConf(MultiSrcConf, HideExekallID): target-conf: target-conf: - name: myboard + name: myboard """ YAML_MAP_TOP_LEVEL_KEY = 'target-conf' STRUCTURE = TopLevelKeyDesc(YAML_MAP_TOP_LEVEL_KEY, 'target connection settings', ( - KeyDesc('name', 'Board name, free-form value only used to embelish logs', [str]), - KeyDesc('kind', 'Target kind. Can be "linux" (ssh) or "android" (adb)', [str]), - - KeyDesc('host', 'Hostname or IP address of the host', [str, None]), - KeyDesc('username', 'SSH username', [str, None]), - KeyDesc('password', 'SSH password', [str, None]), - KeyDesc('port', 'SSH or ADB server port', [int, None]), - KeyDesc('device', 'ADB device. Takes precedence over "host"', [str, None]), - KeyDesc('keyfile', 'SSH private key file', [str, None]), - - KeyDesc('workdir', 'Remote target workdir', [str]), - KeyDesc('tools', 'List of tools to install on the target', [StrList]), + KeyDesc('name', 'Board name, free-form value only used to embelish logs', [str]), + KeyDesc('kind', 'Target kind. Can be "linux" (ssh) or "android" (adb)', [str]), + + KeyDesc('host', 'Hostname or IP address of the host', [str, None]), + KeyDesc('username', 'SSH username', [str, None]), + KeyDesc('password', 'SSH password', [str, None]), + KeyDesc('port', 'SSH or ADB server port', [int, None]), + KeyDesc('device', 'ADB device. Takes precedence over "host"', [str, None]), + KeyDesc('keyfile', 'SSH private key file', [str, None]), + + KeyDesc('workdir', 'Remote target workdir', [str]), + KeyDesc('tools', 'List of tools to install on the target', [StrList]), LevelKeyDesc('ftrace', 'FTrace configuration', ( KeyDesc('events', 'FTrace events to trace', [StrList]), KeyDesc('functions', 'FTrace functions to trace', [StrList]), @@ -146,7 +146,7 @@ class TargetConf(MultiSrcConf, HideExekallID): )) )) - DEFAULT_CONF = { + DEFAULT_SRC = { 'username': USERNAME_DEFAULT, 'ftrace': { 'buffsize': FTRACE_BUFSIZE_DEFAULT, @@ -160,8 +160,6 @@ class TargetConf(MultiSrcConf, HideExekallID): def __init__(self, conf, src='user'): super().__init__(conf=conf, src=src) - # Give some preset in the the lowest prio source - self.add_src('default', self.DEFAULT_CONF, fallback=True) # We do not allow overriding source for this kind of configuration to keep # the YAML interface simple and dict-like diff --git a/lisa/tests/kernel/scheduler/eas_behaviour.py b/lisa/tests/kernel/scheduler/eas_behaviour.py index f5e6ecb4813feafaa95b37e0b198293def1e7938..3babcc8a003922c4c5926c3cb218b18b9423c176 100644 --- a/lisa/tests/kernel/scheduler/eas_behaviour.py +++ b/lisa/tests/kernel/scheduler/eas_behaviour.py @@ -476,7 +476,7 @@ class TwoBigThreeSmall(EASBehaviour): @classmethod def get_rtapp_profile(cls, te): # 50% of the smallest CPU's capacity - small_duty = cls.unscaled_utilization(cls.min_cpu_capacity(te), 50) + small_duty = cls.unscaled_utilization(cls.min_cpu_capacity(te), 25) # 80% of the biggest CPU's capacity big_duty = cls.unscaled_utilization(cls.max_cpu_capacity(te), 80) diff --git a/lisa/utils.py b/lisa/utils.py index 3b1f8fc9f062589af006e866714799224f51d5a0..52fcd5df49da502aadd8e24d0f7bf170c93a36a1 100644 --- a/lisa/utils.py +++ b/lisa/utils.py @@ -49,6 +49,14 @@ The detected location of your LISA installation if not LISA_HOME: logging.getLogger(__name__).warning('LISA_HOME env var is not set, LISA may misbehave.') +def jupyter_notebook_setup(): + """ + Function containing generic init boilerplate to be called at the beginning + of notebooks. This will be called automatically upon importing lisa if the + LISA_DO_NOTEBOOK_SETUP environment variable is set. + """ + setup_logging() + class Loggable: """ A simple class for uniformly named loggers @@ -697,8 +705,9 @@ class MultiSrcConf(SerializableConfABC, Loggable, Mapping, metaclass=MultiSrcCon """ pass - def __init__(self, conf=None, src='default'): + DEFAULT_SRC = {} + def __init__(self, conf=None, src='conf'): self._nested_init( parent=None, structure=self.STRUCTURE, @@ -707,6 +716,10 @@ class MultiSrcConf(SerializableConfABC, Loggable, Mapping, metaclass=MultiSrcCon if conf is not None: self.add_src(src, conf) + # Give some preset in the the lowest prio source + if self.DEFAULT_SRC: + self.add_src('default', self.DEFAULT_SRC, fallback=True) + @classmethod def get_help(cls, *args, **kwargs): return cls.STRUCTURE.get_help(*args, **kwargs) diff --git a/shell/lisa_shell b/shell/lisa_shell index 44a51984e1776a4c87eec6e80556c4426fdf34c8..4a73cb8f3ab68faa1d02f58047e5d05fdf3de91c 100755 --- a/shell/lisa_shell +++ b/shell/lisa_shell @@ -308,7 +308,7 @@ function _lisa-jupyter-start { cd $PYDIR echo echo -n 'Notebook server task: ' - nohup jupyter lab --ip="$IPADDR" --port="$PORT" \ + nohup LISA_DO_NOTEBOOK_SETUP=1 jupyter lab --ip="$IPADDR" --port="$PORT" \ --NotebookApp.token="$TOKEN" \ >"$LOGFILE" 2>&1 & echo $! >"$PIDFILE"