Definitions by Name and Root Evaluations - DevOps-MBSE/AaC GitHub Wiki

get_definitions_by_name

During earlier unit test enhancement work it was noted that the language_context.py get_definitions_by_name method did not return any kind of error or exception when no matches were found. Rather, an empty list was returned. An analysis was done of the methods that call the get_definitions_by_name method and how they handle the resulting list, especially in cases where an empty list. The analysis showed that in all cases the calling method properly handled the results. In most cases a LanguageError was raised if a list with only a single entry was not returned. In some cases this was expanded upon by two different LanguageErrors being generated: one for no entries in the list versus one for multiple entries in the list. In cases where a user interaction is likely involved the ExecutionMessage construct was used to document the results to the user.

One peculiar case was noted during the investigation. The python_helpers.py schema_to_test_dict method does call get_definitions_by_name and raises an Exception if exactly one definition is not returned. An analysis of the second order calling methods (the methods which call the methods which call get_definitions_by_name) shows that schema_to_test_dict is only called by itself. This method appears to be leftover 'dead' code from an earlier substantial Architecture-as-Code refactor effort.

get_definitions_by_root

During earlier unit test enhancement work it was noted that the language_context.py get_definitions_by_root method did not return any kind of error or exception when no matches were found. Rather, an empty list was returned. An analysis was done of the methods that call the get_definitions_by_root method and how they handle the resulting list, especially in cases where an empty list. The analysis showed that in all cases the calling method properly handled the results. In most cases a loop is executed which appeared to handle the empty list case. For instance, the constraint_assignment_arguments_impl.py method _find_constraint_definition sets a return list to empty. It uses the results from get_definitions_by_root to control the repetition of several for loops. In the case of an empty list result from get_definitions_by_root the loop content will not be exercised. The docstring for _find_constraint_definition already documents that an empty return list should be expected in the case of "match not found".

One peculiar case was noted during the investigation. The python_helpers.py schema_to_test_dict method does utilize the get_definitions_by_root by way of get_python_primitive->get_primitives->get_definitions_by_root. An analysis of the third order calling methods shows that schema_to_test_dict is only called by itself. This method appears to be leftover 'dead' code from an earlier substantial Architecture-as-Code refactor effort.

Call Trace File for get_definitions_by_name and get_definitions_by_root

get_definitions_by_X.txt