Skip to content

Commit 8486352

Browse files
committed
Add unique suffix to task names, fallback to timestamp if unnamed
1 parent a27969b commit 8486352

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

sky/dag.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ def add(self, task: 'task.Task') -> None:
7474
ValueError: If the task already exists in the DAG or if its name
7575
is already used.
7676
"""
77-
if task.name is None:
78-
task.name = common_utils.get_unique_task_name(task)
77+
task.name = common_utils.get_unique_task_name(task)
7978
if task.name in self._task_name_lookup:
8079
with ux_utils.print_exception_no_traceback():
8180
raise ValueError(

sky/serve/serve_utils.py

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
if typing.TYPE_CHECKING:
3838
import fastapi
3939

40-
from sky import task as task_lib
4140
from sky.serve import replica_managers
4241

4342
SKY_SERVE_CONTROLLER_NAME: str = (

sky/utils/common_utils.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,10 @@ def get_global_job_id(job_timestamp: str,
232232
return global_job_id
233233

234234

235-
def get_unique_task_name(_: 'task_lib.Task') -> str:
236-
timestamp = int(time.time())
235+
def get_unique_task_name(task: 'task_lib.Task') -> str:
236+
name = task.name or f'task_{int(time.time())}'
237237
unique_suffix = uuid.uuid4().hex[:6]
238-
name = f'task_{timestamp}_{unique_suffix}'
239-
return name
238+
return f'{name}_{unique_suffix}'
240239

241240

242241
class Backoff:

0 commit comments

Comments
 (0)