ensure unique job ids

This commit is contained in:
henryruhs
2026-09-10 21:21:53 +02:00
parent 574965f65d
commit d054cedf85
2 changed files with 11 additions and 2 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
import os
import secrets
from datetime import datetime
from typing import Optional
@@ -21,4 +22,4 @@ def get_step_output_path(job_id : str, step_index : int, output_path : str) -> O
def suggest_job_id(job_prefix : str = 'job') -> str:
return job_prefix + '-' + datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
return job_prefix + '-' + datetime.now().strftime('%Y-%m-%d-%H-%M-%S') + '-' + secrets.token_hex(4)
+9 -1
View File
@@ -1,9 +1,17 @@
import os
from facefusion.jobs.job_helper import get_step_output_path
from facefusion.jobs.job_helper import get_step_output_path, suggest_job_id
def test_get_step_output_path() -> None:
assert get_step_output_path('test-job', 0, 'test.mp4') == 'test-test-job-0.mp4'
assert get_step_output_path('test-job', 0, 'test/test.mp4') == os.path.join('test', 'test-test-job-0.mp4')
assert get_step_output_path('test-job', 0, 'invalid') is None
def test_suggest_job_id() -> None:
job_id_1 = suggest_job_id()
job_id_2 = suggest_job_id()
assert job_id_1.startswith('job')
assert not job_id_1 == job_id_2