Skip to content

Commit 287cc03

Browse files
committed
Adjust eslintrc to permit _vars and align job fields across cards
Signed-off-by: Brent Salisbury <[email protected]>
1 parent 874027f commit 287cc03

File tree

10 files changed

+77
-80
lines changed

10 files changed

+77
-80
lines changed

.eslintrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,15 @@
1212
"react": {
1313
"version": "detect"
1414
}
15+
},
16+
"rules": {
17+
"@typescript-eslint/no-unused-vars": [
18+
"error",
19+
{
20+
"argsIgnorePattern": "^_",
21+
"varsIgnorePattern": "^_",
22+
"ignoreRestSiblings": true
23+
}
24+
]
1525
}
1626
}

src/app/api/fine-tune/data-sets/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
import { NextRequest, NextResponse } from 'next/server';
55

6-
export async function GET(req: NextRequest) {
6+
export async function GET(_request: NextRequest) {
7+
// eslint-disable-line @typescript-eslint/no-unused-vars
78
try {
89
const API_SERVER = process.env.NEXT_PUBLIC_API_SERVER!;
910

src/app/api/fine-tune/data/generate/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { NextResponse } from 'next/server';
44

5-
export async function POST(request: Request) {
5+
export async function POST(_request: Request) {
66
try {
77
const API_SERVER = process.env.NEXT_PUBLIC_API_SERVER!;
88

src/app/api/fine-tune/jobs/[job_id]/logs/route.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
// src/app/api/fine-tune/jobs/[job_id]/logs/route.ts
2-
import { NextResponse } from 'next/server';
1+
import { NextRequest, NextResponse } from 'next/server';
32

4-
const API_SERVER = process.env.NEXT_PUBLIC_API_SERVER!;
3+
type LogsRouteProps = {
4+
params: Promise<{ job_id: string }>;
5+
};
56

6-
export async function GET(request: Request, { params }: { params: { job_id: string } }) {
7-
const { job_id } = await Promise.resolve(params);
7+
export async function GET(request: NextRequest, props: LogsRouteProps) {
8+
const { job_id } = await props.params;
89

910
try {
10-
const response = await fetch(`${API_SERVER}/jobs/${job_id}/logs`, {
11-
method: 'GET'
12-
});
11+
const API_SERVER = process.env.NEXT_PUBLIC_API_SERVER!;
12+
const endpoint = `${API_SERVER}/jobs/${job_id}/logs`;
13+
console.log('Forwarding logs request to:', endpoint);
1314

15+
const response = await fetch(endpoint, { method: 'GET' });
1416
if (!response.ok) {
1517
const errorText = await response.text();
1618
console.error('Error from API server:', errorText);

src/app/api/fine-tune/jobs/[job_id]/status/route.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
// src/app/api/fine-tune/jobs/[job_id]/status/route.ts
22
'use server';
33

4-
import { NextResponse } from 'next/server';
4+
import { NextRequest, NextResponse } from 'next/server';
55

6-
export async function GET(request: Request, { params }: { params: { job_id: string } }) {
7-
const { job_id } = params;
6+
type StatusRouteProps = {
7+
params: Promise<{ job_id: string }>;
8+
};
9+
10+
export async function GET(request: NextRequest, props: StatusRouteProps) {
11+
const { job_id } = await props.params;
812
const API_SERVER = process.env.NEXT_PUBLIC_API_SERVER!;
913

1014
try {
11-
// Forward the request to the API server
1215
const response = await fetch(`${API_SERVER}/jobs/${job_id}/status`, {
1316
method: 'GET'
1417
});
@@ -19,8 +22,8 @@ export async function GET(request: Request, { params }: { params: { job_id: stri
1922
return NextResponse.json({ error: 'Error fetching job status' }, { status: 500 });
2023
}
2124

22-
const result = await response.json();
2325
// Return the job status to the client
26+
const result = await response.json();
2427
return NextResponse.json(result, { status: 200 });
2528
} catch (error) {
2629
console.error('Error fetching job status:', error);

src/app/api/fine-tune/jobs/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
import { NextResponse } from 'next/server';
55

6-
export async function GET(request: Request) {
6+
export async function GET(_request: Request) {
7+
// eslint-disable-line @typescript-eslint/no-unused-vars
78
const API_SERVER = process.env.NEXT_PUBLIC_API_SERVER!;
89

910
try {

src/app/api/fine-tune/model/vllm-status/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export async function GET(request: Request) {
1111
return NextResponse.json({ error: 'Missing modelName query param' }, { status: 400 });
1212
}
1313

14+
// const res = await fetch(`/api/fine-tune/model/vllm-status?modelName=${vllmName}`);
15+
1416
const API_SERVER = process.env.NEXT_PUBLIC_API_SERVER!;
1517
const endpoint = `${API_SERVER}/vllm-status?model_name=${modelName}`;
1618

src/app/api/fine-tune/models/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// src/pages/api/fine-tune/models/route.ts
1+
// src/app/api/fine-tune/models/route.ts
22
'use server';
33

44
import { NextRequest, NextResponse } from 'next/server';
55

6-
export async function GET(req: NextRequest) {
6+
export async function GET(_request: NextRequest) {
7+
// eslint-disable-line @typescript-eslint/no-unused-vars
78
try {
89
const API_SERVER = process.env.NEXT_PUBLIC_API_SERVER!;
910

src/components/Experimental/ChatEval/ChatEval.tsx

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import ModelStatusIndicator from '@/components/Experimental/ModelServeStatus/Mod
4444

4545
// TODO: get nextjs app router server side render working with the patternfly chatbot component.
4646
const MODEL_SERVER_URL = process.env.NEXT_PUBLIC_MODEL_SERVER_URL;
47-
// const MODEL_SERVER_IP = 'http://128.31.20.81';
4847

4948
const ChatModelEval: React.FC = () => {
5049
const [isUnifiedInput, setIsUnifiedInput] = useState(false);
@@ -115,8 +114,8 @@ const ChatModelEval: React.FC = () => {
115114
// Fetch models on component mount
116115
useEffect(() => {
117116
const fetchDefaultModels = async () => {
118-
const response = await fetch('/api/envConfig');
119-
const envConfig = await response.json();
117+
// const response = await fetch('/api/envConfig');
118+
// const envConfig = await response.json();
120119

121120
const storedEndpoints = localStorage.getItem('endpoints');
122121
const cust: Model[] = storedEndpoints
@@ -210,7 +209,7 @@ const ChatModelEval: React.FC = () => {
210209
} else if (endpoint.includes('serve-latest')) {
211210
const servedModel: Model = {
212211
name: 'Granite fine tune checkpoint (Serving)',
213-
apiURL: `${MODEL_SERVER_URL}:8001`, // endpoint for latest model
212+
apiURL: `${MODEL_SERVER_URL}:8001`, // endpoint for latest checkpoint
214213
modelName: 'granite-latest-served'
215214
};
216215

@@ -334,22 +333,6 @@ const ChatModelEval: React.FC = () => {
334333
setAlertMessageRight(undefined);
335334
};
336335

337-
// Common stream update handler
338-
const handleStreamUpdate = (id: string, newContent: string, setMessagesFn: React.Dispatch<React.SetStateAction<MessageProps[]>>) => {
339-
setMessagesFn((msgs) => {
340-
if (!msgs) {
341-
console.error('msgs is undefined in handleStreamUpdate');
342-
return [];
343-
}
344-
const updated = [...msgs];
345-
const idx = updated.findIndex((m) => m.id === id);
346-
if (idx !== -1) {
347-
updated[idx].content = newContent;
348-
}
349-
return updated;
350-
});
351-
};
352-
353336
const handleSend = async (side: 'left' | 'right', message: string) => {
354337
const trimmedMessage = message.trim();
355338

@@ -393,7 +376,7 @@ const ChatModelEval: React.FC = () => {
393376

394377
if (side === 'left') {
395378
setMessagesLeft((msgs) => [...msgs, userMessage]);
396-
setQuestionLeft(''); // Clear the input field
379+
setQuestionLeft('');
397380
} else {
398381
setMessagesRight((msgs) => [...msgs, userMessage]);
399382
setQuestionRight('');
@@ -640,7 +623,6 @@ const ChatModelEval: React.FC = () => {
640623
if (shouldSendLeft) {
641624
handleSend('left', trimmedMessage);
642625
}
643-
644626
if (shouldSendRight) {
645627
handleSend('right', trimmedMessage);
646628
}
@@ -681,12 +663,13 @@ const ChatModelEval: React.FC = () => {
681663
<div style={{ flex: '1 1 45%', maxWidth: '45%', marginBottom: '2rem' }}>
682664
<Chatbot isVisible={true} className="chatbot-ui-page">
683665
<ChatbotHeader className="pf-chatbot__header">
684-
<ChatbotHeaderMain />
666+
<ChatbotHeaderMain>{''}</ChatbotHeaderMain>
685667
<ChatbotHeaderActions className="pf-chatbot__header-actions">
686668
<ModelStatusIndicator modelName={selectedModelLeft?.modelName || null} />
687669
{freeGpus < 1 && !selectedModelLeft && <span style={{ color: 'red', marginRight: '0.5rem', padding: '0.5rem' }}>No GPUs free</span>}
670+
{showModelLoadingLeft && <Spinner size="sm" />}
688671
<ChatbotHeaderSelectorDropdown
689-
disabled={freeGpus < 1 && !selectedModelLeft}
672+
// disabled={(freeGpus < 1 && !selectedModelLeft) || showModelLoadingLeft}
690673
value={selectedModelLeft?.name || 'Select a model'}
691674
onSelect={onSelectModelLeft}
692675
>
@@ -745,12 +728,12 @@ const ChatModelEval: React.FC = () => {
745728
handleSendLeft(message);
746729
}}
747730
hasAttachButton={false}
748-
onChange={(event, val) => {
731+
onChange={(event: React.ChangeEvent<HTMLDivElement>, val: string) => {
749732
console.debug(`Left MessageBar onChange: "${val}"`);
750733
setQuestionLeft(val);
751734
}}
752-
value={questionLeft}
753-
placeholder="Type your prompt for the left model..."
735+
// value={questionLeft}
736+
// placeholder="Type your prompt for the left model..."
754737
// Disable send button if message is empty or no model is selected
755738
isSendButtonDisabled={!questionLeft.trim() || !selectedModelLeft}
756739
/>
@@ -789,12 +772,13 @@ const ChatModelEval: React.FC = () => {
789772
<div style={{ flex: '1 1 45%', maxWidth: '55%', marginBottom: '2rem' }}>
790773
<Chatbot isVisible={true} className="chatbot-ui-page">
791774
<ChatbotHeader className="pf-chatbot__header">
792-
<ChatbotHeaderMain />
775+
<ChatbotHeaderMain>{''}</ChatbotHeaderMain>
793776
<ChatbotHeaderActions className="pf-chatbot__header-actions">
794777
<ModelStatusIndicator modelName={selectedModelRight?.modelName || null} />
795778
{freeGpus < 1 && !selectedModelRight && <span style={{ color: 'red', marginRight: '0.5rem', padding: '0.5rem' }}>No GPUs free</span>}
779+
{showModelLoadingRight && <Spinner size="sm" />}
796780
<ChatbotHeaderSelectorDropdown
797-
disabled={freeGpus < 1 && !selectedModelLeft}
781+
// disabled={(freeGpus < 1 && !selectedModelRight) || showModelLoadingRight}
798782
value={selectedModelRight?.name || 'Select a model'}
799783
onSelect={onSelectModelRight}
800784
>
@@ -853,12 +837,12 @@ const ChatModelEval: React.FC = () => {
853837
handleSendRight(message);
854838
}}
855839
hasAttachButton={false}
856-
onChange={(event, val) => {
840+
onChange={(event: React.ChangeEvent<HTMLDivElement>, val: string) => {
857841
console.debug(`Right MessageBar onChange: "${val}"`);
858842
setQuestionRight(val);
859843
}}
860-
value={questionRight}
861-
placeholder="Type your prompt for the right model..."
844+
// value={questionRight}
845+
// placeholder="Type your prompt for the right model..."
862846
// Disable send button if message is empty or no model is selected
863847
isSendButtonDisabled={!questionRight.trim() || !selectedModelRight}
864848
/>
@@ -904,12 +888,12 @@ const ChatModelEval: React.FC = () => {
904888
handleUnifiedSend(message);
905889
}}
906890
hasAttachButton={false}
907-
onChange={(event, val) => {
891+
onChange={(event: React.ChangeEvent<HTMLDivElement>, val: string) => {
908892
console.debug(`Unified MessageBar onChange: "${val}"`);
909893
setQuestionUnified(val);
910894
}}
911-
value={questionUnified}
912-
placeholder="Type your prompt here and send to both models..."
895+
// value={questionUnified}
896+
// placeholder="Type your prompt here and send to both models..."
913897
// Disable send button if message is empty or no models are selected
914898
isSendButtonDisabled={!questionUnified.trim() || !selectedModelLeft || !selectedModelRight}
915899
/>

src/components/Experimental/FineTuning/index.tsx

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ interface Branch {
4646
interface Job {
4747
job_id: string;
4848
status: string;
49-
type?: 'generate' | 'train' | 'pipeline' | 'model-serve';
49+
type?: 'generate' | 'train' | 'pipeline' | 'model-serve' | 'vllm-run';
5050
branch?: string;
5151
start_time: string; // ISO timestamp
5252
end_time?: string;
@@ -158,17 +158,8 @@ const FineTuning: React.FC = () => {
158158
.sort((a, b) => new Date(b.start_time).getTime() - new Date(a.start_time).getTime());
159159

160160
setJobs(updatedJobs);
161-
162-
// Reset retry counts on successful fetch
163-
// Object.keys(retryCounts.current).forEach((jobId) => {
164-
// retryCounts.current[jobId] = 0;
165-
// });
166161
} catch (error) {
167162
console.error('Error fetching jobs during polling:', error);
168-
// Optionally, display a non-intrusive notification to the user
169-
170-
// Implement retry logic if needed
171-
// For now, we'll avoid clearing the jobs list to maintain UI stability
172163
}
173164
}, 10000); // Poll every 10 seconds
174165

@@ -188,8 +179,9 @@ const FineTuning: React.FC = () => {
188179
return format(date, 'PPpp');
189180
};
190181

191-
const handleToggleChange = (event: React.MouseEvent<HTMLButtonElement>) => {
192-
const id = event.currentTarget.id;
182+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
183+
const handleToggleChange = (event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent, _selected: boolean) => {
184+
const id = (event.currentTarget as HTMLButtonElement).id;
193185
setSelectedStatus(id);
194186
};
195187

@@ -237,7 +229,8 @@ const FineTuning: React.FC = () => {
237229
const newJob: Job = {
238230
job_id: result.job_id,
239231
status: 'running',
240-
type: result.job_id.startsWith('g-') ? 'generate' : result.job_id.startsWith('p-') ? 'pipeline' : 'train'
232+
type: result.job_id.startsWith('g-') ? 'generate' : result.job_id.startsWith('p-') ? 'pipeline' : 'train',
233+
start_time: new Date().toISOString()
241234
};
242235
setJobs((prevJobs) => [...prevJobs, newJob]);
243236
} else {
@@ -281,7 +274,8 @@ const FineTuning: React.FC = () => {
281274
const newJob: Job = {
282275
job_id: result.job_id,
283276
status: 'running',
284-
type: result.job_id.startsWith('g-') ? 'generate' : result.job_id.startsWith('p-') ? 'pipeline' : 'train'
277+
type: result.job_id.startsWith('g-') ? 'generate' : result.job_id.startsWith('p-') ? 'pipeline' : 'train',
278+
start_time: new Date().toISOString()
285279
};
286280
setJobs((prevJobs) => [...prevJobs, newJob]);
287281
} else {
@@ -322,7 +316,8 @@ const FineTuning: React.FC = () => {
322316
job_id: result.pipeline_job_id,
323317
status: 'running',
324318
type: 'pipeline',
325-
branch: selectedBranch
319+
branch: selectedBranch,
320+
start_time: new Date().toISOString()
326321
};
327322
setJobs((prevJobs) => [...prevJobs, newJob]);
328323
console.debug('New pipeline job added:', newJob);
@@ -445,22 +440,20 @@ const FineTuning: React.FC = () => {
445440
: 'Train Job'}
446441
</CardTitle>
447442
<CardBody>
448-
<div style={{ display: 'flex', justifyContent: 'space-between', flexWrap: 'wrap' }}>
449-
<p>
443+
{/* If fields are added, the percentages need to be tweaked to keep columns lined up across cards. */}
444+
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
445+
<div style={{ width: '25%' }}>
450446
<strong>Job ID:</strong> {job.job_id}
451-
</p>
452-
<p>
447+
</div>
448+
<div style={{ width: '25%' }}>
453449
<strong>Status:</strong> {job.status}
454-
</p>
455-
<p>
456-
<strong>Branch:</strong> {job.branch || 'N/A'}
457-
</p>
458-
<p>
450+
</div>
451+
<div style={{ width: '25%' }}>
459452
<strong>Start Time:</strong> {formatDate(job.start_time)}
460-
</p>
461-
<p>
453+
</div>
454+
<div style={{ width: '25%' }}>
462455
<strong>End Time:</strong> {formatDate(job.end_time)}
463-
</p>
456+
</div>
464457
</div>
465458
</CardBody>
466459
<CardFooter>

0 commit comments

Comments
 (0)