Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions coretex/_task/worker/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from contextlib import contextmanager

import logging
import timeit

from watchdog.events import FileSystemEventHandler, FileSystemEvent
from watchdog.observers import Observer
Expand Down Expand Up @@ -83,6 +84,10 @@ def track(taskRun: TaskRun) -> Iterator[FileEventHandler]:
observer.stop() # type: ignore[no-untyped-call]
observer.join()

logging.getLogger("coretexpylib").debug(">> [Coretex] Heartbeat")
taskRun.updateStatus() # updateStatus without params is considered heartbeat
lastTimeHeartbeat = timeit.default_timer()

for index, artifactPath in enumerate(eventHandler.artifactPaths):
logging.getLogger("coretexpylib").debug(f">> [Coretex] Uploading {index + 1}/{len(eventHandler.artifactPaths)} - \"{artifactPath}\"")

Expand All @@ -95,3 +100,8 @@ def track(taskRun: TaskRun) -> Iterator[FileEventHandler]:
except Exception as e:
logging.getLogger("coretexpylib").error(f"\tError while creating artifact: {e}")
logging.getLogger("coretexpylib").debug(f"\tError while creating artifact: {e}", exc_info = e)

if timeit.default_timer() - lastTimeHeartbeat > 5:
logging.getLogger("coretexpylib").debug(">> [Coretex] Heartbeat")
taskRun.updateStatus() # updateStatus without params is considered heartbeat
lastTimeHeartbeat = timeit.default_timer()