mirror of
https://github.com/facefusion/facefusion.git
synced 2026-09-15 12:05:27 +02:00
ensure unique job ids
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user