mirror of
https://github.com/facefusion/facefusion.git
synced 2026-06-10 06:23:58 +02:00
optimize app context detection
This commit is contained in:
@@ -5,12 +5,14 @@ from facefusion.types import AppContext
|
||||
|
||||
|
||||
def detect_app_context() -> AppContext:
|
||||
jobs_path = os.path.join('facefusion', 'jobs')
|
||||
apis_path = os.path.join('facefusion', 'apis')
|
||||
frame = sys._getframe(1)
|
||||
|
||||
while frame:
|
||||
if os.path.join('facefusion', 'jobs') in frame.f_code.co_filename:
|
||||
if jobs_path in frame.f_code.co_filename:
|
||||
return 'cli'
|
||||
if os.path.join('facefusion', 'apis') in frame.f_code.co_filename:
|
||||
if apis_path in frame.f_code.co_filename:
|
||||
return 'api'
|
||||
frame = frame.f_back
|
||||
return 'cli'
|
||||
|
||||
Reference in New Issue
Block a user