-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add cancel button to playground runs (#5566)
* feat: Add cancel button to playground runs Can cancel runs with and without datasets. Cancellation is purely client-side. The backend should abort its tasks when connection with the client is lost. * Abort network requests when gql query/mutation is disposed * Reset loading state when canceling run * Rethrow AbortError inside of authFetch
- Loading branch information
1 parent
3330bff
commit 6bafa46
Showing
8 changed files
with
139 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,52 @@ | ||
import React from "react"; | ||
import { css } from "@emotion/react"; | ||
|
||
import { Button, Icon, Icons } from "@arizeai/components"; | ||
|
||
import { Loading } from "@phoenix/components"; | ||
import { usePlaygroundContext } from "@phoenix/contexts/PlaygroundContext"; | ||
|
||
export function PlaygroundRunButton() { | ||
const runPlaygroundInstances = usePlaygroundContext( | ||
(state) => state.runPlaygroundInstances | ||
); | ||
const cancelPlaygroundInstances = usePlaygroundContext( | ||
(state) => state.cancelPlaygroundInstances | ||
); | ||
const isRunning = usePlaygroundContext((state) => | ||
state.instances.some((instance) => instance.activeRunId != null) | ||
); | ||
return ( | ||
<Button | ||
variant="primary" | ||
disabled={isRunning} | ||
icon={<Icon svg={<Icons.PlayCircleOutline />} />} | ||
loading={isRunning} | ||
icon={ | ||
!isRunning ? ( | ||
<Icon svg={<Icons.PlayCircleOutline />} /> | ||
) : ( | ||
<div | ||
css={css` | ||
margin-right: var(--ac-global-dimension-static-size-50); | ||
& > * { | ||
height: 1em; | ||
width: 1em; | ||
font-size: 1.3rem; | ||
} | ||
`} | ||
> | ||
<Loading size="S" /> | ||
</div> | ||
) | ||
} | ||
size="compact" | ||
onClick={() => { | ||
runPlaygroundInstances(); | ||
if (isRunning) { | ||
cancelPlaygroundInstances(); | ||
} else { | ||
runPlaygroundInstances(); | ||
} | ||
}} | ||
> | ||
{isRunning ? "Running..." : "Run"} | ||
{isRunning ? "Cancel" : "Run"} | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters