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

Method submit_file

paddleocr/_api_client/_http.py:126–157  ·  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

124 return _job_id_from_response(resp)
125
126 def submit_file(
127 self,
128 model: str,
129 file_path: str,
130 optional_payload: dict,
131 page_ranges: Optional[str] = None,
132 batch_id: Optional[str] = None,
133 ) -> str:
134 if not os.path.exists(file_path):
135 raise FileNotFoundError(file_path)
136 data = {
137 "model": model,
138 "optionalPayload": json.dumps(optional_payload),
139 }
140 if page_ranges is not None:
141 data["pageRanges"] = page_ranges
142 if batch_id is not None:
143 data["batchId"] = batch_id
144 try:
145 with open(file_path, "rb") as f:
146 resp = self._session.post(
147 self._jobs_url,
148 data=data,
149 files={"file": f},
150 timeout=self._timeout,
151 )
152 except requests.Timeout as e:
153 raise RequestTimeoutError(f"Request timed out: {e}") from e
154 except requests.ConnectionError as e:
155 raise NetworkError(f"Connection failed: {e}") from e
156 _raise_for_response(resp)
157 return _job_id_from_response(resp)
158
159 def get_job_status(self, job_id: str) -> Dict[str, Any]:
160 try:

Callers 2

_submitMethod · 0.45
_submitMethod · 0.45

Calls 6

_raise_for_responseFunction · 0.85
_job_id_from_responseFunction · 0.85
RequestTimeoutErrorClass · 0.70
NetworkErrorClass · 0.70
FileNotFoundErrorStruct · 0.50
postMethod · 0.45

Tested by

no test coverage detected