Skip to content

feat: Add support for path in map fn #582

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

Merged
merged 10 commits into from
May 7, 2025

Conversation

deependujha
Copy link
Collaborator

Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

What does this PR do?

Fixes #581

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in GitHub issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@deependujha deependujha requested a review from Copilot May 6, 2025 07:38
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for using Path objects in the map function, along with a new test for resolving time templates. The key changes include:

  • Updating _resolve_dir and map function signatures to accept Path types.
  • Adding tests to verify the time template resolution and map functionality.
  • Enhancing error messages and type checks for directory inputs.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/streaming/test_resolver.py Added _resolve_time_template tests
tests/processing/test_functions.py Added new test for map function using Path as output_dir
src/litdata/streaming/resolver.py Updated _resolve_dir and _resolve_time_template signatures
src/litdata/processing/functions.py Updated map function parameter types to support Path
Comments suppressed due to low confidence (1)

tests/streaming/test_resolver.py:402

  • Ensure that the 'resolver' variable is properly defined or imported in the test; otherwise, this line may lead to a NameError at runtime.
assert resolver._resolve_time_template(path_1) == f"/logs/log_{curr_year}-{curr_month:02d}"

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@deependujha deependujha requested a review from Copilot May 6, 2025 07:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for resolving a datetime template in directory paths and extends the map function to handle Path objects.

  • Added tests for time-based template resolution in file paths.
  • Updated type hints and error messages across resolver and processing functions to support Path objects.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/streaming/test_resolver.py Added new test (test_resolve_time_template) for datetime resolution.
tests/processing/test_functions.py Introduced tests for the map function with file path updates.
src/litdata/streaming/resolver.py Updated _resolve_dir to accept Path objects and improved error messaging.
src/litdata/processing/functions.py Updated map function signature to support Path types in parameters.

deependujha and others added 2 commits May 6, 2025 13:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@deependujha
Copy link
Collaborator Author

Hi @SkafteNicki feel free to review the PR.

Copy link

codecov bot commented May 6, 2025

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 79%. Comparing base (96238b6) to head (bff8a9e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@         Coverage Diff         @@
##           main   #582   +/-   ##
===================================
  Coverage    79%    79%           
===================================
  Files        40     40           
  Lines      6111   6112    +1     
===================================
+ Hits       4809   4815    +6     
+ Misses     1302   1297    -5     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bhimrazy bhimrazy requested a review from Borda May 7, 2025 08:24
Copy link
Collaborator

@bhimrazy bhimrazy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Let's get one more approval before merging.

@deependujha deependujha merged commit 71ef218 into Lightning-AI:main May 7, 2025
29 checks passed
@deependujha deependujha deleted the feat/add-pathlib-support branch May 7, 2025 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Pathlib in litdata.map
3 participants