MCPcopy Create free account
hub / github.com/PaddlePaddle/PaddleOCR / submit_file

Method submit_file

paddleocr/_api_client/_async_http.py:108–139  ·  view source on GitHub ↗
(
        self,
        model: str,
        file_path: str,
        optional_payload: dict,
        page_ranges: Optional[str] = None,
        batch_id: Optional[str] = None,
    )

Source from the content-addressed store, hash-verified

106 return extract_job_id(data)
107
108 async def submit_file(
109 self,
110 model: str,
111 file_path: str,
112 optional_payload: dict,
113 page_ranges: Optional[str] = None,
114 batch_id: Optional[str] = None,
115 ) -> str:
116 if not os.path.exists(file_path):
117 raise FileNotFoundError(file_path)
118
119 form = aiohttp.FormData()
120 form.add_field("model", model)
121 form.add_field("optionalPayload", json.dumps(optional_payload))
122 if page_ranges is not None:
123 form.add_field("pageRanges", page_ranges)
124 if batch_id is not None:
125 form.add_field("batchId", batch_id)
126
127 with open(file_path, "rb") as f:
128 file_data = f.read()
129 form.add_field(
130 "file",
131 file_data,
132 filename=os.path.basename(file_path),
133 )
134
135 await self._ensure_session()
136 async with self._session.post(self._jobs_url, data=form) as resp:
137 await self._raise_for_response(resp)
138 data = await self._response_data(resp)
139 return extract_job_id(data)
140
141 async def get_job_status(self, job_id: str) -> Dict[str, Any]:
142 await self._ensure_session()

Callers

nothing calls this directly

Calls 6

_ensure_sessionMethod · 0.95
_raise_for_responseMethod · 0.95
_response_dataMethod · 0.95
extract_job_idFunction · 0.85
FileNotFoundErrorStruct · 0.50
postMethod · 0.45

Tested by

no test coverage detected