From 19c4b8a7ae175525edd9b74f316e456d49eaa24b Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Mon, 3 Dec 2018 15:59:33 +0000 Subject: [PATCH 1/3] utils: Add DEFAULT_SRC feature to MultiSrcConf --- lisa/env.py | 48 +++++++++++++++++++++++------------------------- lisa/utils.py | 7 ++++++- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/lisa/env.py b/lisa/env.py index 4d8c1d25f..9fed3fc85 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/utils.py b/lisa/utils.py index 3b1f8fc9f..d7bbea155 100644 --- a/lisa/utils.py +++ b/lisa/utils.py @@ -697,8 +697,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 +708,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) -- GitLab From 7632bb0237042d3ac8fc425e55f860a559bc27c5 Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Wed, 5 Dec 2018 16:04:56 +0000 Subject: [PATCH 2/3] eas_behaviour: Make TwoBigThreeSmallTask small task smaller Reduce to 25% of a LITTLE CPU instead of 50% --- lisa/tests/kernel/scheduler/eas_behaviour.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisa/tests/kernel/scheduler/eas_behaviour.py b/lisa/tests/kernel/scheduler/eas_behaviour.py index f5e6ecb48..3babcc8a0 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) -- GitLab From 11bf26045dd71609d76f8d8568f58f4ab98944a6 Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Wed, 5 Dec 2018 17:39:12 +0000 Subject: [PATCH 3/3] lisa: Do some implicit notebook setup When the lisa package is imported with LISA_DO_NOTEBOOK_SETUP environment variable is set, some default setup code will be run. This currently only calls utils.setup_logging() to save some boilerplate in notebooks. --- lisa/__init__.py | 13 +++++++++++++ lisa/utils.py | 8 ++++++++ shell/lisa_shell | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lisa/__init__.py b/lisa/__init__.py index c2959c337..6a05e8af4 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/utils.py b/lisa/utils.py index d7bbea155..52fcd5df4 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 diff --git a/shell/lisa_shell b/shell/lisa_shell index 44a51984e..4a73cb8f3 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" -- GitLab