Skip to content

Commit

Permalink
bump to node 20 (#9632)
Browse files Browse the repository at this point in the history
* bump to node 20

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
pngwn and gradio-pr-bot authored Oct 9, 2024
1 parent 2eaa066 commit 9b58ab0
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/clear-walls-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": minor
---

feat:bump to node 20
6 changes: 4 additions & 2 deletions gradio/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,9 @@ def serve_static_file(
return client_utils.synchronize_async(
processing_utils.async_move_files_to_cache, data, self
)
except AttributeError: # Can be raised if this function is called before the Block is fully initialized.
except (
AttributeError
): # Can be raised if this function is called before the Block is fully initialized.
return data


Expand Down Expand Up @@ -2316,7 +2318,7 @@ def launch(
max_file_size: The maximum file size in bytes that can be uploaded. Can be a string of the form "<value><unit>", where value is any positive integer and unit is one of "b", "kb", "mb", "gb", "tb". If None, no limit is set.
enable_monitoring: Enables traffic monitoring of the app through the /monitoring endpoint. By default is None, which enables this endpoint. If explicitly True, will also print the monitoring URL to the console. If False, will disable monitoring altogether.
strict_cors: If True, prevents external domains from making requests to a Gradio server running on localhost. If False, allows requests to localhost that originate from localhost but also, crucially, from "null". This parameter should normally be True to prevent CSRF attacks but may need to be False when embedding a *locally-running Gradio app* using web components.
ssr_mode: If True, the Gradio app will be rendered using server-side rendering mode, which is typically more performant and provides better SEO, but this requires Node 18+ to be installed on the system. If False, the app will be rendered using client-side rendering mode. If None, will use GRADIO_SSR_MODE environment variable or default to False.
ssr_mode: If True, the Gradio app will be rendered using server-side rendering mode, which is typically more performant and provides better SEO, but this requires Node 20+ to be installed on the system. If False, the app will be rendered using client-side rendering mode. If None, will use GRADIO_SSR_MODE environment variable or default to False.
Returns:
app: FastAPI app object that is running the demo
local_url: Locally accessible link to the demo
Expand Down
2 changes: 1 addition & 1 deletion gradio/node_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def start_node_process(
f"Cannot start Node server on any port in the range {server_ports[0]}-{server_ports[-1]}."
)
print(
"Please install Node 18 or higher and set the environment variable GRADIO_NODE_PATH to the path of your Node executable."
"Please install Node 20 or higher and set the environment variable GRADIO_NODE_PATH to the path of your Node executable."
)
print(
"You can explicitly specify a port by setting the environment variable GRADIO_NODE_PORT."
Expand Down
6 changes: 4 additions & 2 deletions gradio/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,9 @@ def login(form_data: OAuth2PasswordRequestForm = Depends()):
not callable(app.auth)
and username in app.auth
and compare_passwords_securely(password, app.auth[username]) # type: ignore
) or (callable(app.auth) and app.auth.__call__(username, password)): # type: ignore
) or (
callable(app.auth) and app.auth.__call__(username, password)
): # type: ignore
token = secrets.token_urlsafe(16)
app.tokens[token] = username
response = JSONResponse(content={"success": True})
Expand Down Expand Up @@ -1553,7 +1555,7 @@ def mount_gradio_app(
favicon_path: If a path to a file (.png, .gif, or .ico) is provided, it will be used as the favicon for this gradio app's page.
show_error: If True, any errors in the gradio app will be displayed in an alert modal and printed in the browser console log. Otherwise, errors will only be visible in the terminal session running the Gradio app.
max_file_size: The maximum file size in bytes that can be uploaded. Can be a string of the form "<value><unit>", where value is any positive integer and unit is one of "b", "kb", "mb", "gb", "tb". If None, no limit is set.
ssr_mode: If True, the Gradio app will be rendered using server-side rendering mode, which is typically more performant and provides better SEO, but this requires Node 18+ to be installed on the system. If False, the app will be rendered using client-side rendering mode. If None, will use GRADIO_SSR_MODE environment variable or default to False.
ssr_mode: If True, the Gradio app will be rendered using server-side rendering mode, which is typically more performant and provides better SEO, but this requires Node 20+ to be installed on the system. If False, the app will be rendered using client-side rendering mode. If None, will use GRADIO_SSR_MODE environment variable or default to False.
node_server_name: The name of the Node server to use for SSR. If None, will use GRADIO_NODE_SERVER_NAME environment variable or search for a node binary in the system.
node_port: The port on which the Node server should run. If None, will use GRADIO_NODE_SERVER_PORT environment variable or find a free port.
Example:
Expand Down
2 changes: 1 addition & 1 deletion gradio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ def get_node_path():

print("Unable to find node install path, falling back to SPA mode.")
print(
"If you wish to use the node backend, please install node 18 and/ or set the path with the GRADIO_NODE_PATH environment variable."
"If you wish to use the node backend, please install node 20 and/ or set the path with the GRADIO_NODE_PATH environment variable."
)
return None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You will need to have:

* Python 3.10+ (<a href="https://www.python.org/downloads/" target="_blank">install here</a>)
* pip 21.3+ (`python -m pip install --upgrade pip`)
* Node.js v16.14+ (<a href="https://nodejs.dev/en/download/package-manager/" target="_blank">install here</a>)
* Node.js 20+ (<a href="https://nodejs.dev/en/download/package-manager/" target="_blank">install here</a>)
* npm 9+ (<a href="https://docs.npmjs.com/downloading-and-installing-node-js-and-npm/" target="_blank">install here</a>)
* Gradio 5+ (`pip install --upgrade gradio`)

Expand Down
2 changes: 1 addition & 1 deletion guides/08_custom-components/07_pdf-component-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This is a sneak preview of what our finished component will look like:
![demo](https://gradio-builds.s3.amazonaws.com/assets/PDFDisplay.png)

## Step 0: Prerequisites
Make sure you have gradio 4.0 or higher installed as well as node 18+.
Make sure you have gradio 5.0 or higher installed as well as node 20+.
As of the time of publication, the latest release is 4.1.1.
Also, please read the [Five Minute Tour](./custom-components-in-five-minutes) of custom components and the [Key Concepts](./key-component-concepts) guide before starting.

Expand Down

0 comments on commit 9b58ab0

Please sign in to comment.