Skip to content

Commit

Permalink
fix: fix test with routes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoanFM committed Nov 10, 2022
1 parent 87c36ff commit e1eec52
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 2 additions & 4 deletions jina/serve/runtimes/gateway/graph/topology_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,8 @@ async def _wait_previous_and_send(
request.parameters = _parse_specific_params(
request.parameters, self.name
)
if copy_request_at_send:
self.parts_to_send.append(copy.deepcopy(request))
else:
self.parts_to_send.append(request)
req_to_send = copy.deepcopy(request) if copy_request_at_send else request
self.parts_to_send.append(req_to_send)
# this is a specific needs
if len(self.parts_to_send) == self.number_of_parts:
self.start_time = datetime.utcnow()
Expand Down
9 changes: 8 additions & 1 deletion jina/serve/runtimes/gateway/request_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from jina.excepts import InternalNetworkError
from jina.importer import ImportExtensions
from jina.helper import GATEWAY_NAME
from jina.proto import jina_pb2
from jina.serve.networking import GrpcConnectionPool
from jina.serve.runtimes.gateway.graph.topology_graph import TopologyGraph
Expand Down Expand Up @@ -346,7 +347,7 @@ async def _process_results_at_end_gateway(
asyncio.create_task(gather_endpoints(request_graph))

partial_responses = await asyncio.gather(*tasks)
except Exception as e:
except Exception:
# update here failed request
self._update_end_failed_requests_metrics()
raise
Expand All @@ -356,6 +357,12 @@ async def _process_results_at_end_gateway(
)

response = filtered_partial_responses[0]
# JoanFM: to keep the docs_map feature, need to add the routes in the WorkerRuntime but clear it here
# so that routes are properly done. not very clean but refactoring would be costly for such a small
# thing, `docs_map` reuses routes potentially not in the best way but works for now
for i in reversed(range(len(response.routes))):
if response.routes[i].executor != GATEWAY_NAME:
del response.routes[i]
request_graph.add_routes(response)

if graph.has_filter_conditions:
Expand Down
1 change: 1 addition & 0 deletions jina/types/request/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ def add_executor(self, executor_name: str):
"""
route_proto = jina_pb2.RouteProto()
route_proto.executor = executor_name
print(f' type {type(self.proto_wo_data.routes)}')
self.proto_wo_data.routes.append(route_proto)

@property
Expand Down

0 comments on commit e1eec52

Please sign in to comment.