Skip to content

Commit

Permalink
Small fix to overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tssweeney committed Nov 18, 2024
1 parent 402232f commit 8d07a9d
Showing 1 changed file with 49 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,52 +26,7 @@ import {CallSchema} from '../wfReactInterface/wfDataModelHooksInterface';

const RUNNABLE_REF_PREFIX = 'wandb.runnable';

// New RunButton component
const RunButton: React.FC<{
actionRef: string;
callId: string;
entity: string;
project: string;
refetchFeedback: () => void;
}> = ({actionRef, callId, entity, project, refetchFeedback}) => {
const getClient = useGetTraceServerClientContext();

const [isRunning, setIsRunning] = useState(false);
const [error, setError] = useState<string | null>(null);

const handleRunClick = async () => {
setIsRunning(true);
setError(null);
try {
await getClient().actionsExecuteBatch({
project_id: projectIdFromParts({entity, project}),
call_ids: [callId],
action_ref: actionRef,
});
refetchFeedback();
} catch (err) {
setError('An error occurred while running the action.');
} finally {
setIsRunning(false);
}
};

if (error) {
return (
<Button variant="destructive" onClick={handleRunClick} disabled>
Error
</Button>
);
}

return (
<div>
<Button variant="secondary" onClick={handleRunClick} disabled={isRunning}>
{isRunning ? 'Running...' : 'Run'}
</Button>
</div>
);
};

const useLatestActionDefinitionsForCall = (call: CallSchema) => {
const actionSpecs = (
Expand Down Expand Up @@ -311,7 +266,7 @@ export const CallScoresViewer: React.FC<{
{
field: 'run',
headerName: '',
width: 70,
width:75,
rowSpanValueGetter: (value, row) => row.displayName,
renderCell: params => {
const actionRef = params.row.runnableActionRef;
Expand Down Expand Up @@ -367,3 +322,51 @@ export const CallScoresViewer: React.FC<{
</>
);
};


const RunButton: React.FC<{
actionRef: string;
callId: string;
entity: string;
project: string;
refetchFeedback: () => void;
}> = ({actionRef, callId, entity, project, refetchFeedback}) => {
const getClient = useGetTraceServerClientContext();

const [isRunning, setIsRunning] = useState(false);
const [error, setError] = useState<string | null>(null);

const handleRunClick = async () => {
setIsRunning(true);
setError(null);
try {
await getClient().actionsExecuteBatch({
project_id: projectIdFromParts({entity, project}),
call_ids: [callId],
action_ref: actionRef,
});
refetchFeedback();
} catch (err) {
setError('An error occurred while running the action.');
} finally {
setIsRunning(false);
}
};


if (error) {
return (
<Button variant="destructive" onClick={handleRunClick} disabled style={{width: '55px'}}>
Error
</Button>
);
}

return (
<div>
<Button variant="secondary" onClick={handleRunClick} disabled={isRunning} style={{width: '55px'}}>
{isRunning ? '...' : 'Run'}
</Button>
</div>
);
};

0 comments on commit 8d07a9d

Please sign in to comment.