MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _dispatch_command

Method _dispatch_command

tensorflow/python/debug/cli/curses_ui.py:661–764  ·  view source on GitHub ↗

Dispatch user command. Args: command: (str) Command to dispatch. Returns: An exit token object. None value means that the UI loop should not exit. A non-None value means the UI loop should exit.

(self, command)

Source from the content-addressed store, hash-verified

659 self._scroll_output(_SCROLL_TO_LINE_INDEX, line_index=scroll_position)
660
661 def _dispatch_command(self, command):
662 """Dispatch user command.
663
664 Args:
665 command: (str) Command to dispatch.
666
667 Returns:
668 An exit token object. None value means that the UI loop should not exit.
669 A non-None value means the UI loop should exit.
670 """
671
672 if self._output_pad:
673 self._toast(self._UI_WAIT_MESSAGE, color=self._UI_WAIT_COLOR_PAIR)
674
675 if command in self.CLI_EXIT_COMMANDS:
676 # Explicit user command-triggered exit: EXPLICIT_USER_EXIT as the exit
677 # token.
678 return debugger_cli_common.EXPLICIT_USER_EXIT
679 elif (command == self._NAVIGATION_FORWARD_COMMAND or
680 command == self._NAVIGATION_BACK_COMMAND):
681 self._navigate_screen_output(command)
682 return
683
684 if command:
685 self._command_history_store.add_command(command)
686
687 if (command.startswith(self.REGEX_SEARCH_PREFIX) and
688 self._curr_unwrapped_output):
689 if len(command) > len(self.REGEX_SEARCH_PREFIX):
690 # Command is like "/regex". Perform regex search.
691 regex = command[len(self.REGEX_SEARCH_PREFIX):]
692
693 self._curr_search_regex = regex
694 self._display_output(self._curr_unwrapped_output, highlight_regex=regex)
695 elif self._unwrapped_regex_match_lines:
696 # Command is "/". Continue scrolling down matching lines.
697 self._display_output(
698 self._curr_unwrapped_output,
699 is_refresh=True,
700 highlight_regex=self._curr_search_regex)
701
702 self._command_pointer = 0
703 self._pending_command = ""
704 return
705 elif command.startswith(self.TENSOR_INDICES_NAVIGATION_PREFIX):
706 indices_str = command[1:].strip()
707 if indices_str:
708 try:
709 indices = command_parser.parse_indices(indices_str)
710 omitted, line_index, _, _ = tensor_format.locate_tensor_element(
711 self._curr_wrapped_output, indices)
712 if not omitted:
713 self._scroll_output(
714 _SCROLL_TO_LINE_INDEX, line_index=line_index)
715 except Exception as e: # pylint: disable=broad-except
716 self._error_toast(str(e))
717 else:
718 self._error_toast("Empty indices.")

Callers 3

run_uiMethod · 0.95
_ui_loopMethod · 0.95
_on_textbox_keypressMethod · 0.95

Calls 13

_toastMethod · 0.95
_display_outputMethod · 0.95
_scroll_outputMethod · 0.95
_error_toastMethod · 0.95
write_to_fileMethod · 0.95
_info_toastMethod · 0.95
add_commandMethod · 0.80
stripMethod · 0.80
_parse_commandMethod · 0.80
is_registeredMethod · 0.80
dispatch_commandMethod · 0.80

Tested by

no test coverage detected