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

[Train] Replace lambda default arguments #46576

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: 4 additions & 1 deletion python/ray/train/_internal/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,15 @@ def _upload_to_uri_with_exclude_fsspec(
def _list_at_fs_path(
fs: pyarrow.fs.FileSystem,
fs_path: str,
file_filter: Callable[[pyarrow.fs.FileInfo], bool] = lambda x: True,
file_filter: Optional[Callable[[pyarrow.fs.FileInfo], bool]] = None,
) -> List[str]:
"""Returns the list of filenames at (fs, fs_path), similar to os.listdir.

If the path doesn't exist, returns an empty list.
"""
if file_filter is None:
file_filter = lambda x: True # noqa: E731

selector = pyarrow.fs.FileSelector(fs_path, allow_not_found=True, recursive=False)
return [
os.path.relpath(file_info.path.lstrip("/"), start=fs_path.lstrip("/"))
Expand Down
8 changes: 6 additions & 2 deletions python/ray/train/tests/dummy_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
class DummyPreprocessor(Preprocessor):
_is_fittable = False

def __init__(self, transform=lambda b: b):
def __init__(self, transform=None):
self.id = uuid.uuid4()
self.transform = transform

if transform is None:
self.transform = lambda b: b
else:
self.transform = transform

def transform_batch(self, batch):
self._batch_transformed = True
Expand Down
Loading