Skip to content

Commit

Permalink
Created VersionAnnotationTask class. Added code to check for version …
Browse files Browse the repository at this point in the history
…of Annotation units.
  • Loading branch information
fatimarabab committed Apr 24, 2024
1 parent de8626b commit 6c26e7f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 6 deletions.
26 changes: 20 additions & 6 deletions backend/src/core/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,34 @@ def process_tasks(annotation_queue, genomic_unit_collection): # pylint: disable
annotation_task_futures = {}
while not annotation_queue.empty():
annotation_unit = annotation_queue.get()
version_exists = False
if genomic_unit_collection.annotation_exist(annotation_unit.genomic_unit, annotation_unit.dataset):
logger.info('%s Annotation Exists...', format_annotation_logging(annotation_unit))
if not annotation_unit.version_exists():
version_exists = True
# need to check if this version is latest
continue

if version_exists:
# 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))
ready = True
else:

# determine as version_annotation_type
# create version_annotation_task
# send version-url and attribute
# put this in background task

ready = False
continue

ready = True

if 'dependencies' in annotation_unit.dataset:
missing_dependencies = annotation_unit.get_missing_dependencies()
print("ANNOTATION UNIT & MISSING DEPENDENCIES")
print("--------------------------------------")
# print(annotation_unit.get_genomic_unit())
# print("--------------------------------------")
print(missing_dependencies)
print("--------------------------------------")
for missing in missing_dependencies:
annotation_value = genomic_unit_collection.find_genomic_unit_annotation_value(
annotation_unit.genomic_unit, missing
Expand Down
38 changes: 38 additions & 0 deletions backend/src/core/annotation_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,43 @@ 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):
"""initializes the task with the genomic_unit"""
AnnotationTaskInterface.__init__(genomic_unit_json)

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()
elif versioning_type == "rosalution":
version = self.get_version_from_rosalution()
elif versioning_type == "date":
version = self.get_version_from_date()
return version

def get_annotation_version_from_rest(self):
"""Gets version for rest type and returns the version data"""
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 = ""
# getting version from date
return version_from_date


class AnnotationTaskFactory:
Expand All @@ -199,6 +236,7 @@ class AnnotationTaskFactory:
"csv": CsvAnnotationTask,
"none": NoneAnnotationTask,
"forge": ForgeAnnotationTask,
"version": VersionAnnotationTask
}

@classmethod
Expand Down
11 changes: 11 additions & 0 deletions backend/src/core/annotation_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class AnnotationUnit:
def __init__(self, genomic_unit, dataset):
self.genomic_unit = genomic_unit
self.dataset = dataset
self.version = ""

def get_genomic_unit(self):
"""Getter method"""
Expand Down Expand Up @@ -45,3 +46,13 @@ def to_name_string(self):
Returns the annotation unit's genomic_unit and corresponding dataset.
"""
return f"{self.get_genomic_unit} for {self.get_dataset}"

def set_latest_version(self, version_info):
self.version = version_info

def version_exists(self):
if self.version == "":
return True
else:
return False

0 comments on commit 6c26e7f

Please sign in to comment.