-
Notifications
You must be signed in to change notification settings - Fork 590
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
Revert 5407 #5429
Revert 5407 #5429
Conversation
This reverts commit d306a36.
WalkthroughThis pull request introduces significant changes to the FiftyOne library's core functionality, focusing on sample retrieval methods across multiple files. The modifications involve removing Changes
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
fiftyone/core/dataset.py (1)
1237-1241
: Raise exceptions withraise ... from err
to preserve the original traceback.A static analysis hint suggests re-raising from the original exception for better debugging clarity:
- except ValueError: - raise ValueError("%s is empty" % self.__class__.__name__) + except ValueError as e: + raise ValueError("%s is empty" % self.__class__.__name__) from e🧰 Tools
🪛 Ruff (0.8.2)
1239-1239: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling(B904)
fiftyone/__public__.py (1)
166-166
: Remove unused importStatic analysis tools indicate that the
Sample
import is not used. Removing it will clean up the code and can help avoid confusion.- from .core.sample import Sample
🧰 Tools
🪛 Ruff (0.8.2)
166-166:
.core.sample.Sample
imported but unusedRemove unused import:
.core.sample.Sample
(F401)
fiftyone/core/collections.py (2)
926-929
: Add error context when raising ValueErrorThe error handling should preserve the context of the original error by using
raise ... from None
syntax.try: return next(iter(self)) except StopIteration: - raise ValueError("%s is empty" % self.__class__.__name__) + raise ValueError("%s is empty" % self.__class__.__name__) from None🧰 Tools
🪛 Ruff (0.8.2)
929-929: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling(B904)
Line range hint
971-1031
: Add error context when raising ValueError and improve error messageThe error handling should preserve the context of the original error and provide more descriptive error messages.
try: sample = next(matches) except StopIteration: - raise ValueError("No samples match the given expression") + raise ValueError( + "No samples match the given expression '%s'" % expr + ) from None if exact: try: next(matches) raise ValueError( - "Expected one matching sample, but found %d matches" - % len(view) + "Expected exactly one matching sample for expression '%s', but found %d matches" + % (expr, len(view)) ) except StopIteration: pass
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
fiftyone/__public__.py
(1 hunks)fiftyone/core/collections.py
(5 hunks)fiftyone/core/dataset.py
(6 hunks)fiftyone/core/view.py
(0 hunks)tests/unittests/dataset_tests.py
(0 hunks)
💤 Files with no reviewable changes (2)
- fiftyone/core/view.py
- tests/unittests/dataset_tests.py
🧰 Additional context used
🪛 Ruff (0.8.2)
fiftyone/__public__.py
166-166: .core.sample.Sample
imported but unused
Remove unused import: .core.sample.Sample
(F401)
fiftyone/core/collections.py
929-929: Within an except
clause, raise exceptions with raise ... from err
or raise ... from None
to distinguish them from errors in exception handling
(B904)
1019-1019: Within an except
clause, raise exceptions with raise ... from err
or raise ... from None
to distinguish them from errors in exception handling
(B904)
fiftyone/core/dataset.py
1239-1239: Within an except
clause, raise exceptions with raise ... from err
or raise ... from None
to distinguish them from errors in exception handling
(B904)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: test / test-app
- GitHub Check: build / build
- GitHub Check: build
🔇 Additional comments (9)
fiftyone/core/dataset.py (6)
1228-1228
: No issues found on this line. Good usage ofsuper().first()
.
1255-1258
: Clear and concise data extraction in thehead
method.
1272-1275
: Well-structured list comprehension in thetail
method.
1306-1306
: No issues; example usage in the docstring is fine.
1318-1319
: Straightforward use ofmatch()
and_aggregate()
for filtering.
1330-1331
: String formatting logic is acceptable.fiftyone/core/collections.py (3)
938-938
: LGTM: Efficient implementation of last()The implementation correctly returns the last element by taking a slice of the last element and using first() to retrieve it.
950-952
: LGTM: Clear docstring and implementation for head()The docstring accurately describes the return type and the implementation efficiently returns the first N samples as a list.
964-966
: LGTM: Clear docstring and implementation for tail()The docstring accurately describes the return type and the implementation efficiently returns the last N samples as a list.
What changes are proposed in this pull request?
How is this patch tested? If it is not, please explain why.
(Details)
Release Notes
Is this a user-facing change that should be mentioned in the release notes?
notes for FiftyOne users.
(Details in 1-2 sentences. You can just refer to another PR with a description
if this PR is part of a larger change.)
What areas of FiftyOne does this PR affect?
fiftyone
Python library changesSummary by CodeRabbit
Release Notes
Breaking Changes
SampleView
from public module importsfirst()
,last()
,head()
,tail()
, andone()
methods fromDatasetView
Improvements
SampleCollection
methods for retrieving samplesDataset
methods to simplify sample retrieval logicTesting
These changes modify how samples are accessed and retrieved in the dataset, potentially requiring updates to existing code that uses these methods.