Skip to content

Commit

Permalink
Add option to skip scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
wsanchez committed Nov 9, 2023
1 parent 806e556 commit b518840
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions src/transmissions/indexer/_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ async def indexIntoStore(
self,
store: TXDataStore,
*,
existingOnly: bool = True,
computeChecksum: bool = True,
computeTranscription: bool = True,
computeDuration: bool = True,
Expand All @@ -427,28 +428,37 @@ async def indexIntoStore(
await store.createEvent(self.event)

taskQueue: deque[Awaitable[Any]] = deque()
scanComplete = False

def scan() -> None:
nonlocal scanComplete
for transmission in self.transmissions():
# Note that the data store may not be thread safe but we are OK
# here because we aren't doing the actual store work in the
# scanning thread; we are merely adding it to a queue, which is
# processed on the main thread.
taskQueue.append(
self._ensureTransmission(
store,
transmission,
taskQueue,
computeChecksum=computeChecksum,
computeTranscription=computeTranscription,
computeDuration=computeDuration,
)

def queueTransmission(transmission: Transmission) -> None:
taskQueue.append(
self._ensureTransmission(
store,
transmission,
taskQueue,
computeChecksum=computeChecksum,
computeTranscription=computeTranscription,
computeDuration=computeDuration,
)
scanComplete = True
)

scanTask = deferToThread(scan)
if existingOnly:
for transmission in await store.transmissions():
queueTransmission(transmission)
scanComplete = True
else:
scanComplete = False

def scan() -> None:
nonlocal scanComplete
for transmission in self.transmissions():
# Note that the data store may not be thread safe but we are
# OK here because we aren't doing the actual store work in
# the scanning thread; we are merely adding it to a queue,
# which is processed on the main thread.
queueTransmission(transmission)
scanComplete = True

scanTask = deferToThread(scan)

if computeTranscription:
# Load Whisper before we start tasks
Expand Down

0 comments on commit b518840

Please sign in to comment.