Skip to content

Commit

Permalink
style: fixing logger
Browse files Browse the repository at this point in the history
  • Loading branch information
aatmanvaidya committed Mar 7, 2024
1 parent 2301c98 commit dc86b15
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/core/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def __init__(self, moduleName):
self.environment = os.environ.get("ENVIRONMENT", "DEVELOPMENT")
self.log = logging.getLogger(moduleName)

def info(self, msg):
self.log.info(msg)
def info(self, msg, *args, **kwargs):
self.log.info(msg, *args, **kwargs)

def debug(self, msg):
if self.environment == "DEVELOPMENT":
Expand All @@ -24,5 +24,5 @@ def exception(self, msg):
def prettyprint(self, msg):
pp.pprint(msg)

def error(self, msg):
self.log.error(msg)
def error(self, msg, *args, **kwargs):
self.log.error(self, msg, *args, **kwargs)
3 changes: 2 additions & 1 deletion src/worker/audiovec/audio_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def worker(ch, method, properties, body):
file_content = json.loads(body)
audio_path = AudioFactory.make_from_url(file_content['path'])
try:
log.info("Processing File")
media_type = MediaType.AUDIO
audio_vec = audio_vec_embedding.run(audio_path)
doc = {
Expand All @@ -40,7 +41,7 @@ def worker(ch, method, properties, body):
"date_added": datetime.utcnow(),
}
result = feluda.store.store(media_type, doc)
print(result)
log.info(result)
report = make_report_indexed(file_content, "indexed")
feluda.queue.message(feluda.config.queue.parameters.queues[1]['name'], report)
ch.basic_ack(delivery_tag=method.delivery_tag)
Expand Down
3 changes: 2 additions & 1 deletion src/worker/audiovec/audio_worker_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ def worker(ch, method, properties, body):
file_content = json.loads(body)
audio_path = AudioFactory.make_from_url(file_content['path'])
try:
log.info("Processsing File")
audio_vec = audio_vec_embedding.run(audio_path)
search_result = feluda.store.find("audio", audio_vec)
print(search_result)
log.info(search_result)
report = make_report_indexed(file_content, "searched")
feluda.queue.message(feluda.config.queue.parameters.queues[3]['name'], report)
ch.basic_ack(delivery_tag=method.delivery_tag)
Expand Down
4 changes: 2 additions & 2 deletions src/worker/vidvec/video_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ def worker(ch, method, properties, body):
file_content = json.loads(body)
video_path = VideoFactory.make_from_url(file_content['path'])
try:
print("Processing File:", video_path)
log.info("Processing file")
video_vec = vid_vec_rep_resnet.run(video_path)
doc = generate_document(video_path["path"], video_vec)
media_type = MediaType.VIDEO
result = feluda.store.store(media_type, doc)
print(result)
log.info(result)
report = make_report_indexed(file_content, "indexed")
feluda.queue.message(feluda.config.queue.parameters.queues[1]['name'], report)
ch.basic_ack(delivery_tag=method.delivery_tag)
Expand Down
4 changes: 2 additions & 2 deletions src/worker/vidvec/video_worker_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def worker(ch, method, properties, body):
file_content = json.loads(body)
video_path = VideoFactory.make_from_url(file_content['path'])
try:
print("Processing File:", video_path)
log.info("Processing File:")
video_vec = vid_vec_rep_resnet.run(video_path)
average_vector = next(video_vec)
search_result = feluda.store.find("video", average_vector.get('vid_vec'))
print(search_result)
log.info(search_result)
report = make_report_indexed(file_content, "searched")
feluda.queue.message(feluda.config.queue.parameters.queues[3]['name'], report)
ch.basic_ack(delivery_tag=method.delivery_tag)
Expand Down

0 comments on commit dc86b15

Please sign in to comment.