From 9e9c3a1f50b219d4ccadc2ac134f2ce43efca471 Mon Sep 17 00:00:00 2001 From: yelihua Date: Thu, 12 Nov 2020 14:46:05 +0800 Subject: [PATCH] change debugger restful url and fix the docstring --- mindinsight/backend/debugger/debugger_api.py | 8 ++++---- mindinsight/debugger/debugger_server.py | 1 - .../debugger/stream_cache/debugger_graph.py | 1 - .../debugger/stream_cache/debugger_multigraph.py | 4 +++- mindinsight/debugger/stream_cache/watchpoint.py | 1 - .../debugger/stream_handler/tensor_handler.py | 3 --- .../debugger/stream_handler/watchpoint_handler.py | 4 ---- tests/st/func/debugger/test_restful_api.py | 4 ++-- .../debugger/stream_handler/test_tensor_handler.py | 14 +++++--------- 9 files changed, 14 insertions(+), 26 deletions(-) diff --git a/mindinsight/backend/debugger/debugger_api.py b/mindinsight/backend/debugger/debugger_api.py index 63f5bb01..1c65c9cb 100644 --- a/mindinsight/backend/debugger/debugger_api.py +++ b/mindinsight/backend/debugger/debugger_api.py @@ -312,7 +312,7 @@ def recheck(): return reply -@BLUEPRINT.route("/debugger/tensor_graphs", methods=["GET"]) +@BLUEPRINT.route("/debugger/tensor-graphs", methods=["GET"]) def retrieve_tensor_graph(): """ Retrieve tensor value according to name and shape. @@ -321,7 +321,7 @@ def retrieve_tensor_graph(): str, the required data. Examples: - >>> GET http://xxxx/v1/mindinsight/debugger/tensor_graphs?tensor_name=tensor_name$graph_name=graph_name + >>> GET http://xxxx/v1/mindinsight/debugger/tensor-graphs?tensor_name=tensor_name&graph_name=graph_name """ tensor_name = request.args.get('tensor_name') graph_name = request.args.get('graph_name') @@ -329,7 +329,7 @@ def retrieve_tensor_graph(): return reply -@BLUEPRINT.route("/debugger/tensor_hits", methods=["GET"]) +@BLUEPRINT.route("/debugger/tensor-hits", methods=["GET"]) def retrieve_tensor_hits(): """ Retrieve tensor value according to name and shape. @@ -338,7 +338,7 @@ def retrieve_tensor_hits(): str, the required data. Examples: - >>> GET http://xxxx/v1/mindinsight/debugger/tensor_hits?tensor_name=tensor_name$graph_name=graph_name + >>> GET http://xxxx/v1/mindinsight/debugger/tensor-hits?tensor_name=tensor_name&graph_name=graph_name """ tensor_name = request.args.get('tensor_name') graph_name = request.args.get('graph_name') diff --git a/mindinsight/debugger/debugger_server.py b/mindinsight/debugger/debugger_server.py index e80b46ce..89704973 100644 --- a/mindinsight/debugger/debugger_server.py +++ b/mindinsight/debugger/debugger_server.py @@ -478,7 +478,6 @@ class DebuggerServer: } - id (str): Id of condition. - - params (list[dict]): The list of param for this condition. watch_nodes (list[str]): The list of node names. watch_point_id (int): The id of watchpoint. diff --git a/mindinsight/debugger/stream_cache/debugger_graph.py b/mindinsight/debugger/stream_cache/debugger_graph.py index cce33ab5..690c9967 100644 --- a/mindinsight/debugger/stream_cache/debugger_graph.py +++ b/mindinsight/debugger/stream_cache/debugger_graph.py @@ -123,7 +123,6 @@ class DebuggerGraph(MSGraph): - activation_func (Union[str, list[str]): The target functions. Used when node_type is TargetTypeEnum.ACTIVATION. - - search_range (list[Node]): The list of nodes to be searched from. Returns: diff --git a/mindinsight/debugger/stream_cache/debugger_multigraph.py b/mindinsight/debugger/stream_cache/debugger_multigraph.py index 22fbbb7c..d100a396 100644 --- a/mindinsight/debugger/stream_cache/debugger_multigraph.py +++ b/mindinsight/debugger/stream_cache/debugger_multigraph.py @@ -18,12 +18,14 @@ from mindinsight.debugger.common.log import LOGGER as log from mindinsight.datavisual.data_transform.graph.node import Node, NodeTypeEnum from .debugger_graph import DebuggerGraph + class DebuggerMultiGraph(DebuggerGraph): """The `DebuggerMultiGraph` object provides interfaces to describe a debugger multigraph.""" def add_graph(self, graph_dict): """ - add graphs to DebuggerMultiGraph + Add graphs to DebuggerMultiGraph. + Args: graph_dict (dict): The dict. """ diff --git a/mindinsight/debugger/stream_cache/watchpoint.py b/mindinsight/debugger/stream_cache/watchpoint.py index 04c6196f..146c9f69 100644 --- a/mindinsight/debugger/stream_cache/watchpoint.py +++ b/mindinsight/debugger/stream_cache/watchpoint.py @@ -178,7 +178,6 @@ class Watchpoint: watch_condition (dict): The condition of Watchpoint. - condition (str): Accept `INF` or `NAN`. - - param (list[float]): Not defined yet. """ diff --git a/mindinsight/debugger/stream_handler/tensor_handler.py b/mindinsight/debugger/stream_handler/tensor_handler.py index 45678431..1773b92b 100644 --- a/mindinsight/debugger/stream_handler/tensor_handler.py +++ b/mindinsight/debugger/stream_handler/tensor_handler.py @@ -50,7 +50,6 @@ class TensorHandler(StreamHandlerBase): value (dict): The Tensor proto message. - step (int): The current step of tensor. - - tensor_protos (list[TensorProto]): The tensor proto. Returns: @@ -153,9 +152,7 @@ class TensorHandler(StreamHandlerBase): filter_condition (dict): Filter condition. - name (str): The full name of tensor. - - node_type (str): The type of the node. - - prev (bool): Whether to get previous tensor. Returns: diff --git a/mindinsight/debugger/stream_handler/watchpoint_handler.py b/mindinsight/debugger/stream_handler/watchpoint_handler.py index 6c40c5a2..0079e242 100644 --- a/mindinsight/debugger/stream_handler/watchpoint_handler.py +++ b/mindinsight/debugger/stream_handler/watchpoint_handler.py @@ -389,11 +389,8 @@ class WatchpointHitHandler(StreamHandlerBase): value (dict): The watchpoint hit info. - tensor_proto (TensorProto): The message about hit tensor. - - watchpoint (Watchpoint): The Watchpoint that a node hit. - - node_name (str): The UI node name. - - graph_name (str): The graph name. """ watchpoint_hit = WatchpointHit( @@ -561,7 +558,6 @@ def validate_watch_condition_params(condition_mgr, watch_condition): watch_condition (dict): Watch condition. - id (str): Condition id. Should be in WATCHPOINT_CONDITION_MAPPING. - - param (list): Condition value. Should be given for comparison condition. The value will be translated to np.float32. """ diff --git a/tests/st/func/debugger/test_restful_api.py b/tests/st/func/debugger/test_restful_api.py index b1fe41b1..e45165d8 100644 --- a/tests/st/func/debugger/test_restful_api.py +++ b/tests/st/func/debugger/test_restful_api.py @@ -379,7 +379,7 @@ class TestAscendDebugger: ]) def test_retrieve_tensor_graph(self, app_client, body_data, expect_file): """Test retrieve tensor graph.""" - url = 'tensor_graphs' + url = 'tensor-graphs' with self._debugger_client.get_thread_instance(): create_watchpoint_and_wait(app_client) send_and_compare_result(app_client, url, body_data, expect_file, method='GET') @@ -637,7 +637,7 @@ class TestMultiGraphDebugger: ]) def test_retrieve_tensor_hits(self, app_client, body_data, expect_file): """Test retrieve tensor graph.""" - url = 'tensor_hits' + url = 'tensor-hits' with self._debugger_client.get_thread_instance(): check_waiting_state(app_client) send_and_compare_result(app_client, url, body_data, expect_file, method='GET') diff --git a/tests/ut/debugger/stream_handler/test_tensor_handler.py b/tests/ut/debugger/stream_handler/test_tensor_handler.py index 53846327..33d321bd 100644 --- a/tests/ut/debugger/stream_handler/test_tensor_handler.py +++ b/tests/ut/debugger/stream_handler/test_tensor_handler.py @@ -25,19 +25,17 @@ class TestTensorHandler: """Test TensorHandler.""" def setup_method(self): + """Setup method for each test case.""" self.tensor_handler = TensorHandler() @mock.patch.object(TensorHandler, '_get_tensor') @mock.patch.object(log, "error") - @pytest.mark.parametrize("filter_condition", {}) - def test_get(self, mock_get_tensor, mock_error, filter_condition): - """ - Test get full tensor value. - """ + def test_get(self, mock_get_tensor, mock_error): + """Test get full tensor value.""" mock_get_tensor.return_value = None mock_error.return_value = None with pytest.raises(DebuggerParamValueError) as ex: - self.tensor_handler.get(filter_condition) + self.tensor_handler.get({}) assert "No tensor named {}".format(None) in str(ex.value) def test_get_tensor_value_by_name_none(self): @@ -48,9 +46,7 @@ class TestTensorHandler: @mock.patch.object(log, "error") @pytest.mark.parametrize("tensor_name", "name") def test_get_tensors_diff_error(self, mock_error, tensor_name): - """ - Test get_tensors_diff. - """ + """Test get_tensors_diff.""" mock_error.return_value = None with pytest.raises(DebuggerParamValueError) as ex: self.tensor_handler.get_tensors_diff(tensor_name, {1, 1})