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

[ENHANCEMENT] Get record by ID - refresh record resource #5500

Merged
merged 7 commits into from
Sep 19, 2024

Conversation

frascuchon
Copy link
Member

Description

This PR adds support to refresh a rg.Record from the server, allowing load responses, suggestions and vectors.

Type of change

  • Improvement (change adding some improvement to an existing functionality)

How Has This Been Tested

Checklist

  • I added relevant documentation
  • I followed the style guidelines of this project
  • I did a self-review of my code
  • I made corresponding changes to the documentation
  • I confirm My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/)

selectinload(Record.suggestions),
selectinload(Record.responses),
Copy link
Member Author

Choose a reason for hiding this comment

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

In a future step, this can be controlled by with_* query parameters as we already have for other record endpoints.

"""Retrieves the record from the server."""
model = self._client.api.records.get(self._server_id)
instance = self.from_model(model, dataset=self.dataset)
self.__dict__ = instance.__dict__
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only known way to update the internal instance state. The record from_model has complex mapping logic to build the record resource properly

Comment on lines +281 to +290
@property
def _client(self) -> Optional["Argilla"]:
if self._dataset:
return self.dataset._client

@property
def _api(self) -> Optional["RecordsAPI"]:
if self._client:
return self._client.api.records

Copy link
Member Author

Choose a reason for hiding this comment

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

To align the Resource interface definition

@frascuchon frascuchon added this to the v2.3.0 milestone Sep 18, 2024
@frascuchon frascuchon merged commit 1d9dbad into develop Sep 19, 2024
12 checks passed
@frascuchon frascuchon deleted the feat/get-record-by-id branch September 19, 2024 10:10
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.

2 participants