Skip to content

Commit 6f4a426

Browse files
authored
[Feat] Log log_id in HPS server (#4698)
* Log log_id * Fix bug * Fix unhashable bug
1 parent 6ae34b1 commit 6f4a426

File tree

2 files changed

+33
-17
lines changed
  • deploy/hps
    • sdk/pipelines/PaddleOCR-VL/server/model_repo/layout-parsing/1
    • server_env/paddlex-hps-server/src/paddlex_hps_server

2 files changed

+33
-17
lines changed

deploy/hps/sdk/pipelines/PaddleOCR-VL/server/model_repo/layout-parsing/1/model.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def get_result_model_type(self):
8181
return schemas.paddleocr_vl.InferResult
8282

8383
def run(self, input, log_id):
84-
return self.run_batch([input], [log_id])
84+
return self.run_batch([input], [log_id], log_id)
8585

8686
def run_batch(self, inputs, log_ids, batch_id):
8787
result_or_output_dic = {}
@@ -170,24 +170,39 @@ def run_batch(self, inputs, log_ids, batch_id):
170170
return [result_or_output_dic[i] for i in range(len(inputs))]
171171

172172
def _group_inputs(self, inputs):
173+
def _to_hashable(obj):
174+
if isinstance(obj, list):
175+
return tuple(obj)
176+
elif isinstance(obj, dict):
177+
return tuple(sorted(obj.items()))
178+
else:
179+
return obj
180+
173181
def _hash(input):
174182
return hash(
175-
(
176-
input.useDocOrientationClassify,
177-
input.useDocUnwarping,
178-
input.useLayoutDetection,
179-
input.useChartRecognition,
180-
input.layoutThreshold,
181-
input.layoutNms,
182-
input.layoutUnclipRatio,
183-
input.layoutMergeBboxesMode,
184-
input.promptLabel,
185-
input.formatBlockContent,
186-
input.repetitionPenalty,
187-
input.temperature,
188-
input.topP,
189-
input.minPixels,
190-
input.maxPixels,
183+
tuple(
184+
map(
185+
_to_hashable,
186+
(
187+
(
188+
input.useDocOrientationClassify,
189+
input.useDocUnwarping,
190+
input.useLayoutDetection,
191+
input.useChartRecognition,
192+
input.layoutThreshold,
193+
input.layoutNms,
194+
input.layoutUnclipRatio,
195+
input.layoutMergeBboxesMode,
196+
input.promptLabel,
197+
input.formatBlockContent,
198+
input.repetitionPenalty,
199+
input.temperature,
200+
input.topP,
201+
input.minPixels,
202+
input.maxPixels,
203+
)
204+
),
205+
)
191206
)
192207
)
193208

deploy/hps/server_env/paddlex-hps-server/src/paddlex_hps_server/base_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def execute(self, requests):
9191
log_ids = []
9292
for i, request in enumerate(requests):
9393
log_id = protocol.generate_log_id()
94+
logging.info("Request %s received", log_id)
9495
log_ids.append(log_id)
9596
input_ = pb_utils.get_input_tensor_by_name(
9697
request, constants.INPUT_NAME

0 commit comments

Comments
 (0)