Skip to content

refactor#139

Open
teith wants to merge 4 commits intomainfrom
refactor
Open

refactor#139
teith wants to merge 4 commits intomainfrom
refactor

Conversation

@teith
Copy link
Contributor

@teith teith commented Jul 24, 2025

refactor

@teith teith self-assigned this Jul 24, 2025
@teith teith requested review from D1-3105, bghira and felixsanz July 24, 2025 18:09
@teith teith changed the title Refactor refactor Jul 24, 2025
aiofiles==23.2.1
python-dotenv==1.0.1
websockets
websockets>=12.0,<16.0 No newline at end of file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need <?

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()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not seem to cancel, does opaque operation instead

self._timeout_task = asyncio.create_task(self._handle_timeout(timeout))

try:
return await self.execute()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from e

Comment on lines +12 to +21
field_mappings = {
"taskType": "taskType",
"imageUUID": "imageUUID",
"taskUUID": "taskUUID",
"inputImageUUID": "inputImageUUID",
"imageURL": "imageURL",
"imageBase64Data": "imageBase64Data",
"imageDataURI": "imageDataURI",
"cost": "cost",
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks strange

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,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from e

logger.debug(
f"Operation {self.operation_id} handling prompt enhance message: {message}"
)
enhanced_prompt = self._parse_response(message)
Copy link

@D1-3105 D1-3105 Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's blocking and cpu bound, rewrite in parallel manner w/ threads

Comment on lines +711 to +716
IKlingAIProviderSettings
| IGoogleProviderSettings
| IMinimaxProviderSettings
| IBytedanceProviderSettings
| IPixverseProviderSettings
| IViduProviderSettings
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python3.8 incompatible. is it okay?

"aiofiles==23.2.1",
"python-dotenv==1.0.1",
"websockets==12.0",
"websockets>=12.0,<16.0",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the point of <16.0

@MunazaAshraf10 MunazaAshraf10 self-requested a review July 25, 2025 19:23

def __init__(self, max_workers: int = None):
self._executor = ThreadPoolExecutor(max_workers=max_workers)
self._loop = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default mutable types (results, metadata) can be set via field(default_factory=list/dict)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants