From 2e3ceb8f5824a6b1c91b73e03c15667ad4ba6aa1 Mon Sep 17 00:00:00 2001 From: Rabab Fatima Date: Wed, 24 Apr 2024 16:53:40 -0500 Subject: [PATCH] Linted, Formatted and fixed some function names. --- backend/src/core/annotation.py | 16 +++++++++------- backend/src/core/annotation_task.py | 26 ++++++++++++++------------ backend/src/core/annotation_unit.py | 10 +++++----- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/backend/src/core/annotation.py b/backend/src/core/annotation.py index 275451ee..cd2d50b1 100644 --- a/backend/src/core/annotation.py +++ b/backend/src/core/annotation.py @@ -103,15 +103,17 @@ def process_tasks(annotation_queue, genomic_unit_collection): # pylint: disable # check if the version is latest latest = False if annotation_unit.version is latest: - logger.info('%s Annotation Exists with Latest Version...', format_annotation_logging(annotation_unit)) + logger.info( + '%s Annotation Exists with Latest Version...', format_annotation_logging(annotation_unit) + ) ready = True else: - - # determine as version_annotation_type - # create version_annotation_task - # send version-url and attribute - # put this in background task - + + # determine as version_annotation_type + # create version_annotation_task + # send version-url and attribute + # put this in background task + ready = False continue diff --git a/backend/src/core/annotation_task.py b/backend/src/core/annotation_task.py index 63e7ddd4..9fc96410 100644 --- a/backend/src/core/annotation_task.py +++ b/backend/src/core/annotation_task.py @@ -186,24 +186,29 @@ def build_url(self): Builds the URL from the base_url and then appends the list of query parameters for the list of datasets. """ return self.aggregate_string_replacements(self.dataset['url']) - + + class VersionAnnotationTask(AnnotationTaskInterface): """An annotation task that gets the version of the annotation""" - def __init__(self, genomic_unit_json: dict): + def __init__(self, genomic_unit_json): """initializes the task with the genomic_unit""" - AnnotationTaskInterface.__init__(genomic_unit_json) + AnnotationTaskInterface.__init__(self, genomic_unit_json) + + def annotate(self): + """placeholder for annotating a genomic unit with version""" + return "not-implemented" def versioning_by_method(self, versioning_type): """Gets version by versioning type and returns the version data to the annotation unit""" version = "" if versioning_type == "rest": - version = self.get_version_from_rest() + version = self.get_annotation_version_from_rest() elif versioning_type == "rosalution": - version = self.get_version_from_rosalution() + version = self.get_annotation_version_from_rosalution() elif versioning_type == "date": - version = self.get_version_from_date() + version = self.get_annotation_version_from_date() return version def get_annotation_version_from_rest(self): @@ -211,13 +216,13 @@ def get_annotation_version_from_rest(self): version_from_rest = "" # getting version from rest return version_from_rest - + def get_annotation_version_from_rosalution(self): """Gets version for rosalution type and returns the version data""" version_from_rosalution = "" # getting version from rosalution return version_from_rosalution - + def get_annotation_version_from_date(self): """Gets version for date type and returns the version data""" version_from_date = "" @@ -232,10 +237,7 @@ class AnnotationTaskFactory: """ tasks = { - "http": HttpAnnotationTask, - "csv": CsvAnnotationTask, - "none": NoneAnnotationTask, - "forge": ForgeAnnotationTask, + "http": HttpAnnotationTask, "csv": CsvAnnotationTask, "none": NoneAnnotationTask, "forge": ForgeAnnotationTask, "version": VersionAnnotationTask } diff --git a/backend/src/core/annotation_unit.py b/backend/src/core/annotation_unit.py index 2cea3903..75989efc 100644 --- a/backend/src/core/annotation_unit.py +++ b/backend/src/core/annotation_unit.py @@ -47,12 +47,12 @@ def to_name_string(self): """ return f"{self.get_genomic_unit} for {self.get_dataset}" - def set_latest_version(self, version_info): - self.version = version_info + def set_latest_version(self, version_details): + """Sets the Annotation Unit with the version details""" + self.version = version_details def version_exists(self): + """Checks if the Annotation Unit is versioned or not""" if self.version == "": return True - else: - return False - \ No newline at end of file + return False