-
Couldn't load subscription status.
- Fork 604
refactor: use dataloader for table fields #10010
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: main
Are you sure you want to change the base?
Conversation
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.
It might be worth making the interface classes into abstract base classes with abstract methods to ensure the sub-classes implement the required fields.
| @strawberry.field | ||
| async def color( | ||
| self, | ||
| info: Info[Context, None], | ||
| ) -> str: | ||
| if self.db_record: | ||
| val = self.db_record.color or "#ffffff" | ||
| else: | ||
| val = await info.context.data_loaders.dataset_split_fields.load( | ||
| (self.id, models.DatasetSplit.color), | ||
| ) | ||
| val = val or "#ffffff" | ||
| return val |
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.
| @strawberry.field | |
| async def color( | |
| self, | |
| info: Info[Context, None], | |
| ) -> str: | |
| if self.db_record: | |
| val = self.db_record.color or "#ffffff" | |
| else: | |
| val = await info.context.data_loaders.dataset_split_fields.load( | |
| (self.id, models.DatasetSplit.color), | |
| ) | |
| val = val or "#ffffff" | |
| return val | |
| @strawberry.field | |
| async def color( | |
| self, | |
| info: Info[Context, None], | |
| ) -> str: | |
| if self.db_record: | |
| val = self.db_record.color | |
| else: | |
| val = await info.context.data_loaders.dataset_split_fields.load( | |
| (self.id, models.DatasetSplit.color), | |
| ) | |
| return val |
Required type
| @strawberry.field | ||
| async def user(self, info: Info[Context, None]) -> Optional[User]: | ||
| async def user( | ||
| self, info: Info[Context, None] |
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.
| self, info: Info[Context, None] | |
| self |
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.
The Annotation interface has more in it than it used to. Is that on purpose?
Note
Refactors GraphQL types and mutations/queries to use TableFieldsDataLoader-backed field resolvers and consistent Node(id, db_record) construction, while expanding annotation schema and related fields.
Annotationinterface and concrete types to includeannotatorKind,metadata,source,identifier,user, and timing fields; alignDocumentAnnotation,SpanAnnotation,TraceAnnotation,ExperimentRunAnnotation, andProjectSessionAnnotationaccordingly (e.g.,traceId: ID).Project,Trace,Span,Dataset*,Prompt*,User*, etc.) to lazy, dataloader-backed field resolvers; standardize construction toNode(id, db_record).TableFieldsDataLoaderentries (e.g., for datasets, splits, versions, prompts, labels, users, api keys, annotations, experiments, traces, sessions) and expose them throughContext.DataLoaders.idand optionaldb_recordinstead of bespoke converters.ChatPromptVersionInput.to_orm_prompt_versionand simplify prompt mutations.noderesolver to construct nodes withidand rely on dataloaders for fields; remove legacy to_gql helpers.Span(id, db_record)and enqueue events as before.Written by Cursor Bugbot for commit 59da6ad. This will update automatically on new commits. Configure here.