diff --git a/lisa/_doc/helpers.py b/lisa/_doc/helpers.py index 89b0dac95b586f1b8dad8ee3f755530154760607..7af72e44c6c90e3031f2461e22dc01f7bf4864a6 100644 --- a/lisa/_doc/helpers.py +++ b/lisa/_doc/helpers.py @@ -315,7 +315,7 @@ def autodoc_process_analysis_plots(app, what, name, obj, options, lines, plot_co plot_methods = set(itertools.chain.from_iterable( subclass.get_plot_methods() - for subclass in get_subclasses(TraceAnalysisBase) + for subclass in TraceAnalysisBase.get_analysis_classes().values() )) if obj not in plot_methods: @@ -354,7 +354,7 @@ def autodoc_process_analysis_methods(app, what, name, obj, options, lines): """ methods = { func: subclass - for subclass in get_subclasses(TraceAnalysisBase) + for subclass in TraceAnalysisBase.get_analysis_classes().values() for name, func in inspect.getmembers(subclass, callable) } @@ -377,6 +377,9 @@ def get_analysis_list(meth_type): for entry in get_deprecated_map().values() } + # Ensure all the submodules have been imported + TraceAnalysisBase.get_analysis_classes() + for subclass in get_subclasses(AnalysisHelpers): class_path = f"{subclass.__module__}.{subclass.__qualname__}" if meth_type == 'plot': diff --git a/lisa/analysis/__init__.py b/lisa/analysis/__init__.py deleted file mode 100644 index 29db79cfd7d26e5521aaff727e3c3a1a61b4aba3..0000000000000000000000000000000000000000 --- a/lisa/analysis/__init__.py +++ /dev/null @@ -1,36 +0,0 @@ -#! /usr/bin/env python3 -# SPDX-License-Identifier: Apache-2.0 -# -# Copyright (C) 2018, ARM Limited and contributors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -__all__ = [] - -# Import all the submodules before they are asked for by user code, since -# we need to create the *Analysis classes in order for them to be -# registered against TraceAnalysisBase - - -def _import_submodules(): - from lisa.utils import _import_all_submodules - modules = _import_all_submodules(__name__, __path__) - __all__.extend(modules) - - -_import_submodules() -# Avoid polluting the namespace with non-necessary names -del _import_submodules - -# vim :set tabstop=4 shiftwidth=4 textwidth=80 expandtab diff --git a/lisa/analysis/base.py b/lisa/analysis/base.py index e50aa398dfd2cbea8753b9eff69545d198996e94..4aa99a3eb8cc35f1a8b41ad2fbf5d36a5594b6ae 100644 --- a/lisa/analysis/base.py +++ b/lisa/analysis/base.py @@ -43,7 +43,7 @@ import panel as pn import panel.widgets -from lisa.utils import Loggable, deprecate, get_doc_url, get_short_doc, get_subclasses, guess_format, is_running_ipython, measure_time, memoized, update_wrapper_doc +from lisa.utils import Loggable, deprecate, get_doc_url, get_short_doc, get_subclasses, guess_format, is_running_ipython, measure_time, memoized, update_wrapper_doc, _import_all_submodules from lisa.trace import PandasDataDesc from lisa.notebook import _hv_fig_to_pane, _hv_link_dataframes, axis_cursor_delta, axis_link_dataframes, make_figure from lisa._generic import TypedList @@ -1175,6 +1175,11 @@ class TraceAnalysisBase(AnalysisHelpers): @classmethod def get_analysis_classes(cls): + # Import all the submodules so that we have full visibility over the + # subclasses. + import lisa.analysis as ana + _import_all_submodules(ana.__name__, ana.__path__) + return { subcls.name: subcls for subcls in get_subclasses(cls)