Skip to content

Dropdown for seeing docs as latest or main #2544

Merged
aliabd merged 59 commits into
mainfrom
aliabd/toggle-main-pip
Nov 8, 2022
Merged

Dropdown for seeing docs as latest or main #2544
aliabd merged 59 commits into
mainfrom
aliabd/toggle-main-pip

Conversation

@aliabd
Copy link
Copy Markdown
Contributor

@aliabd aliabd commented Oct 26, 2022

Allows users to see the docs for both main and latest release. Live on staging.

Workflow:

  • Cronjob on the instance pulls from github every minute to see if there are any changes and if there are it builds the website using the Dockerfile
  • Dockerfile creates a gradio wheel and uploads it to s3, also uploads all the demos to spaces (with the suffix _main) and adds the wheel to their requirements. It also uploads all the demos on spaces to use the latest gradio version if a new one exists.
  • Dockerfile builds the website and the docs. The /docs page points to a static file that is already generated and saved in the repo named v{X.X.X}_template.html . The /docs/main page is built on every commit. There's a dropdown on each page for readers to switch between them.
  • When a new version is released (version.txt is changed in main), a github action opens a PR to add the new versioned docs (new v{X.X.X}_template.html file). The action installs the new version and builds the docs, so there should not be any conflicts, it also uses the versioned gradio.js instead of the built one in /docs/main, so it basically behaves entirely like a snapshot of the docs when the version was released.

I tested the github action on a fork of the repo. You can see an example of it working here or failing here because the version was a prerelease/not latest (we don't want to show docs for prereleases)

Closes: #1650

@aliabd aliabd self-assigned this Oct 26, 2022
@aliabd aliabd marked this pull request as draft October 26, 2022 21:53
@github-actions
Copy link
Copy Markdown
Contributor

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2544-all-demos

@aliabd aliabd marked this pull request as ready for review November 4, 2022 10:12
Comment thread CHANGELOG.md Outdated

## Documentation Changes:
No changes to highlight.
* See docs for the latest gradio commit to main as well the latest pip release:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's move this up to 3.9 section

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

@aliabd Thank you for this useful PR! I reviewed the upload demo and buiild logic and it looks good to me. Left some questions but nothing blocking merge.

- name: Install requirements
run: python -m pip install -r website/homepage/requirements.txt
- name: Install gradio
run: python -m pip install gradio -U
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We install from pip here right? And the reason is so that we do not use the local front-end code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure what you mean by local front-end code.

We install from pip the latest released version because that's where we want to generate these docs from. Part of the docs comes from gradio as a module and not form the /website dir. For example gradio.generate_documentation().

But on what will show up in /docs/main we install gradio from the repo and not from pip (this happens inside the Dockerfile)

Lmk if this isn't what you mean

Comment thread website/check_version.py Outdated
def wait_for_version(version: str):
for _ in range(10):
if is_version_up(version):
latest_gradio_stable = requests.get("https://pypi.org/pypi/gradio/json").json()["info"]["version"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: Maybe it's worth putting this in its own helper as I see this logic is in separate files?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good idea, done

Comment thread website/homepage/src/docs/__init__.py Outdated
docs_files = os.listdir("src/docs")
for file in docs_files:
if file.endswith("_template.html") and file.startswith("v"):
os.remove(os.path.join("src/docs", file))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We don't need to remove the old version builds right? Might be good to keep them for just-in-case even though there are not displayed on the website?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yup you're right, might be useful! done

@abidlabs
Copy link
Copy Markdown
Member

abidlabs commented Nov 4, 2022

LGTM @aliabd! One thing that is happening for me on staging is that the select dropdown to toggle between v3.9 and main sometimes takes a while to load and in the meantime I see this empty dropdown:

image

@freddyaboulton
Copy link
Copy Markdown
Collaborator

Also these two spaces are not building because they specify incompatible gradio versions in the requirements.txt

Not sure if they are needed or we can delete.
image

@abidlabs
Copy link
Copy Markdown
Member

abidlabs commented Nov 4, 2022

I don't see any reason why we've pinned the Gradio versions in these demos. We should be able to unpin and they'll probably work fine

@aliabd
Copy link
Copy Markdown
Contributor Author

aliabd commented Nov 4, 2022

@abidlabs I don't see this specific dropdown issue. Do you see that @freddyaboulton?

Screen.Recording.2022-11-04.at.1.35.03.PM.mov

That being said though, there is some really bad sluggishness on the website now. For example go https://gradio.app/docs and scroll really fast. you'll see it takes a while for things to render. I guess the page is just really heavy now and we'll have to look into that from the embedding side.

No idea why those two demos pinned a gradio version to their requirements, fixed though and should auto update the spaces once this is merged.

@freddyaboulton
Copy link
Copy Markdown
Collaborator

@aliabd The dev server behaves the same for me. The dropdown shows both options without lag. Switching versions takes about ~1 second during which the page hangs a bit. We can probably tune that with the other website performance improvements?

@abidlabs
Copy link
Copy Markdown
Member

abidlabs commented Nov 4, 2022

Ok here's what it looks like for me:

Recording 2022-11-04 at 16 42 45

But I'm okay with getting this big one in and working on general website tune-ups in a separate PR.

Comment thread website/homepage/src/docs/template.html Outdated
Copy link
Copy Markdown
Contributor

@aliabid94 aliabid94 left a comment

Choose a reason for hiding this comment

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

Just tested, LGTM!

@aliabd aliabd merged commit a80084f into main Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose "latest" vs "stable" version of the gradio docs

4 participants