gradio-app / gradio

Build and share delightful machine learning apps, all in Python. ๐ŸŒŸ Star to support our work!
http://www.gradio.app
Apache License 2.0
34.22k stars 2.6k forks source link

[Custom Components] `gradio cc dev / build` doesn't work with modifying the `FRONTEND_DIR` property #8162

Open Col0ring opened 7 months ago

Col0ring commented 7 months ago

Describe the bug

gradio cc dev / build doesn't work with modifying the FRONTEND_DIR property on the Component python class after 4.28.0 version.

ValueError: Could not find `@gradio/preview`. Run `npm i -D @gradio/preview` in your frontend folder.

It seems the error was caused by this piece of code. The modifications to FRONTEND_DIR need to be synchronized here.

gradio/cli/commands/components/build.py

image

Have you searched existing issues? ๐Ÿ”Ž

Reproduction

  1. Create a component with an official template.
    gradio cc create textbox  --template SimpleTextbox
  2. move the folder frontend to frontend/textbox.
  3. Modify the FRONTEND_DIR property and run gradio cc dev.

class textbox(FormComponent): """ Creates a very simple textbox for user to enter string input or display string output. """ FRONTEND_DIR = "../../frontend/textbox"

...


### Screenshot

_No response_

### Logs

_No response_

### System Info

```shell
gradio version: 4.28.3
gradio_client version: 0.16.0

Severity

Blocking usage of gradio

pngwn commented 7 months ago

Ah, interesting. This is definitely an issue, i'll take a look!

abidlabs commented 1 month ago

Hi, apologies for the late follow up. We haven't had a chance to look into this issue, but the Gradio codebase has changed quite significantly since this issue was created, particularly with the release of Gradio 5. Could you let us know if this is still an issue in the latest version of Gradio (pip install --upgrade gradio)? Thanks!

Col0ring commented 1 month ago

Yes, this issue still exists in Gradio 5.

https://github.com/gradio-app/gradio/blob/bcb7d15a8aef1cf1b873ba3d039fbec91432c5b2/gradio/cli/commands/components/dev.py#L76

abidlabs commented 1 month ago

Thanks for confirming @Col0ring