From 4f8b5c850b80fa2cb948795a1c7581ee5e4018b3 Mon Sep 17 00:00:00 2001 From: darkdi Date: Thu, 6 Aug 2026 12:31:10 +0300 Subject: [PATCH] docs: fix docstring Args entries that name a parameter the function does not take --- src/bentoml/_internal/cloud/model.py | 2 +- src/bentoml/_internal/container/base.py | 1 - src/bentoml/_internal/frameworks/fastai.py | 2 +- .../_internal/frameworks/pytorch_lightning.py | 6 +-- .../_internal/frameworks/torchscript.py | 2 +- src/bentoml/_internal/io_descriptors/base.py | 1 - src/bentoml/_internal/io_descriptors/file.py | 3 -- src/bentoml/_internal/io_descriptors/image.py | 5 -- src/bentoml/_internal/io_descriptors/json.py | 1 - src/bentoml/_internal/io_descriptors/numpy.py | 9 +--- .../_internal/io_descriptors/pandas.py | 52 ++----------------- src/bentoml/_internal/models/model.py | 2 +- .../_internal/utils/analytics/usage_stats.py | 1 - src/bentoml/bentos.py | 1 - src/bentoml/models.py | 1 - src/bentoml/testing/server.py | 2 +- 16 files changed, 10 insertions(+), 81 deletions(-) diff --git a/src/bentoml/_internal/cloud/model.py b/src/bentoml/_internal/cloud/model.py index 5d8d56a0a63..f9adc36dae6 100644 --- a/src/bentoml/_internal/cloud/model.py +++ b/src/bentoml/_internal/cloud/model.py @@ -526,7 +526,7 @@ def get(self, name: str, version: str | None = None) -> ModelSchema: """Get a model from the remote model store Args: - tag: The tag of the model to get + name: The tag of the model to get Returns: The model diff --git a/src/bentoml/_internal/container/base.py b/src/bentoml/_internal/container/base.py index 9ff8f150caa..335342374dd 100644 --- a/src/bentoml/_internal/container/base.py +++ b/src/bentoml/_internal/container/base.py @@ -100,7 +100,6 @@ def __init__( Initialize the OCI builder. Args: - backend: The name of the OCI builder. env: Environment variables to be passed to the OCI builder. enable_buildkit: Whether to enable BuildKit support for given OCI builder. build_cmd: The build command to be used by the OCI builder, minus the backend name. diff --git a/src/bentoml/_internal/frameworks/fastai.py b/src/bentoml/_internal/frameworks/fastai.py index a5cfc1ae5d1..800baf13312 100644 --- a/src/bentoml/_internal/frameworks/fastai.py +++ b/src/bentoml/_internal/frameworks/fastai.py @@ -137,7 +137,7 @@ def save_model( Args: name: The name to give to the model in the BentoML store. This must be a valid :obj:`~bentoml.Tag` name. - learner: :obj:`~fastai.learner.Learner` to be saved. + learner_: :obj:`~fastai.learner.Learner` to be saved. signatures: Signatures of predict methods to be used. If not provided, the signatures default to ``predict``. See :obj:`~bentoml.types.ModelSignature` for more details. labels: A default set of management labels to be associated with the model. An example is ``{"training-set": "data-1"}``. diff --git a/src/bentoml/_internal/frameworks/pytorch_lightning.py b/src/bentoml/_internal/frameworks/pytorch_lightning.py index fe1be6f6528..5a6fce9903c 100644 --- a/src/bentoml/_internal/frameworks/pytorch_lightning.py +++ b/src/bentoml/_internal/frameworks/pytorch_lightning.py @@ -47,12 +47,10 @@ def load_model( Load a model from BentoML local modelstore with given name. Args: - tag (:code:`Union[str, Tag]`): + bentoml_model (:code:`Union[str, Tag]`): Tag of a saved model in BentoML local modelstore. device_id (:code:`str`, `optional`): Optional devices to put the given model on. Refer to https://pytorch.org/docs/stable/tensor_attributes.html#torch.torch.device - model_store (:mod:`~bentoml._internal.models.store.ModelStore`, default to :mod:`BentoMLContainer.model_store`): - BentoML modelstore, provided by DI Container. Returns: :obj:`torch.ScriptModule`: an instance of :obj:`torch.ScriptModule` from BentoML modelstore. @@ -104,8 +102,6 @@ def save_model( e.g. a tokenizer module, preprocessor module, model configuration module metadata (:code:`Dict[str, Any]`, `optional`, default to :code:`None`): Custom metadata for given model. - model_store (:mod:`~bentoml._internal.models.store.ModelStore`, default to :mod:`BentoMLContainer.model_store`): - BentoML modelstore, provided by DI Container. Returns: :obj:`~bentoml.Tag`: A :obj:`tag` with a format `name:version` where `name` is the user-defined model's name, and a generated `version` by BentoML. diff --git a/src/bentoml/_internal/frameworks/torchscript.py b/src/bentoml/_internal/frameworks/torchscript.py index b60b1f13935..bdc3b60bcbd 100644 --- a/src/bentoml/_internal/frameworks/torchscript.py +++ b/src/bentoml/_internal/frameworks/torchscript.py @@ -44,7 +44,7 @@ def load_model( Load a model from BentoML local modelstore with given name. Args: - tag: + bentoml_model: Tag of a saved model in BentoML local modelstore. device_id: Optional devices to put the given model on. Refer to https://pytorch.org/docs/stable/tensor_attributes.html#torch.torch.device diff --git a/src/bentoml/_internal/io_descriptors/base.py b/src/bentoml/_internal/io_descriptors/base.py index 5754dddec01..57724f262ab 100644 --- a/src/bentoml/_internal/io_descriptors/base.py +++ b/src/bentoml/_internal/io_descriptors/base.py @@ -148,7 +148,6 @@ def _from_sample(self, sample: t.Any) -> IOType: Args: sample: The sample to create the instance from. - **kwargs: Additional keyword arguments to pass to the constructor. Returns: An instance of the IODescriptor. diff --git a/src/bentoml/_internal/io_descriptors/file.py b/src/bentoml/_internal/io_descriptors/file.py index d86dbec3d28..d605e8f26f2 100644 --- a/src/bentoml/_internal/io_descriptors/file.py +++ b/src/bentoml/_internal/io_descriptors/file.py @@ -129,9 +129,6 @@ def _from_sample(self, sample: FileType | str) -> FileType: Args: sample: Given File-like object, or a path to a file. - kind: The kind of file-like object to be used. Currently, the only accepted value is ``binaryio``. - mime_type: Optional MIME type for the descriptor. If not provided, ``from_sample`` - will try to infer the MIME type from the file extension. Returns: :class:`~bentoml._internal.io_descriptors.file.File`: IODescriptor from given users inputs. diff --git a/src/bentoml/_internal/io_descriptors/image.py b/src/bentoml/_internal/io_descriptors/image.py index f7c852239d6..655cc6e9ce1 100644 --- a/src/bentoml/_internal/io_descriptors/image.py +++ b/src/bentoml/_internal/io_descriptors/image.py @@ -205,11 +205,6 @@ def _from_sample(self, sample: ImageType | str) -> ImageType: Args: sample: Given File-like object, or a path to a file. - pilmode: Optional color mode for PIL. Default to ``RGB``. - mime_type: The MIME type of the file type that this descriptor should return. - If not specified, then ``from_sample`` will try to infer the MIME type - from file extension. - allowed_mime_types: An optional list of MIME types to restrict input to. Returns: :class:`~bentoml._internal.io_descriptors.image.Image`: IODescriptor from given users inputs. diff --git a/src/bentoml/_internal/io_descriptors/json.py b/src/bentoml/_internal/io_descriptors/json.py index 264be793577..c36ced5b931 100644 --- a/src/bentoml/_internal/io_descriptors/json.py +++ b/src/bentoml/_internal/io_descriptors/json.py @@ -229,7 +229,6 @@ class IrisFeatures(BaseModel): @svc.api(input=input_spec, output=NumpyNdarray()) async def predict(input: NDArray[np.int16]) -> NDArray[Any]: return await runner.async_run(input) - json_encoder: Optional JSON encoder. Returns: :class:`~bentoml._internal.io_descriptors.json.JSON`: IODescriptor from given users inputs. diff --git a/src/bentoml/_internal/io_descriptors/numpy.py b/src/bentoml/_internal/io_descriptors/numpy.py index 8d2e4c05538..21a6298fcf2 100644 --- a/src/bentoml/_internal/io_descriptors/numpy.py +++ b/src/bentoml/_internal/io_descriptors/numpy.py @@ -433,12 +433,6 @@ def _from_sample(self, sample: ext.NpNDArray | t.Sequence[t.Any]) -> ext.NpNDArr Args: sample: Given sample ``np.ndarray`` data. It also accepts a sequence-like data type that can be converted to ``np.ndarray``. - enforce_dtype: Enforce a certain data type. :code:`dtype` must be specified at function - signature. If you don't want to enforce a specific dtype then change - :code:`enforce_dtype=False`. - enforce_shape: Enforce a certain shape. :code:`shape` must be specified at function - signature. If you don't want to enforce a specific shape then change - :code:`enforce_shape=False`. Returns: :class:`~bentoml._internal.io_descriptors.numpy.NumpyNdarray`: IODescriptor from given users inputs. @@ -491,8 +485,7 @@ async def from_proto(self, field: pb.NDArray | bytes) -> ext.NpNDArray: Process incoming protobuf request and convert it to ``numpy.ndarray`` Args: - request: Incoming RPC request message. - context: grpc.ServicerContext + field: Incoming RPC request message. Returns: ``numpy.ndarray``: A ``np.array`` constructed from given protobuf message. diff --git a/src/bentoml/_internal/io_descriptors/pandas.py b/src/bentoml/_internal/io_descriptors/pandas.py index 7e6b899e45e..6fbff3aa586 100644 --- a/src/bentoml/_internal/io_descriptors/pandas.py +++ b/src/bentoml/_internal/io_descriptors/pandas.py @@ -347,31 +347,6 @@ def _from_sample(self, sample: ext.PdDataFrame) -> ext.PdDataFrame: Args: sample: Given sample ``pd.DataFrame`` data - orient: Indication of expected JSON string format. Compatible JSON strings can be - produced by :func:`pandas.io.json.to_json()` with a corresponding orient value. - Possible orients are: - - - :obj:`split` - :code:`dict[str, Any]` ↦ {``idx`` ↠ ``[idx]``, ``columns`` ↠ ``[columns]``, ``data`` ↠ ``[values]``} - - :obj:`records` - :code:`list[Any]` ↦ [{``column`` ↠ ``value``}, ..., {``column`` ↠ ``value``}] - - :obj:`index` - :code:`dict[str, Any]` ↦ {``idx`` ↠ {``column`` ↠ ``value``}} - - :obj:`columns` - :code:`dict[str, Any]` ↦ {``column`` ↠ {``index`` ↠ ``value``}} - - :obj:`values` - :code:`dict[str, Any]` ↦ Values arrays - - :obj:`table` - :code:`dict[str, Any]` ↦ {``schema``: { schema }, ``data``: { data }} - apply_column_names: Update incoming DataFrame columns. ``columns`` must be specified at - function signature. If you don't want to enforce a specific columns - name then change ``apply_column_names=False``. - enforce_dtype: Enforce a certain data type. `dtype` must be specified at function - signature. If you don't want to enforce a specific dtype then change - ``enforce_dtype=False``. - enforce_shape: Enforce a certain shape. ``shape`` must be specified at function - signature. If you don't want to enforce a specific shape then change - ``enforce_shape=False``. - default_format: The default serialization format to use if the request does not specify a ``Content-Type`` Headers. - It is also the serialization format used for the response. Possible values are: - - - :obj:`json` - JSON text format (inferred from content-type ``"application/json"``) - - :obj:`parquet` - Parquet binary format (inferred from content-type ``"application/vnd.apache.parquet"``) - - :obj:`csv` - CSV text format (inferred from content-type ``"text/csv"``) Returns: :class:`~bentoml._internal.io_descriptors.pandas.PandasDataFrame`: IODescriptor from given users inputs. @@ -640,8 +615,7 @@ async def from_proto(self, field: pb.DataFrame | bytes) -> ext.PdDataFrame: Process incoming protobuf request and convert it to ``pandas.DataFrame`` Args: - request: Incoming RPC request message. - context: grpc.ServicerContext + field: Incoming RPC request message. Returns: a ``pandas.DataFrame`` object. This can then be used @@ -698,7 +672,6 @@ async def _to_proto_impl( Args: obj: ``pandas.DataFrame`` that will be serialized to protobuf - context: grpc.aio.ServicerContext from grpc.aio.Server Returns: ``service_pb2.Response``: Protobuf representation of given ``pandas.DataFrame`` @@ -849,9 +822,6 @@ def predict(input_arr): - :obj:`index` - :code:`dict[str, Any]` ↦ {``idx`` ↠ {``column`` ↠ ``value``}} - :obj:`columns` - :code:`dict[str, Any]` ↦ {``column`` ↠ {``index`` ↠ ``value``}} - :obj:`values` - :code:`dict[str, Any]` ↦ Values arrays - columns: List of columns name that users wish to update. - apply_column_names: Whether to update incoming DataFrame columns. If :code:`apply_column_names=True`, - then ``columns`` must be specified. dtype: Data type users wish to convert their inputs/outputs to. If it is a boolean, then pandas will infer dtypes. Else if it is a dictionary of column to ``dtype``, then applies those to incoming dataframes. If ``False``, then don't @@ -898,21 +868,7 @@ def _from_sample(self, sample: ext.PdSeries | t.Sequence[t.Any]) -> ext.PdSeries Create a :class:`~bentoml._internal.io_descriptors.pandas.PandasSeries` IO Descriptor from given inputs. Args: - sample_input: Given sample ``pd.DataFrame`` data - orient: Indication of expected JSON string format. Compatible JSON strings can be - produced by :func:`pandas.io.json.to_json()` with a corresponding orient value. - Possible orients are: - - - :obj:`split` - :code:`dict[str, Any]` ↦ {``idx`` ↠ ``[idx]``, ``columns`` ↠ ``[columns]``, ``data`` ↠ ``[values]``} - - :obj:`records` - :code:`list[Any]` ↦ [{``column`` ↠ ``value``}, ..., {``column`` ↠ ``value``}] - - :obj:`index` - :code:`dict[str, Any]` ↦ {``idx`` ↠ {``column`` ↠ ``value``}} - - :obj:`table` - :code:`dict[str, Any]` ↦ {``schema``: { schema }, ``data``: { data }} - enforce_dtype: Enforce a certain data type. `dtype` must be specified at function - signature. If you don't want to enforce a specific dtype then change - ``enforce_dtype=False``. - enforce_shape: Enforce a certain shape. ``shape`` must be specified at function - signature. If you don't want to enforce a specific shape then change - ``enforce_shape=False``. + sample: Given sample ``pd.DataFrame`` data Returns: :class:`~bentoml._internal.io_descriptors.pandas.PandasSeries`: IODescriptor from given users inputs. @@ -1095,8 +1051,7 @@ async def from_proto(self, field: pb.Series | bytes) -> ext.PdSeries: Process incoming protobuf request and convert it to ``pandas.Series`` Args: - request: Incoming RPC request message. - context: grpc.ServicerContext + field: Incoming RPC request message. Returns: a ``pandas.Series`` object. This can then be used @@ -1157,7 +1112,6 @@ async def _to_proto_impl( Args: obj: ``pandas.Series`` that will be serialized to protobuf - context: grpc.aio.ServicerContext from grpc.aio.Server Returns: ``service_pb2.Response``: Protobuf representation of given ``pandas.Series`` diff --git a/src/bentoml/_internal/models/model.py b/src/bentoml/_internal/models/model.py index 184d5222441..6f3eb06e5c6 100644 --- a/src/bentoml/_internal/models/model.py +++ b/src/bentoml/_internal/models/model.py @@ -318,7 +318,7 @@ def to_runner( name: max_batch_size: max_latency_ms: - runnable_method_configs: + method_configs: Returns: diff --git a/src/bentoml/_internal/utils/analytics/usage_stats.py b/src/bentoml/_internal/utils/analytics/usage_stats.py index 5c249605540..1a091b8f40d 100644 --- a/src/bentoml/_internal/utils/analytics/usage_stats.py +++ b/src/bentoml/_internal/utils/analytics/usage_stats.py @@ -292,7 +292,6 @@ def get_metrics_report( Args: metrics_client: Instance of bentoml._internal.server.metrics.prometheus.PrometheusClient - grpc: Whether the metrics are for gRPC server. Returns: A tuple of a list of metrics and an optional boolean to determine whether the return metrics are legacy metrics. diff --git a/src/bentoml/bentos.py b/src/bentoml/bentos.py index fa46a72d9ab..7c0fd35a461 100644 --- a/src/bentoml/bentos.py +++ b/src/bentoml/bentos.py @@ -133,7 +133,6 @@ def import_bento( `FS URL documentation `_. Args: - tag: the tag of the bento to export path: can be one of two things: * a folder on the local filesystem * an `FS URL `_, diff --git a/src/bentoml/models.py b/src/bentoml/models.py index 64015b10055..ebf7d372cf7 100644 --- a/src/bentoml/models.py +++ b/src/bentoml/models.py @@ -105,7 +105,6 @@ def import_model( `FS URL documentation `_. Args: - tag: the tag of the model to export path: can be one of two things: * a folder on the local filesystem * an `FS URL `_, for example :code:`'s3://my_bucket/folder/my_model.bentomodel'` diff --git a/src/bentoml/testing/server.py b/src/bentoml/testing/server.py index 6deb599eb44..a03ed4aedee 100644 --- a/src/bentoml/testing/server.py +++ b/src/bentoml/testing/server.py @@ -427,7 +427,7 @@ def host_bento( Host a bentoml service, yields the host URL. Args: - bento: a bento tag or :code:`module_path:service` + bento_name: a bento tag or :code:`module_path:service` project_path: the path to the project directory config_file: the path to the config file deployment_mode: the deployment mode, one of :code:`standalone`, :code:`docker` or :code:`distributed`