-
Notifications
You must be signed in to change notification settings - Fork 15
chore: deprecate trackHash #1028
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
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @arthur-encord, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses the deprecation of the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Unit test report (Python 3.9.24, Pydantic 2.12.3)268 tests 268 ✅ 8s ⏱️ Results for commit b22b22c. |
Unit test report (Python 3.9.24, Pydantic 1.10.22)268 tests 268 ✅ 9s ⏱️ Results for commit b22b22c. |
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.
Code Review
This pull request aims to deprecate the trackHash attribute, as it's no longer used by the Encord platform. The changes involve removing the initialization and usage of _track_hash in the Answer class and replacing it with a hardcoded empty string in the serialized output. A deprecation warning is also added for the track_hash parameter in Answer.__init__.
My review found a significant issue with the implementation of the deprecation warning. It appears to be unreachable because the subclasses of Answer do not propagate the track_hash parameter to the superclass constructor. This makes the deprecation ineffective. I've left a detailed comment with a suggestion on how to fix this. Addressing this is important for the deprecation to work as intended.
| if track_hash is not None: | ||
| warnings.warn( | ||
| "The 'track_hash' parameter is deprecated and will be removed in a future release. " | ||
| "It is no longer used by the Encord platform.", | ||
| category=DeprecationWarning, | ||
| stacklevel=2, | ||
| ) |
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.
This deprecation warning is currently unreachable. The Answer class is an abstract base class and cannot be instantiated directly. Its concrete subclasses (TextAnswer, RadioAnswer, etc.) define __init__ methods that do not accept a track_hash argument. Consequently, super().__init__ is always called with track_hash as None, and this warning is never triggered.
To make the deprecation warning functional, the __init__ methods of all Answer subclasses should be updated to accept and pass on the track_hash argument.
For example, for TextAnswer:
# In encord/objects/answers.py
class TextAnswer(Answer[str, TextAttribute]):
def __init__(self, ontology_attribute: TextAttribute, track_hash: Optional[str] = None):
super().__init__(ontology_attribute, track_hash=track_hash)
self._value: Optional[str] = NoneThis change (and similar ones for RadioAnswer, ChecklistAnswer, and NumericAnswer) is needed to allow users to pass the track_hash parameter and receive the deprecation warning.
SDK integration test report285 tests ±0 277 ✅ +1 15m 44s ⏱️ - 3m 6s For more details on these failures, see this check. Results for commit b22b22c. ± Comparison against base commit a9c7401. |
Introduction and Explanation
trackHashis not anymore by the Encord platform. The ontology element uid and value of theAnswerfully identifies the range.