Skip to content

Commit

Permalink
Generalize siblings dict generation (breaking)
Browse files Browse the repository at this point in the history
Breaking compatibility with old models to make alternative sibilings
dict generation more self-adjustable to new decision tags.
  • Loading branch information
iburakov committed Aug 31, 2023
1 parent a52fba6 commit ffa27ff
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions ml/synthesis/src/components/data_crawling/node/node_converting.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from collections import defaultdict
from typing import Iterable

from components.common.nitta_node import NittaNode
Expand Down Expand Up @@ -44,26 +45,11 @@ def _extract_params_dict(node: NittaNode) -> dict:


def _extract_alternative_siblings_dict(node: NittaNode, siblings: Iterable[NittaNode]) -> dict:
# this could be refactored to simply get a count per decision tag,
# but backwards compatibility with old models will be broken
result = {
"alt_bindings": 0,
"alt_group_bindings": 0,
"alt_dataflows": 0,
"alt_refactorings": 0,
}
result: defaultdict[str, int] = defaultdict(lambda: 0)

for sibling in siblings:
if sibling.sid == node.sid:
continue
if sibling.decision_tag == _SINGLE_BIND_DECISION_TAG:
result["alt_bindings"] += 1
elif sibling.decision_tag == _GROUP_BIND_DECISION_TAG:
result["alt_group_bindings"] += 1
elif sibling.decision_tag in _DATAFLOW_DECISION_TAGS:
result["alt_dataflows"] += 1
else:
# refactorings have arbitrary decision tags
result["alt_refactorings"] += 1
result[f"siblings_{sibling.decision_tag}"] += 1

return result
return dict(result)

0 comments on commit ffa27ff

Please sign in to comment.