Skip to content

Commit a4d4a85

Browse files
committed
fix after review
1 parent 0e38033 commit a4d4a85

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

src/yandex_cloud_ml_sdk/_runs/domain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
class BaseRuns(BaseDomain, Generic[RunTypeT]):
2929
"""
30-
Abstract class for Runs operations with configurable RunTypeT.
30+
Class for Runs operations.
3131
Provides core functionality for managing assistant execution in streams.
3232
3333
For usage examples see `runs example <https://github.com/yandex-cloud/yandex-cloud-ml-sdk/blob/master/examples/{link}/assistants/runs.py>`_.

src/yandex_cloud_ml_sdk/_runs/result.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
from yandex_cloud_ml_sdk._models.completions.result import Usage
1414
from yandex_cloud_ml_sdk._tools.tool_call import HaveToolCalls, ToolCallTypeT
1515
from yandex_cloud_ml_sdk._tools.tool_call_list import ProtoAssistantToolCallList, ToolCallList
16+
from yandex_cloud_ml_sdk._types.operation import BaseOperationStatus
1617
from yandex_cloud_ml_sdk._types.result import BaseProtoResult, ProtoMessageTypeT_contra
18+
from yandex_cloud_ml_sdk._utils.doc import doc_from
1719

1820
from .status import BaseRunStatus, RunStatus, StreamEvent
1921

@@ -45,24 +47,18 @@ def _from_proto(cls, *, proto: ProtoMessageTypeT_contra, sdk: BaseSDK) -> BaseRu
4547
pass
4648

4749
@property
50+
@doc_from(BaseOperationStatus.is_running)
4851
def is_running(self) -> bool:
49-
"""
50-
Check if run is in progress.
51-
"""
5252
return self.status.is_running
5353

5454
@property
55+
@doc_from(BaseOperationStatus.is_succeeded)
5556
def is_succeeded(self) -> bool:
56-
"""
57-
Check if run completed successfully.
58-
"""
5957
return self.status.is_succeeded
6058

6159
@property
60+
@doc_from(BaseOperationStatus.is_failed)
6261
def is_failed(self) -> bool:
63-
"""
64-
Check if run failed.
65-
"""
6662
return self.status.is_failed
6763

6864
@property

src/yandex_cloud_ml_sdk/_runs/status.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
from yandex.cloud.ai.assistants.v1.runs.run_service_pb2 import StreamEvent as ProtoStreamEvent
88

99
from yandex_cloud_ml_sdk._types.operation import BaseOperationStatus
10+
from yandex_cloud_ml_sdk._utils.doc import doc_from
1011
from yandex_cloud_ml_sdk._utils.proto import ProtoEnumBase
1112

1213

1314
# pylint: disable=abstract-method
1415
class BaseRunStatus(BaseOperationStatus):
1516
pass
1617
"""
17-
Base class for run status enumerations.
18+
Class for run status enumerations.
1819
"""
1920

2021

@@ -38,24 +39,18 @@ class RunStatus(BaseRunStatus, ProtoEnumBase, IntEnum):
3839
TOOL_CALLS = ProtoRunState.TOOL_CALLS
3940

4041
@property
42+
@doc_from(BaseOperationStatus.is_running)
4143
def is_running(self) -> bool:
42-
"""
43-
Check if execution is still in progress.
44-
"""
4544
return self in (self.IN_PROGRESS, self.PENDING)
4645

4746
@property
47+
@doc_from(BaseOperationStatus.is_succeeded)
4848
def is_succeeded(self) -> bool:
49-
"""
50-
Check if execution completed successfully.
51-
"""
5249
return self in (self.COMPLETED, self.TOOL_CALLS)
5350

5451
@property
52+
@doc_from(BaseOperationStatus.is_failed)
5553
def is_failed(self) -> bool:
56-
"""
57-
Check if execution failed.
58-
"""
5954
return self is self.FAILED
6055

6156

@@ -77,22 +72,16 @@ class StreamEvent(BaseRunStatus, ProtoEnumBase, IntEnum):
7772
TOOL_CALLS = ProtoStreamEvent.TOOL_CALLS
7873

7974
@property
75+
@doc_from(BaseOperationStatus.is_running)
8076
def is_running(self) -> bool:
81-
"""
82-
Check if execution is still in progress.
83-
"""
8477
return self is self.PARTIAL_MESSAGE
8578

8679
@property
80+
@doc_from(BaseOperationStatus.is_succeeded)
8781
def is_succeeded(self) -> bool:
88-
"""
89-
Check if execution completed successfully.
90-
"""
9182
return self in (self.DONE, self.TOOL_CALLS)
9283

9384
@property
85+
@doc_from(BaseOperationStatus.is_failed)
9486
def is_failed(self) -> bool:
95-
"""
96-
Check if execution failed.
97-
"""
9887
return self is self.ERROR

src/yandex_cloud_ml_sdk/_types/operation.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,37 @@
3333
class BaseOperationStatus:
3434
@property
3535
def is_running(self) -> bool:
36+
"""
37+
Check if operation execution is still in progress.
38+
"""
3639
raise NotImplementedError()
3740

3841
@property
3942
def is_succeeded(self) -> bool:
43+
"""
44+
Check if operation execution completed successfully.
45+
"""
4046
raise NotImplementedError()
4147

4248
@property
4349
def is_failed(self) -> bool:
50+
"""
51+
Check if operation execution failed.
52+
"""
4453
raise NotImplementedError()
4554

4655
@property
4756
def is_finished(self) -> bool:
57+
"""
58+
Check if operation execution finished.
59+
"""
4860
return self.is_succeeded or self.is_failed
4961

5062
@property
5163
def status_name(self) -> str:
64+
"""
65+
Get operation execution status name.
66+
"""
5267
if self.is_succeeded:
5368
return 'success'
5469
if self.is_failed:

0 commit comments

Comments
 (0)