Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
dbca5121
Commit
dbca5121
authored
Feb 03, 2023
by
siutin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add an internal API for obtaining current task id
parent
22bcc7be
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
modules/progress.py
modules/progress.py
+8
-0
webui.py
webui.py
+1
-0
No files found.
modules/progress.py
View file @
dbca5121
...
@@ -4,6 +4,7 @@ import time
...
@@ -4,6 +4,7 @@ import time
import
gradio
as
gr
import
gradio
as
gr
from
pydantic
import
BaseModel
,
Field
from
pydantic
import
BaseModel
,
Field
from
typing
import
List
from
modules.shared
import
opts
from
modules.shared
import
opts
...
@@ -37,6 +38,9 @@ def add_task_to_queue(id_job):
...
@@ -37,6 +38,9 @@ def add_task_to_queue(id_job):
pending_tasks
[
id_job
]
=
time
.
time
()
pending_tasks
[
id_job
]
=
time
.
time
()
class
CurrentTaskResponse
(
BaseModel
):
current_task
:
str
=
Field
(
default
=
None
,
title
=
"Task ID"
,
description
=
"id of the current progress task"
)
class
ProgressRequest
(
BaseModel
):
class
ProgressRequest
(
BaseModel
):
id_task
:
str
=
Field
(
default
=
None
,
title
=
"Task ID"
,
description
=
"id of the task to get progress for"
)
id_task
:
str
=
Field
(
default
=
None
,
title
=
"Task ID"
,
description
=
"id of the task to get progress for"
)
id_live_preview
:
int
=
Field
(
default
=-
1
,
title
=
"Live preview image ID"
,
description
=
"id of last received last preview image"
)
id_live_preview
:
int
=
Field
(
default
=-
1
,
title
=
"Live preview image ID"
,
description
=
"id of last received last preview image"
)
...
@@ -56,6 +60,8 @@ class ProgressResponse(BaseModel):
...
@@ -56,6 +60,8 @@ class ProgressResponse(BaseModel):
def
setup_progress_api
(
app
):
def
setup_progress_api
(
app
):
return
app
.
add_api_route
(
"/internal/progress"
,
progressapi
,
methods
=
[
"POST"
],
response_model
=
ProgressResponse
)
return
app
.
add_api_route
(
"/internal/progress"
,
progressapi
,
methods
=
[
"POST"
],
response_model
=
ProgressResponse
)
def
setup_current_task_api
(
app
):
return
app
.
add_api_route
(
"/internal/current_task"
,
current_task_api
,
methods
=
[
"GET"
],
response_model
=
CurrentTaskResponse
)
def
progressapi
(
req
:
ProgressRequest
):
def
progressapi
(
req
:
ProgressRequest
):
active
=
req
.
id_task
==
current_task
active
=
req
.
id_task
==
current_task
...
@@ -97,3 +103,5 @@ def progressapi(req: ProgressRequest):
...
@@ -97,3 +103,5 @@ def progressapi(req: ProgressRequest):
return
ProgressResponse
(
active
=
active
,
queued
=
queued
,
completed
=
completed
,
progress
=
progress
,
eta
=
eta
,
live_preview
=
live_preview
,
id_live_preview
=
id_live_preview
,
textinfo
=
shared
.
state
.
textinfo
)
return
ProgressResponse
(
active
=
active
,
queued
=
queued
,
completed
=
completed
,
progress
=
progress
,
eta
=
eta
,
live_preview
=
live_preview
,
id_live_preview
=
id_live_preview
,
textinfo
=
shared
.
state
.
textinfo
)
def
current_task_api
():
return
CurrentTaskResponse
(
current_task
=
current_task
)
\ No newline at end of file
webui.py
View file @
dbca5121
...
@@ -279,6 +279,7 @@ def webui():
...
@@ -279,6 +279,7 @@ def webui():
setup_middleware
(
app
)
setup_middleware
(
app
)
modules
.
progress
.
setup_progress_api
(
app
)
modules
.
progress
.
setup_progress_api
(
app
)
modules
.
progress
.
setup_current_task_api
(
app
)
if
launch_api
:
if
launch_api
:
create_api
(
app
)
create_api
(
app
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment