GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: Dask zero division error if parquet dataset has only one partition by mzwiessele · Pull Request #3236 · feast-dev/feast

fix: Dask zero division error if parquet dataset has only one partition #3236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
feast-ci-bot merged 3 commits into feast-dev:master from mzwiessele:zero_division_dask_drop_duplicates
Oct 12, 2022

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix: Dask zero division error if parquet dataset has only one partition #3236

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3 commits
Select commit Hold shift + click to select a range
91835d1
fix: dask zero division error if parquet dataset has only one partition
mzwiessele Sep 23, 2022
69b3fae
Update file.py
mzwiessele Oct 6, 2022
f60862b
Update file.py
mzwiessele Oct 6, 2022
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

31 changes: 25 additions & 6 deletions 31 sdk/python/feast/infra/offline_stores/file.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -662,14 +662,33 @@ def _drop_duplicates(
created_timestamp_column: str,
entity_df_event_timestamp_col: str,
) -> dd.DataFrame:
if created_timestamp_column:
df_to_join = df_to_join.sort_values(
by=created_timestamp_column, na_position="first"
)
column_order = df_to_join.columns
Comment thread
felixwang9817 marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.


# try-catch block is added to deal with this issue https://github.com/dask/dask/issues/8939.
# TODO(kevjumba): remove try catch when fix is merged upstream in Dask.
try:
if created_timestamp_column:
df_to_join = df_to_join.sort_values(
by=created_timestamp_column, na_position="first"
)
df_to_join = df_to_join.persist()

df_to_join = df_to_join.sort_values(by=timestamp_field, na_position="first")
df_to_join = df_to_join.persist()

df_to_join = df_to_join.sort_values(by=timestamp_field, na_position="first")
df_to_join = df_to_join.persist()
except ZeroDivisionError:
# Use 1 partition to get around case where everything in timestamp column is the same so the partition algorithm doesn't
# try to divide by zero.
if created_timestamp_column:
df_to_join = df_to_join[column_order].sort_values(
by=created_timestamp_column, na_position="first", npartitions=1
)
df_to_join = df_to_join.persist()

df_to_join = df_to_join[column_order].sort_values(
by=timestamp_field, na_position="first", npartitions=1
)
df_to_join = df_to_join.persist()

df_to_join = df_to_join.drop_duplicates(
all_join_keys + [entity_df_event_timestamp_col],
Expand Down
35 changes: 35 additions & 0 deletions 35 sdk/python/tests/integration/feature_repos/universal/data_sources/file.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import Any, Dict, List, Optional

import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq
from minio import Minio
from testcontainers.core.generic import DockerContainer
from testcontainers.core.waiting_utils import wait_for_logs
Expand Down Expand Up @@ -87,6 +89,39 @@ def teardown(self):
shutil.rmtree(d)


class FileParquetDatasetSourceCreator(FileDataSourceCreator):
def create_data_source(
self,
df: pd.DataFrame,
destination_name: str,
timestamp_field="ts",
created_timestamp_column="created_ts",
field_mapping: Dict[str, str] = None,
) -> DataSource:

destination_name = self.get_prefixed_table_name(destination_name)

dataset_path = tempfile.TemporaryDirectory(
prefix=f"{self.project_name}_{destination_name}"
)
table = pa.Table.from_pandas(df)
pq.write_to_dataset(
table,
base_dir=dataset_path.name,
compression="snappy",
format="parquet",
existing_data_behavior="overwrite_or_ignore",
)
self.files.append(dataset_path.name)
return FileSource(
file_format=ParquetFormat(),
path=dataset_path.name,
timestamp_field=timestamp_field,
created_timestamp_column=created_timestamp_column,
field_mapping=field_mapping or {"ts_1": "ts"},
)


class S3FileDataSourceCreator(DataSourceCreator):
f: Any
minio: DockerContainer
Expand Down
6 changes: 6 additions & 0 deletions 6 sdk/python/tests/utils/e2e_test_validation.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
)
from tests.integration.feature_repos.universal.data_sources.file import (
FileDataSourceCreator,
FileParquetDatasetSourceCreator,
)
from tests.integration.feature_repos.universal.data_sources.redshift import (
RedshiftDataSourceCreator,
Expand Down Expand Up @@ -211,6 +212,11 @@ def make_feature_store_yaml(
offline_store_creator=FileDataSourceCreator,
online_store=None,
),
IntegrationTestRepoConfig(
provider="local",
offline_store_creator=FileParquetDatasetSourceCreator,
online_store=None,
),
]

# Only test if this is NOT a local test
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.