Skip to content

Commit

Permalink
chores: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
denniswittich committed Feb 28, 2025
1 parent f506994 commit 026da82
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions learning_loop_node/detector/outbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def save(self,
image_metadata: Optional[ImageMetadata] = None,
tags: Optional[List[str]] = None,
source: Optional[str] = None,
creation_date: Optional[str] = None
) -> None:
creation_date: Optional[str] = None) -> None:

if not self._is_valid_jpg(image):
self.log.error('Invalid jpg image')
Expand Down Expand Up @@ -99,10 +98,10 @@ def _is_valid_isoformat(self, date: Optional[str]) -> bool:
except Exception:
return False

def get_data_files(self):
def get_data_files(self) -> List[str]:
return glob(f'{self.path}/*')

def ensure_continuous_upload(self):
def ensure_continuous_upload(self) -> None:
self.log.debug('start_continuous_upload')
if self._upload_process_alive():
self.log.debug('Upload thread already running')
Expand All @@ -111,15 +110,15 @@ def ensure_continuous_upload(self):
self.shutdown_event.clear()
self.upload_task = asyncio.create_task(self._continuous_upload())

async def _continuous_upload(self):
async def _continuous_upload(self) -> None:
self.log.info('continuous upload started')
assert self.shutdown_event is not None
while not self.shutdown_event.is_set():
await self.upload()
await asyncio.sleep(5)
self.log.info('continuous upload ended')

async def upload(self):
async def upload(self) -> None:
items = self.get_data_files()
if not items:
self.log.debug('No images found to upload')
Expand All @@ -135,7 +134,7 @@ async def upload(self):
except Exception:
self.log.exception('Could not upload files')

async def _upload_batch(self, items: List[str]):
async def _upload_batch(self, items: List[str]) -> None:

# NOTE: keys are not relevant for the server, but using a fixed key like 'files'
# results in a post failure on the first run of the test in a docker environment (WTF)
Expand Down

0 comments on commit 026da82

Please sign in to comment.