Add docstrings for _models/image_generation#115
Add docstrings for _models/image_generation#115vhaldemar merged 19 commits intoyandex-cloud:masterfrom
Conversation
vhaldemar
left a comment
There was a problem hiding this comment.
Я правильно понял, что ты в этом ПР со всеми файлами директории придешь?
И пока он не финальный?
|
|
||
| class BaseImageGeneration(BaseModelFunction[ModelTypeT]): | ||
| """ | ||
| Base class for image generation models. |
There was a problem hiding this comment.
Это не бейз класс.
Точнее это бейз класс, но ты-то копируешь эту строчку через doc_from
|
|
||
| Returns a model's object through which requests to the backend are made. | ||
|
|
||
| >>> model = sdk.models.image_generation('yandex-art') #this is how the model is created |
There was a problem hiding this comment.
Кажется, оступ лишний в 4 пробела
#this is how the model is created -> # this is how the model is created
(два пробела перед # и один после, так принято)
| @dataclass(frozen=True) | ||
| class ImageMessage: | ||
| """ | ||
| This class represents an image message with optional weight. |
There was a problem hiding this comment.
optional weight field, мне кажется
|
|
||
|
|
||
| def messages_to_proto(messages: ImageMessageInputType) -> list[ProtoMessage]: | ||
| """ |
There was a problem hiding this comment.
Это не надо, это внутреннее.
:meta private:
| """ | ||
| text: str | ||
|
|
||
|
|
There was a problem hiding this comment.
зато надо ImageMessageType и ImageMessageInputType
… _models/image_generation/model.py - v2
| @dataclass(frozen=True) | ||
| class ImageMessage: | ||
| """ | ||
| This class represents an image message with optional weight field. |
There was a problem hiding this comment.
Что такое image message?)
На самом деле, это просто структура сообщения, которую модель ожидает от пользователя.
То есть "message for using in image generation models", ниже тоже самое
|
|
||
|
|
||
| ImageMessageType = Union[ImageMessage, ImageMessageDict, AnyMessage, str] | ||
| """Type alias for different types of image messages that can be processed.""" |
There was a problem hiding this comment.
Вообще, так, наверное, сработает, но я ожидал #: над переменной
| class BaseImageGenerationModel( | ||
| ModelAsyncMixin[ImageGenerationModelConfig, ImageGenerationModelResult, OperationTypeT], | ||
| ): | ||
| """A class for image generation models.""" |
There was a problem hiding this comment.
Нет, это уже класс одной, конкретной модели.
Можно дописать, что она в себе инкапсулирует УРИ модели и конфигурацию
| :param seed: a random seed for generation. | ||
| :param width_ratio: the width ratio for the generated image. | ||
| :param height_ratio: the height ratio for the generated image. | ||
| :param mime_type: the MIME type of the generated image. |
There was a problem hiding this comment.
Здесь бы не помешала бы ссылка на доку про то, а какие MIME-типы мы умеем принимать
| and returns an operation representing the ongoing image generation process. | ||
|
|
||
| :param messages: the input messages for image generation. | ||
| :param timeout: the timeout for the operation in seconds. |
There was a problem hiding this comment.
Вот только тут слово "операция" конфликтует со словом "операция" выше.
Это разные операции))
В таймауте имеется ввиду - операция http-запрос по созданию объекта Операции.
|
|
||
| @dataclass(frozen=True, repr=False) | ||
| class ImageGenerationModelResult(BaseResult): | ||
| """This class represents the result of an image generation model.""" |
There was a problem hiding this comment.
This class represents the result of an image generation model inference
Как мне кажется
|
|
||
| @classmethod | ||
| def _from_proto(cls, *, proto: ProtoMessage, sdk: BaseSDK) -> Self: # pylint: disable=unused-argument | ||
| """:meta private:""" |
There was a problem hiding this comment.
Вот такие методы, начинающиеся с _, их не надо помечать
| ) | ||
|
|
||
| def _repr_jpeg_(self) -> bytes | None: | ||
| """:meta private:""" |
There was a problem hiding this comment.
А вот это, как ни странно, наоборот, именно _repr_smth_ - это как бы публичные методы.
Напиши им пока meta public, я не уверен, скушает ли это сфинкс.
А связанная ссылка про эти методы - https://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display
There was a problem hiding this comment.
Сделай :meta public:, пожалуйста
| return None | ||
|
|
||
| def __repr__(self) -> str: | ||
| """:meta private:""" |
There was a problem hiding this comment.
__repr__ просто не трогай)
| text: str | ||
|
|
||
|
|
||
| #: type alias for different types of image messages that can be processed |
There was a problem hiding this comment.
of messages that can be processed by image generation models
| ) | ||
|
|
||
| def _repr_jpeg_(self) -> bytes | None: | ||
| """:meta private:""" |
There was a problem hiding this comment.
Сделай :meta public:, пожалуйста
First version is ready for review