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

Add bulk annotation helper on sample #333

Merged
merged 6 commits into from
Nov 22, 2023

Conversation

gregorjerse
Copy link
Contributor

No description provided.

@gregorjerse gregorjerse force-pushed the feature/bulk_annotations branch 2 times, most recently from 0750904 to d847661 Compare November 21, 2023 11:22
@@ -222,6 +222,9 @@ def _fetch(self):
if isinstance(items, dict) and "results" in items:
self._count = items["count"]
items = items["results"]
# Store count when list of objects is received.
if isinstance(items, list):
self._count = len(items)
Copy link
Member

Choose a reason for hiding this comment

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

👌🏼

@mzganec
Copy link
Contributor

mzganec commented Nov 22, 2023

Works well.

Feature request:

  • Consider implementing also Sample.get_annotations, which would return all annotated fields in a dict. This type of output is more useful to bioinformaticians than the list of key-value pairs that we get from Sample.annotations.all().

Bugs:

  • Both Sample.annotations.count() and Sample.annotations.all().count() return a wrong number of items. I annotated four fields and count() returned one.
  • s.set_annotation (note the singular form) fails if the value is set to None, i.e., deleting a field is not supported.

@gregorjerse gregorjerse force-pushed the feature/bulk_annotations branch 3 times, most recently from 8d95cb1 to 1f22257 Compare November 22, 2023 11:26
@gregorjerse
Copy link
Contributor Author

  1. Helper get_annotations is implemented.
  2. Bugs should be fixed now.

Copy link
Contributor

@mzganec mzganec left a comment

Choose a reason for hiding this comment

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

Well done! Works as expected.

I noticed that set_annotation (note the singular form) requires explicit confirmation when deleting a field. That's fine, but note that bioinformaticians typically annotate all samples in a collection, so this may require them to press "y" several hundred times. A force argument would be nice to control the confirmation prompt. This issue doesn't need to be addressed immediately because set_annotations doesn't prompt for confirmation, so we can use that instead.

def set_annotation(self, full_path: str, value) -> Optional["AnnotationValue"]:
"""Create/update annotation value.

If value is None the annotatioe is deleted and None is returned.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: annotation

@gregorjerse gregorjerse merged commit b52797e into genialis:master Nov 22, 2023
9 checks passed
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.

None yet

3 participants