Skip to content

Commit

Permalink
Queue max_size defaults to Block's max_threads on ZeroGPU Spaces (#…
Browse files Browse the repository at this point in the history
…4937)

* Queue max_size defaults to Block's max_threads on ZeroGPU Spaces

* More readable ?

* CHANGELOG
  • Loading branch information
cbensimon authored Jul 17, 2023
1 parent b16732f commit c409cd5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ demo.launch()
- Warning on mobile that if a user leaves the tab, websocket connection may break. On broken connection, tries to rejoin queue and displays error conveying connection broke. By [@aliabid94](https://github.com/aliabid94) in [PR 4742](https://github.com/gradio-app/gradio/pull/4742)
- Remove blocking network calls made before the local URL gets printed - these slow down the display of the local URL, especially when no internet is available. [@aliabid94](https://github.com/aliabid94) in [PR 4905](https://github.com/gradio-app/gradio/pull/4905).
- Pinned dependencies to major versions to reduce the likelihood of a broken `gradio` due to changes in downstream dependencies by [@abidlabs](https://github.com/abidlabs) in [PR 4885](https://github.com/gradio-app/gradio/pull/4885)
- Queue `max_size` defaults to parent Blocks `max_thread` when running on Spaces with ZeroGPU hardware. By [@cbensimon](https://github.com/cbensimon) in [PR 4937](https://github.com/gradio-app/gradio/pull/4937)

## Breaking Changes:

Expand Down
3 changes: 2 additions & 1 deletion gradio/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1619,11 +1619,12 @@ def queue(
warn_deprecation(
"The client_position_to_load_data parameter is deprecated."
)
max_size_default = self.max_threads if utils.is_zero_gpu_space() else None
self._queue = queueing.Queue(
live_updates=status_update_rate == "auto",
concurrency_count=concurrency_count,
update_intervals=status_update_rate if status_update_rate != "auto" else 1,
max_size=max_size,
max_size=max_size_default if max_size is None else max_size,
blocks_dependencies=self.dependencies,
)
self.config = self.get_config_file()
Expand Down
4 changes: 4 additions & 0 deletions gradio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ def get_space() -> str | None:
return None


def is_zero_gpu_space() -> bool:
return os.getenv("SPACES_ZERO_GPU") == "true"


def readme_to_html(article: str) -> str:
try:
response = requests.get(article, timeout=3)
Expand Down

1 comment on commit c409cd5

@vercel
Copy link

@vercel vercel bot commented on c409cd5 Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.