Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTX-6357: Sending heartbeats while uploading artifacts #269

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
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()
Loading