Skip to content

Commit

Permalink
build(datasets): add type targets for return types (#797)
Browse files Browse the repository at this point in the history
* build(datasets): circumvent Requests ref not found

See also: sphinx-doc/sphinx#9653

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): circumvent dask_expr ref not found

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add VersionNotFoundError exc type

Signed-off-by: Deepyaman Datta <[email protected]>

* docs(datasets): update malformed dataset docstring

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add missing DataFrame type target

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add missing DataFrame type target

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add missing DataFrame type target

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add missing transformers.Pipeline

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): create new `ir.Table` type target

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add a `numpy.ndarray` type target

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add type target for `plt.Figure`s

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): create NetworkX Graph type target

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add missing DataFrame type target

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add `PIL.Image.Image` type target

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add type target for Plotly Figure

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add type target for Figure Widget

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add missing DataFrame type target

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add missing LazyFrame type target

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add missing DataFrame type target

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add missing target for DeltaTable

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add missing DataFrame type target

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): create type target for csr_matrix

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add type target for Keras `Model`

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add missing type target for video

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): make `type_targets` for Anthropic

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add type target for Cohere models

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add xarray dataset `type_targets`

Signed-off-by: Deepyaman Datta <[email protected]>

* build(datasets): add target for xarray `DataArray`

Signed-off-by: Deepyaman Datta <[email protected]>

* feat(datasets)!: expose `load` and `save` publicly

Signed-off-by: Deepyaman Datta <[email protected]>

* fix(datasets): replace calls to _meth with wrapped

Signed-off-by: Deepyaman Datta <[email protected]>

* fix(datasets): pass `self` for `__wrapped__` calls

Signed-off-by: Deepyaman Datta <[email protected]>

* revert(datasets): restore to `_load`s and `_save`s

Refs: 3204803, 42201cf, b40597c

Signed-off-by: Deepyaman Datta <[email protected]>

---------

Signed-off-by: Deepyaman Datta <[email protected]>
  • Loading branch information
deepyaman authored Aug 2, 2024
1 parent 0c35e78 commit 95219ad
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
31 changes: 30 additions & 1 deletion kedro-datasets/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,49 @@
"AbstractDataset",
"kedro.io.core.Version",
"requests.auth.AuthBase",
"requests.models.Response",
"google.oauth2.credentials.Credentials",
"deltalake.table.Metadata",
"DataCatalog",
"ibis.backends.BaseBackend",
"langchain_openai.chat_models.base.ChatOpenAI",
"langchain_openai.embeddings.base.OpenAIEmbeddings",
"dask_expr._collection.DataFrame",
"DataFrame",
"pd.DataFrame",
"geopandas.geodataframe.GeoDataFrame",
"transformers.pipelines.base.Pipeline",
"ibis.expr.types.relations.Table",
"numpy.ndarray",
"matplotlib.figure.Figure",
"networkx.classes.graph.Graph",
"pandas.core.frame.DataFrame",
"PIL.Image.Image",
"plotly.graph_objs._figure.Figure",
"plotly.graph_objs._figurewidget.FigureWidget",
"polars.dataframe.frame.DataFrame",
"polars.lazyframe.frame.LazyFrame",
"snowflake.snowpark.dataframe.DataFrame",
"delta.tables.DeltaTable",
"pyspark.sql.dataframe.DataFrame",
"scipy.sparse._csr.csr_matrix",
"keras.src.models.model.Model",
"kedro_datasets.video.video_dataset.AbstractVideo",
"langchain_anthropic.chat_models.ChatAnthropic",
"langchain_cohere.chat_models.ChatCohere",
"xarray.core.dataset.Dataset",
"xarray.core.dataarray.DataArray",
),
"py:data": (
"typing.Any",
"typing.Union",
"typing.Optional",
"typing.Tuple",
),
"py:exc": ("DatasetError",),
"py:exc": (
"DatasetError",
"VersionNotFoundError",
),
}
# https://stackoverflow.com/questions/61770698/sphinx-nit-picky-mode-but-only-for-links-i-explicitly-wrote
nitpick_ignore = [(key, value) for key in type_targets for value in type_targets[key]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ class ManagedTable:

def __post_init__(self):
"""Run validation methods if declared.
The validation method can be a simple check
that raises DatasetError.
The validation is performed by calling a function named:
`validate_<field_name>(self, value) -> raises DatasetError`
The validation is performed by calling a function with the signature
`validate_<field_name>(self, value) -> raises DatasetError`.
"""
for name in self.__dataclass_fields__.keys():
method = getattr(self, f"_validate_{name}", None)
Expand Down Expand Up @@ -293,11 +295,11 @@ def _load(self) -> DataFrame | pd.DataFrame:
Raises:
VersionNotFoundError: if the version defined in
the init doesn't exist
the init doesn't exist
Returns:
Union[DataFrame, pd.DataFrame]: Returns a dataframe
in the format defined in the init
in the format defined in the init
"""
if self._version and self._version.load >= 0:
try:
Expand Down

0 comments on commit 95219ad

Please sign in to comment.