Conversation
D1-3105
requested changes
Jul 25, 2025
| aiofiles==23.2.1 | ||
| python-dotenv==1.0.1 | ||
| websockets | ||
| websockets>=12.0,<16.0 No newline at end of file |
Comment on lines
+284
to
+302
| async def cancel(self): | ||
| """Cancel the operation.""" | ||
| if self.status in [ | ||
| OperationStatus.COMPLETED, | ||
| OperationStatus.FAILED, | ||
| OperationStatus.CANCELLED, | ||
| OperationStatus.TIMEOUT, | ||
| ]: | ||
| return | ||
|
|
||
| if self._is_cancelled: | ||
| return | ||
|
|
||
| self._is_cancelled = True | ||
| self.status = OperationStatus.CANCELLED | ||
| self.logger.info(f"Cancelling operation {self.operation_id}") | ||
|
|
||
| self.completion_event.set() | ||
| await self._cleanup() |
There was a problem hiding this comment.
does not seem to cancel, does opaque operation instead
| self._timeout_task = asyncio.create_task(self._handle_timeout(timeout)) | ||
|
|
||
| try: | ||
| return await self.execute() |
There was a problem hiding this comment.
should be an opportunity to cancel it too?
| except Exception as e: | ||
| wrapped = error_ctx.wrap_error(e) | ||
| await self._handle_error(wrapped) | ||
| raise wrapped |
Comment on lines
+12
to
+21
| field_mappings = { | ||
| "taskType": "taskType", | ||
| "imageUUID": "imageUUID", | ||
| "taskUUID": "taskUUID", | ||
| "inputImageUUID": "inputImageUUID", | ||
| "imageURL": "imageURL", | ||
| "imageBase64Data": "imageBase64Data", | ||
| "imageDataURI": "imageDataURI", | ||
| "cost": "cost", | ||
| } |
Comment on lines
+86
to
+90
| raise RunwareOperationError( | ||
| f"Failed to parse model search response: {e}", | ||
| operation_id=self.operation_id, | ||
| operation_type=self.operation_type, | ||
| ) |
| logger.debug( | ||
| f"Operation {self.operation_id} handling prompt enhance message: {message}" | ||
| ) | ||
| enhanced_prompt = self._parse_response(message) |
There was a problem hiding this comment.
it's cpu bound and blocking, do it in a separated thread
| logger.debug( | ||
| f"Operation {self.operation_id} building video inference request payload" | ||
| ) | ||
| await self._process_video_images() |
There was a problem hiding this comment.
it's blocking and cpu bound, rewrite in parallel manner w/ threads
Comment on lines
+711
to
+716
| IKlingAIProviderSettings | ||
| | IGoogleProviderSettings | ||
| | IMinimaxProviderSettings | ||
| | IBytedanceProviderSettings | ||
| | IPixverseProviderSettings | ||
| | IViduProviderSettings |
| "aiofiles==23.2.1", | ||
| "python-dotenv==1.0.1", | ||
| "websockets==12.0", | ||
| "websockets>=12.0,<16.0", |
|
|
||
| def __init__(self, max_workers: int = None): | ||
| self._executor = ThreadPoolExecutor(max_workers=max_workers) | ||
| self._loop = None |
Contributor
There was a problem hiding this comment.
instead of self._loop we can also use asyncio.get_running_loop()
| error: Optional[Exception] = None | ||
| start_time: Optional[float] = None | ||
| end_time: Optional[float] = None | ||
| metadata: Dict[str, Any] = None |
Contributor
There was a problem hiding this comment.
Default mutable types (results, metadata) can be set via field(default_factory=list/dict)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refactor