Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: restrict construction_order when searching for node callbacks #4

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
git clone https://github.com/tier4/caret_analyze_cpp_impl.git
- name: Restore Cache
id: cpp_impl-cache
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: caret_analyze_cpp_impl/install
key: ${{ runner.os }}-node-cpp_impl-${{ hashFiles('caret_analyze_cpp_impl/CARET_analyze_cpp_impl/**') }}
Expand All @@ -60,7 +60,7 @@ jobs:

- name: Cache caret_analyze_cpp_impl
if: steps.cpp_impl-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
uses: actions/cache/save@v4
with:
path: caret_analyze_cpp_impl/install
key: ${{ runner.os }}-node-cpp_impl-${{ hashFiles('caret_analyze_cpp_impl/CARET_analyze_cpp_impl/**') }}
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ repos:
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.38.0
rev: v0.39.0
hooks:
- id: markdownlint
args: [-c, .markdownlint.yaml, --fix]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.4
rev: v4.0.0-alpha.8
hooks:
- id: prettier

Expand Down
2 changes: 1 addition & 1 deletion mkdocs-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ mike
plantuml-markdown
pymdown-extensions
python-markdown-math
mkdocstrings
mkdocstrings<=0.23
mkdocstrings[python]
7 changes: 5 additions & 2 deletions src/caret_analyze/architecture/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import logging

from .architecture_exporter import ArchitectureExporter
from .architecture_loaded import NodeValuesLoaded
from .architecture_loaded import MAX_CONSTRUCTION_ORDER, NodeValuesLoaded
from .combine_path import CombinePath

from .reader_interface import ArchitectureReader, IGNORE_TOPICS
Expand All @@ -42,6 +42,7 @@ def __init__(
self,
file_type: str,
file_path: str,
max_construction_order: int = MAX_CONSTRUCTION_ORDER
) -> None:
from .architecture_reader_factory import ArchitectureReaderFactory
from .architecture_loaded import ArchitectureLoaded
Expand All @@ -51,7 +52,9 @@ def __init__(

reader = ArchitectureReaderFactory.create_instance(
file_type, file_path)
loaded = ArchitectureLoaded(reader, ignore_topics)
loaded = ArchitectureLoaded(reader,
ignore_topics,
max_construction_order=max_construction_order)

self._nodes: list[NodeStruct] = loaded.nodes
self._communications: list[CommunicationStruct] = loaded.communications
Expand Down
41 changes: 35 additions & 6 deletions src/caret_analyze/architecture/architecture_loaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

logger = getLogger(__name__)

MAX_CONSTRUCTION_ORDER = 10


def indexed_name(base_name: str, i: int, num_digit: int):
index_str = str(i).zfill(num_digit)
Expand All @@ -62,13 +64,15 @@ class ArchitectureLoaded():
def __init__(
self,
reader: ArchitectureReader,
ignore_topics: list[str]
ignore_topics: list[str],
max_construction_order: int = MAX_CONSTRUCTION_ORDER
) -> None:

topic_ignored_reader = TopicIgnoredReader(reader, ignore_topics)

self._nodes: list[NodeStruct]
nodes_loaded = NodeValuesLoaded(topic_ignored_reader)
nodes_loaded = NodeValuesLoaded(topic_ignored_reader,
max_construction_order=max_construction_order)

self._nodes = nodes_loaded.data

Expand Down Expand Up @@ -274,6 +278,7 @@ class NodeValuesLoaded():
def __init__(
self,
reader: ArchitectureReader,
max_construction_order: int = MAX_CONSTRUCTION_ORDER
) -> None:
self._reader = reader
nodes_struct: list[NodeStruct] = []
Expand All @@ -291,7 +296,11 @@ def __init__(

for node in Progress.tqdm(nodes, 'Loading nodes.'):
try:
node, cb_loaded, cbg_loaded = self._create_node(node, reader)
node, cb_loaded, cbg_loaded = self._create_node(
node,
reader,
max_construction_order=max_construction_order
)
nodes_struct.append(node)
self._cb_loaded.append(cb_loaded)
self._cbg_loaded.append(cbg_loaded)
Expand Down Expand Up @@ -446,6 +455,7 @@ def find_callbacks(
def _create_node(
node: NodeValue,
reader: ArchitectureReader,
max_construction_order: int = MAX_CONSTRUCTION_ORDER
) -> tuple[NodeStruct, CallbacksLoaded, CallbackGroupsLoaded]:

callbacks_loaded = CallbacksLoaded(reader, node)
Expand Down Expand Up @@ -476,7 +486,12 @@ def _create_node(
)

try:
node_paths = NodeValuesLoaded._search_node_paths(node_struct, reader)
node_paths = \
NodeValuesLoaded._search_node_paths(
node_struct,
reader,
max_construction_order=max_construction_order
)
node_path_added = NodeStruct(
node_struct.node_name, node_struct.publishers,
node_struct.subscriptions,
Expand All @@ -496,14 +511,15 @@ def _create_node(
@staticmethod
def _search_node_paths(
node: NodeStruct,
reader: ArchitectureReader
reader: ArchitectureReader,
max_construction_order: int = MAX_CONSTRUCTION_ORDER
) -> list[NodePathStruct]:

node_paths: list[NodePathStruct] = []

# add callback-graph paths
logger.info('[callback_chain]')
node_paths += list(CallbackPathSearched(node).data)
node_paths += list(CallbackPathSearched(node, max_construction_order).data)

# add pub-sub pair graph paths
logger.info('\n[pub-sub pair]')
Expand Down Expand Up @@ -1588,6 +1604,7 @@ class CallbackPathSearched():
def __init__(
self,
node: NodeStruct,
max_construction_order: int = MAX_CONSTRUCTION_ORDER
) -> None:
from .graph_search import CallbackPathSearcher
self._data: list[NodePathStruct]
Expand All @@ -1598,7 +1615,13 @@ def __init__(
paths: list[NodePathStruct] = []

if callbacks is not None:
skip_nodes = []
for write_callback, read_callback in product(callbacks, callbacks):
if max_construction_order != 0:
if write_callback.construction_order > max_construction_order or \
read_callback.construction_order > max_construction_order:
skip_nodes.append(node.node_name)
continue
searched_paths = searcher.search(write_callback, read_callback, node)
for path in searched_paths:
msg = 'Path Added: '
Expand All @@ -1608,6 +1631,12 @@ def __init__(
logger.info(msg)
paths += searched_paths

from collections import Counter
skip_node_counts = Counter(skip_nodes)
for name, count in skip_node_counts.items():
logger.warn(f'skip due to callback construction_order over'
f'({max_construction_order}): {name} ({count})')

self._data = paths

@property
Expand Down
2 changes: 1 addition & 1 deletion src/caret_analyze/infra/lttng/event_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _validate(self):

# For after iron distributions
# No need to check trace points added by fork-rclcpp
if self._distribution in ['iron', 'rolling']:
if self._distribution[0] >= 'i':
return

has_forked_inter_process_trace_points = len(
Expand Down
2 changes: 1 addition & 1 deletion src/caret_analyze/infra/lttng/records_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def intra_proc_comm_records(self) -> RecordsInterface:
- message_timestamp

"""
if self._info.get_distribution() in ['iron', 'rolling']:
if self._info.get_distribution()[0] >= 'i':
return self.intra_proc_comm_records_iron

sink_records = self._data.dispatch_intra_process_subscription_callback_instances
Expand Down
4 changes: 0 additions & 4 deletions src/caret_analyze/plot/histogram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .histogram import ResponseTimeHistPlot
from .histogram_factory import ResponseTimeHistPlotFactory
from .histogram_plot import HistogramPlot
from .histogram_plot_factory import HistogramPlotFactory

__all__ = [
'ResponseTimeHistPlot',
'ResponseTimeHistPlotFactory',
'HistogramPlotFactory',
'HistogramPlot'
]
64 changes: 0 additions & 64 deletions src/caret_analyze/plot/histogram/histogram.py

This file was deleted.

43 changes: 0 additions & 43 deletions src/caret_analyze/plot/histogram/histogram_factory.py

This file was deleted.

Loading
Loading