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

Download Button [1/n]: Setup UI on the editor client #1061

Merged
merged 1 commit into from
Jan 29, 2024
Merged

Conversation

rossdanlm
Copy link
Contributor

@rossdanlm rossdanlm commented Jan 29, 2024

Download Button [1/n]: Setup UI on the editor client

If the download callback is defined (not for local editor or VSCode, but will be for Gradio), then we display it and use the loading state to disable you from clicking on the button.

I'm making the signature of the callback take in an AIConfig object parameter, because we have function clientConfigToAIConfig within the editor pacakge:

export function clientConfigToAIConfig(clientConfig: ClientAIConfig): AIConfig {

Test Plan

Rebase onto #1045

Go to aiconfig/python/src/aiconfig/editor/client and run this command:

rm -rf node_modules && yarn && yarn build

Then go to aiconfig dir and run this command:

aiconfig_path=./cookbooks/Gradio/huggingface.aiconfig.json
parsers_path=./cookbooks/Gradio/hf_model_parsers.py
aiconfig edit --aiconfig-path=$aiconfig_path --server-port=8080 --server-mode=debug_servers --parsers-module-path=$parsers_path
3460ce7d-5164-4ec1-9bee-be70b9758724.mp4

If the download callback is defined (not for local editor or VSCode, but will be for Gradio), then we display it and use the loading state to disable you from clicking on the button.

I'm making the signature of the callback take in an AIConfig object parameter, because we have function `clientConfigToAIConfig` within the editor pacakge: https://github.com/lastmile-ai/aiconfig/blob/c838856f36941b0796c8f12edcf846cc18ebdaa1/python/src/aiconfig/editor/client/src/shared/types.ts#L37

## Test Plan
Rebase onto #1045

Go to `aiconfig/python/src/aiconfig/editor/client` and run this command:
```
rm -rf node_modules && yarn && yarn build
```

Then go to `aiconfig` dir and run this command:
```
aiconfig_path=./cookbooks/Gradio/huggingface.aiconfig.json
parsers_path=./cookbooks/Gradio/hf_model_parsers.py
aiconfig edit --aiconfig-path=$aiconfig_path --server-port=8080 --server-mode=debug_servers --parsers-module-path=$parsers_path
```

https://github.com/lastmile-ai/aiconfig/assets/151060367/123319cf-2e92-49e8-8f93-2d930a3b0ac7
return;
}
try {
await downloadCallback(config);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, this is kind of strange -- here we are using the client config as the source of truth and I guess sending it to the server to initiate the download? Can't we just use the server-copy similar to share?

Copy link
Contributor

Choose a reason for hiding this comment

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

r.e. using server link. If we had an endpoint for the server to give us the download we would be able to just use the download property for an anchor element: https://developer.mozilla.org/en-US/docs/Web/API/HTMLAnchorElement/download

Copy link
Contributor Author

Choose a reason for hiding this comment

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

endpoint for the server to give us the download

You mean give us the AIConfig from server? This is similar to the load() endpoint which we could re-use if desired (but we'd have to refactor it to accept sessionId to get the right AIConfig instance)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. I think this is fine for now. In gradio we can just fetch from the server and download. It won't actually be 2 hops since it's just one server request (to download the config) and then the browser -> user machine is a synchronous (local) operation, right?

Copy link
Contributor

@rholinshead rholinshead left a comment

Choose a reason for hiding this comment

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

Synced over slack. I think this is good for now

@rossdanlm rossdanlm merged commit 1c5fa98 into main Jan 29, 2024
2 checks passed
@rossdanlm rossdanlm deleted the pr1061 branch January 29, 2024 20:59
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

2 participants