Skip to content
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.

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

Update __init__.py #484

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions streaming/base/converters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"""Utility function for converting spark dataframe to MDS dataset."""

from streaming.base.converters.dataframe_to_mds import MAPPING_SPARK_TO_MDS, dataframeToMDS
from streaming.base.converters.dataframe_to_mds import (MAPPING_SPARK_TO_MDS, dataframe_to_mds,
dataframeToMDS)

__all__ = ['dataframeToMDS', 'MAPPING_SPARK_TO_MDS']
__all__ = ['dataframeToMDS', 'dataframe_to_mds', 'MAPPING_SPARK_TO_MDS']
XiaohanZhangCMU marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion streaming/base/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def _merge_index_from_list(index_file_urls: List[Union[str, Tuple[str, str]]],

# Prepare a temp folder to download index.json from remote if necessary. Removed in the end.
with tempfile.TemporaryDirectory() as temp_root:
logging.warning(f'Create a temporary folder {temp_root} to store index files')
logging.warning(f'A temporary folder {temp_root} is created to store index files')

# Copy files to a temporary directory. Download if necessary
partitions = []
Expand Down
22 changes: 11 additions & 11 deletions tests/base/converters/test_dataframe_to_mds.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pyspark.sql.functions import col
from pyspark.sql.types import DecimalType, IntegerType, StringType, StructField, StructType

from streaming.base.converters import dataframeToMDS
from streaming.base.converters import dataframe_to_mds

os.environ[
'OBJC_DISABLE_INITIALIZE_FORK_SAFETY'] = 'YES' # set to yes to all fork process in spark calls
Expand Down Expand Up @@ -68,13 +68,13 @@ def test_end_to_end_conversion_local_nocolumns(self, dataframe: Any, keep_local:
}

with pytest.raises(ValueError, match=f'.*is not supported by MDSWriter.*'):
_, _ = dataframeToMDS(dataframe.select(col('id'), col('dept'), col('properties')),
merge_index=merge_index,
mds_kwargs=mds_kwargs)
_, _ = dataframe_to_mds(dataframe.select(col('id'), col('dept'), col('properties')),
merge_index=merge_index,
mds_kwargs=mds_kwargs)

_, _ = dataframeToMDS(dataframe.select(col('id'), col('dept')),
merge_index=merge_index,
mds_kwargs=mds_kwargs)
_, _ = dataframe_to_mds(dataframe.select(col('id'), col('dept')),
merge_index=merge_index,
mds_kwargs=mds_kwargs)

if keep_local:
assert len(os.listdir(out)) > 0, f'{out} is empty'
Expand Down Expand Up @@ -115,7 +115,7 @@ def test_end_to_end_conversion_local_decimal(self, decimal_dataframe: Any, use_c
if use_columns:
mds_kwargs['columns'] = user_defined_columns

_, _ = dataframeToMDS(decimal_dataframe, merge_index=True, mds_kwargs=mds_kwargs)
_, _ = dataframe_to_mds(decimal_dataframe, merge_index=True, mds_kwargs=mds_kwargs)
assert len(os.listdir(out)) > 0, f'{out} is empty'

def test_user_defined_columns(self, dataframe: Any, local_remote_dir: Tuple[str, str]):
Expand All @@ -126,7 +126,7 @@ def test_user_defined_columns(self, dataframe: Any, local_remote_dir: Tuple[str,
'columns': user_defined_columns,
}
with pytest.raises(ValueError, match=f'.*is not a column of input dataframe.*'):
_, _ = dataframeToMDS(dataframe, merge_index=False, mds_kwargs=mds_kwargs)
_, _ = dataframe_to_mds(dataframe, merge_index=False, mds_kwargs=mds_kwargs)

user_defined_columns = {'id': 'strr', 'dept': 'str'}

Expand All @@ -135,7 +135,7 @@ def test_user_defined_columns(self, dataframe: Any, local_remote_dir: Tuple[str,
'columns': user_defined_columns,
}
with pytest.raises(ValueError, match=f'.* is not supported by MDSWriter.*'):
_, _ = dataframeToMDS(dataframe, merge_index=False, mds_kwargs=mds_kwargs)
_, _ = dataframe_to_mds(dataframe, merge_index=False, mds_kwargs=mds_kwargs)

@pytest.mark.parametrize('keep_local', [True, False])
@pytest.mark.parametrize('merge_index', [True, False])
Expand All @@ -154,7 +154,7 @@ def test_end_to_end_conversion_local(self, dataframe: Any, keep_local: bool, mer
'size_limit': 1 << 26
}

_, _ = dataframeToMDS(dataframe, merge_index=merge_index, mds_kwargs=mds_kwargs)
_, _ = dataframe_to_mds(dataframe, merge_index=merge_index, mds_kwargs=mds_kwargs)

if keep_local:
assert len(os.listdir(out)) > 0, f'{out} is empty'
Expand Down