Skip to content

Commit 67e6f0c

Browse files
authored
feat: only wait for tutor managed jobs while running k8s (#1230)
1 parent 3b6acae commit 67e6f0c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- [Improvement] Do not wait for non tutor jobs while running k8s. (by @mlabeeb03)

tutor/commands/k8s.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
from tutor import config as tutor_config
99
from tutor import env as tutor_env
10-
from tutor import exceptions, fmt, hooks
10+
from tutor import exceptions, fmt, hooks, serialize, utils
1111
from tutor import interactive as interactive_config
12-
from tutor import serialize, utils
1312
from tutor.commands import jobs
1413
from tutor.commands.config import save as config_save_command
1514
from tutor.commands.context import BaseTaskContext
@@ -187,7 +186,7 @@ def _load_jobs(self) -> Iterable[Any]:
187186

188187
def active_job_names(self) -> List[str]:
189188
"""
190-
Return a list of active job names
189+
Return a list of active job names that are managed by tutor.
191190
Docs:
192191
https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#list-job-v1-batch
193192
@@ -197,7 +196,10 @@ def active_job_names(self) -> List[str]:
197196
api = K8sClients.instance().batch_api
198197
return [
199198
job.metadata.name
200-
for job in api.list_namespaced_job(k8s_namespace(self.config)).items
199+
for job in api.list_namespaced_job(
200+
k8s_namespace(self.config),
201+
label_selector="app.kubernetes.io/managed-by=tutor",
202+
).items
201203
if job.status.active
202204
]
203205

0 commit comments

Comments
 (0)