-
Notifications
You must be signed in to change notification settings - Fork 25
funasr support payload.input and bug fix in transcription #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,14 +167,20 @@ def wait( | |
| task: Union[str, TranscriptionResponse], # type: ignore[override] | ||
| api_key: str = None, | ||
| workspace: str = None, | ||
| wait_timeout: int = -1, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that |
||
| **kwargs, | ||
| ) -> TranscriptionResponse: | ||
| """Poll task until the final results of transcription is obtained. | ||
|
|
||
| Args: | ||
| task (Union[str, TranscriptionResponse]): The task_id or | ||
| response including task_id returned from async_call(). | ||
| api_key (str, optional): The api_key. Defaults to None. | ||
| workspace (str): The dashscope workspace id. | ||
| wait_timeout (int, optional): The timeout for waiting. | ||
| Defaults to -1.That means no timeout. | ||
| If set to a value > 0, the task does not complete | ||
| within this time, a timeout error response will be returned. | ||
|
|
||
| Returns: | ||
| TranscriptionResponse: The result of batch transcription. | ||
|
|
@@ -183,6 +189,7 @@ def wait( | |
| task, | ||
| api_key=api_key, | ||
| workspace=workspace, | ||
| wait_timeout=wait_timeout, | ||
| **kwargs, | ||
| ) | ||
| return TranscriptionResponse.from_api_response(response) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -191,6 +191,7 @@ async def wait( | |
| task: Union[str, DashScopeAPIResponse], | ||
| api_key: str = None, | ||
| workspace: str = None, | ||
| wait_timeout: int = -1, | ||
| **kwargs, | ||
| ) -> DashScopeAPIResponse: | ||
| """Wait for async task completion and return task result. | ||
|
|
@@ -199,6 +200,12 @@ async def wait( | |
| task (Union[str, DashScopeAPIResponse]): The task_id, or | ||
| async_call response. | ||
| api_key (str, optional): The api_key. Defaults to None. | ||
| workspace (str, optional): The dashscope workspace id. | ||
| wait_timeout (int, optional): The maximum seconds to wait | ||
| for the task to complete. Default is -1, which means no | ||
| timeout. When set to a value > 0, if the task does not | ||
| complete within this time, a timeout error response will | ||
| be returned. | ||
|
|
||
| Returns: | ||
| DashScopeAPIResponse: The async task information. | ||
|
|
@@ -208,6 +215,7 @@ async def wait( | |
| max_wait_seconds = 5 | ||
| increment_steps = 3 | ||
| step = 0 | ||
| start_time = time.time() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| while True: | ||
| step += 1 | ||
| # we start by querying once every second, and double | ||
|
|
@@ -217,6 +225,21 @@ async def wait( | |
| # (server side return immediately when ready) | ||
| if wait_seconds < max_wait_seconds and step % increment_steps == 0: | ||
| wait_seconds = min(wait_seconds * 2, max_wait_seconds) | ||
| if 0 < wait_timeout <= (time.time() - start_time): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| logger.warning( | ||
| "Wait task: %s timeout after %s seconds.", | ||
| task_id, | ||
| wait_timeout, | ||
| ) | ||
| return DashScopeAPIResponse( | ||
| request_id=task_id, | ||
| status_code=HTTPStatus.REQUEST_TIMEOUT, | ||
| code="WaitTaskTimeout", | ||
| message=( | ||
| f"Wait task: {task_id} timeout after " | ||
| f"{wait_timeout} seconds." | ||
| ), | ||
| ) | ||
| rsp = await cls._get( | ||
| task_id, | ||
| api_key, | ||
|
|
@@ -767,6 +790,7 @@ def wait( | |
| task: Union[str, DashScopeAPIResponse], | ||
| api_key: str = None, | ||
| workspace: str = None, | ||
| wait_timeout: int = -1, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While |
||
| **kwargs, | ||
| ) -> DashScopeAPIResponse: | ||
| """Wait for async task completion and return task result. | ||
|
|
@@ -775,6 +799,12 @@ def wait( | |
| task (Union[str, DashScopeAPIResponse]): The task_id, or | ||
| async_call response. | ||
| api_key (str, optional): The api_key. Defaults to None. | ||
| workspace (str, optional): The dashscope workspace id. | ||
| wait_timeout (int, optional): The maximum seconds to wait | ||
| for the task to complete. Default is -1, which means no | ||
| timeout. When set to a value > 0, if the task does not | ||
| complete within this time, a timeout error response will | ||
| be returned. | ||
|
|
||
| Returns: | ||
| DashScopeAPIResponse: The async task information. | ||
|
|
@@ -784,6 +814,7 @@ def wait( | |
| max_wait_seconds = 5 | ||
| increment_steps = 3 | ||
| step = 0 | ||
| start_time = time.time() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| while True: | ||
| step += 1 | ||
| # we start by querying once every second, and double | ||
|
|
@@ -794,6 +825,21 @@ def wait( | |
| # (server side return immediately when ready) | ||
| if wait_seconds < max_wait_seconds and step % increment_steps == 0: | ||
| wait_seconds = min(wait_seconds * 2, max_wait_seconds) | ||
| if 0 < wait_timeout <= (time.time() - start_time): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| logger.warning( | ||
| "Wait task: %s timeout after %s seconds.", | ||
| task_id, | ||
| wait_timeout, | ||
| ) | ||
| return DashScopeAPIResponse( | ||
| request_id=task_id, | ||
| status_code=HTTPStatus.REQUEST_TIMEOUT, | ||
| code="WaitTaskTimeout", | ||
| message=( | ||
| f"Wait task: {task_id} timeout after " | ||
| f"{wait_timeout} seconds." | ||
| ), | ||
| ) | ||
| rsp = cls._get(task_id, api_key, workspace=workspace, **kwargs) | ||
| if rsp.status_code == HTTPStatus.OK: | ||
| if rsp.output is None: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mutating
self.parametersin-place inside_only_parameters()introduces side effects. If the request is retried, logged, or reused,raw_inputwill be permanently missing fromself.parameters. Copyingself.parametersbefore popping avoids this side effect.