Skip to content

Commit

Permalink
docs(datasets): blacken code in rst literal blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>
  • Loading branch information
deepyaman committed Oct 2, 2023
1 parent 7b3ac6c commit 2cee92e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ repos:
- "--ignore=E203,E266,E501,W503"
exclude: "^kedro_airflow/dag_template.py|^template.py"

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
args:
- "--rst-literal-blocks"
additional_dependencies:
- black==22.12.0

- repo: local
hooks:
# pylint quick checks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,13 @@ class ManagedTableDataset(AbstractVersionedDataset):
.. code-block:: python
from pyspark.sql import SparkSession
from pyspark.sql.types import (StructField, StringType,
IntegerType, StructType)
from pyspark.sql.types import StructField, StringType, IntegerType, StructType
from kedro_datasets.databricks import ManagedTableDataset
schema = StructType([StructField("name", StringType(), True),
StructField("age", IntegerType(), True)])
data = [('Alex', 31), ('Bob', 12), ('Clarke', 65), ('Dave', 29)]
schema = StructType(
[StructField("name", StringType(), True), StructField("age", IntegerType(), True)]
)
data = [("Alex", 31), ("Bob", 12), ("Clarke", 65), ("Dave", 29)]
spark_df = SparkSession.builder.getOrCreate().createDataFrame(data, schema)
dataset = ManagedTableDataset(table="names_and_ages")
dataset.save(spark_df)
Expand Down
8 changes: 4 additions & 4 deletions kedro-datasets/kedro_datasets/pandas/hdf_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ class HDFDataset(AbstractVersionedDataset[pd.DataFrame, pd.DataFrame]):
Example usage for the
`Python API <https://kedro.readthedocs.io/en/stable/data/\
advanced_data_catalog_usage.html>`_:
::
.. code-block:: pycon
>>> from kedro_datasets.pandas import HDFDataset
>>> import pandas as pd
>>>
>>> data = pd.DataFrame({'col1': [1, 2], 'col2': [4, 5],
... 'col3': [5, 6]})
>>> data = pd.DataFrame({"col1": [1, 2], "col2": [4, 5], "col3": [5, 6]})
>>>
>>> dataset = HDFDataset(filepath="test.h5", key='data')
>>> dataset = HDFDataset(filepath="test.h5", key="data")
>>> dataset.save(data)
>>> reloaded = dataset.load()
>>> assert data.equals(reloaded)
Expand Down
1 change: 1 addition & 0 deletions kedro-datasets/kedro_datasets/spark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Supported file formats are:
from kedro.framework.hooks import hook_impl
from pyspark.sql import SparkSession


class SparkStreamsHook:
@hook_impl
def after_pipeline_run(self) -> None:
Expand Down

0 comments on commit 2cee92e

Please sign in to comment.