(
self,
model: str,
file_path: str,
optional_payload: dict,
page_ranges: Optional[str] = None,
batch_id: Optional[str] = None,
)
| 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: |
no test coverage detected