Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gradio admin interface #732

Merged
merged 1 commit into from
Jan 31, 2023
Merged

Add gradio admin interface #732

merged 1 commit into from
Jan 31, 2023

Conversation

lhoestq
Copy link
Member

@lhoestq lhoestq commented Jan 30, 2023

A simple Gradio app to show the pending jobs.

Contrary to the observable notebook, this can run locally and connect to your local dev environment.

I added a feature to see the number of jobs in the queue, and a simple SQL query feature that uses DuckDB.

The app can be extended to support more admin features e.g.

  • refresh jobs
  • cancel jobs
  • show report

I'll also deploy it on Spaces

image

@lhoestq lhoestq requested a review from severo January 30, 2023 19:02
return f"❌ Unauthorized (user '{user['name']} is not a member of '{ADMIN_HF_ORGANIZATION}')"

def view_jobs(token):
global pending_jobs_df

Choose a reason for hiding this comment

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

I'm not sure if this will work for concurrent users if deployed on spaces. The same df will be shared by everyone.

Might be best to save this in an invisible gr.Dataframe component? That will be isolated per session.

Copy link
Member Author

@lhoestq lhoestq Jan 31, 2023

Choose a reason for hiding this comment

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

It's ok if it's shared by everyone for now.

I tried to store it in a gr.Dataframe though but it failed. The dataframe is 40MB and has string and timestamp types that can be null.

I can share you a pickle dump if you want to try

Copy link
Member Author

Choose a reason for hiding this comment

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

More specifically I tried to store the pandas dataframe it in a gr.Dataframe with visible=False, and it caused my server to hang

Copy link
Collaborator

@severo severo left a comment

Choose a reason for hiding this comment

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

Excellent, it's super useful, thanks.

We can see later how to integrate it inside the deployment to get a published version.

@@ -0,0 +1,5 @@
gradio==~3.16.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should have only one: pyproject.toml or requirements.txt

Copy link
Member Author

Choose a reason for hiding this comment

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

I added requirements.txt to easily deploy it on Spaces - I don't think Spaces support pyproject.toml files.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok!
If needed, we could later generate the file automatically in the CI with https://python-poetry.org/docs/cli/#export, in order to avoid duplicating the dependencies information.

@lhoestq
Copy link
Member Author

lhoestq commented Jan 31, 2023

Merging for now, and later we can improve the dataframe thing and auto deployment if we want

@lhoestq lhoestq merged commit 9387638 into main Jan 31, 2023
@lhoestq lhoestq deleted the gradio-admin-ui branch January 31, 2023 14:28
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.

None yet

3 participants