Skip to content

Commit

Permalink
Import tabulate in each task (#1679)
Browse files Browse the repository at this point in the history
* Import tabulate in each task

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

* Fix lint errors

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>

---------

Signed-off-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
Co-authored-by: Eduardo Apolinario <eapolinario@users.noreply.github.com>
  • Loading branch information
eapolinario and eapolinario committed May 13, 2024
1 parent a4cd567 commit 374093a
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
StructuredDatasetEncoder,
StructuredDatasetTransformerEngine,
)
from tabulate import tabulate
from typing_extensions import Annotated


Expand Down Expand Up @@ -203,6 +202,8 @@ class CompanyField:

@task(container_image=image)
def create_parquet_file() -> StructuredDataset:
from tabulate import tabulate

df = pd.json_normalize(data, max_level=0)
print("original dataframe: \n", tabulate(df, headers="keys", tablefmt="psql"))

Expand All @@ -211,48 +212,62 @@ def create_parquet_file() -> StructuredDataset:

@task(container_image=image)
def print_table_by_arg(sd: MyArgDataset) -> pd.DataFrame:
from tabulate import tabulate

t = sd.open(pd.DataFrame).all()
print("MyArgDataset dataframe: \n", tabulate(t, headers="keys", tablefmt="psql"))
return t


@task(container_image=image)
def print_table_by_dict(sd: MyDictDataset) -> pd.DataFrame:
from tabulate import tabulate

t = sd.open(pd.DataFrame).all()
print("MyDictDataset dataframe: \n", tabulate(t, headers="keys", tablefmt="psql"))
return t


@task(container_image=image)
def print_table_by_list_dict(sd: MyDictListDataset) -> pd.DataFrame:
from tabulate import tabulate

t = sd.open(pd.DataFrame).all()
print("MyDictListDataset dataframe: \n", tabulate(t, headers="keys", tablefmt="psql"))
return t


@task(container_image=image)
def print_table_by_top_dataclass(sd: MyTopDataClassDataset) -> pd.DataFrame:
from tabulate import tabulate

t = sd.open(pd.DataFrame).all()
print("MyTopDataClassDataset dataframe: \n", tabulate(t, headers="keys", tablefmt="psql"))
return t


@task(container_image=image)
def print_table_by_top_dict(sd: MyTopDictDataset) -> pd.DataFrame:
from tabulate import tabulate

t = sd.open(pd.DataFrame).all()
print("MyTopDictDataset dataframe: \n", tabulate(t, headers="keys", tablefmt="psql"))
return t


@task(container_image=image)
def print_table_by_second_dataclass(sd: MySecondDataClassDataset) -> pd.DataFrame:
from tabulate import tabulate

t = sd.open(pd.DataFrame).all()
print("MySecondDataClassDataset dataframe: \n", tabulate(t, headers="keys", tablefmt="psql"))
return t


@task(container_image=image)
def print_table_by_nested_dataclass(sd: MyNestedDataClassDataset) -> pd.DataFrame:
from tabulate import tabulate

t = sd.open(pd.DataFrame).all()
print("MyNestedDataClassDataset dataframe: \n", tabulate(t, headers="keys", tablefmt="psql"))
return t
Expand Down

0 comments on commit 374093a

Please sign in to comment.