@@ -5,74 +5,81 @@ import { getRequest } from "../utils/requests";
55export const ApiService = ( ) => {
66 const {
77 map,
8- pointsSelector,
9- activeProject,
10- activeClass,
11- dispatchSetItems,
8+ pointsSelector : ps ,
9+ activeProject : ap ,
10+ activeClass : ac ,
11+ dispatchSetItems : dsi ,
1212 items,
13- encodeItems,
14- dispatchEncodeItems,
15- activeEncodeImageItem,
16- dispatchActiveEncodeImageItem,
17- setSpinnerLoading,
13+ encodeItems : ei ,
14+ dispatchEncodeItems : dei ,
15+ activeEncodeImageItem : aei ,
16+ dispatchActiveEncodeImageItem : daei ,
17+ setSpinnerLoading : ssl ,
1818 } = useContext ( MainContext ) ;
19-
19+
2020 const [ apiDetails , setApiDetails ] = useState ( {
21- gpu : { gpu : false } ,
22- cpu : { cpu_percent : 0 } ,
23- memory : { memory_percent : 0 } ,
21+ device : "" ,
22+ gpu : {
23+ device_name : "" ,
24+ num_gpus : 0 ,
25+ gpu_memory_total : "" ,
26+ gpu_memory_allocated : "" ,
27+ gpu_memory_cached : "" ,
28+ gpu_memory_free : "" ,
29+ } ,
30+ cpu : {
31+ cpu_percent : 0 ,
32+ cpu_cores : 0 ,
33+ cpu_logical_cores : 0 ,
34+ } ,
35+ memory : {
36+ total_memory : "" ,
37+ used_memory : "" ,
38+ free_memory : "" ,
39+ memory_percent : 0 ,
40+ } ,
2441 } ) ;
2542
2643 useEffect ( ( ) => {
27- const requestApiServiceDetails = async ( ) => {
44+ const fetchApiDetails = async ( ) => {
2845 try {
2946 const result = await getRequest ( "" ) ;
3047 result && setApiDetails ( result ) ;
31- } catch ( error ) {
32- console . error ( "Error fetching API details :" , error ) ;
48+ } catch ( err ) {
49+ console . error ( "Error:" , err ) ;
3350 }
3451 } ;
35- requestApiServiceDetails ( ) ;
36- } , [
37- map ,
38- pointsSelector ,
39- activeProject ,
40- activeClass ,
41- dispatchSetItems ,
42- items ,
43- encodeItems ,
44- dispatchEncodeItems ,
45- activeEncodeImageItem ,
46- dispatchActiveEncodeImageItem ,
47- setSpinnerLoading ,
48- ] ) ;
52+ fetchApiDetails ( ) ;
53+ } , [ map , ps , ap , ac , dsi , items , ei , dei , aei , daei , ssl ] ) ;
4954
5055 return (
51- < div className = "flex space-x-4 mt-2 " >
56+ < div className = "flex space-x-4" >
5257 < span
53- className = { `inline-flex justify-center items-center text-[10px] font-medium rounded pr-4 pl-4 ${
54- apiDetails . gpu . gpu ? "text-green-800 bg-green-200" : "text-yellow-800 bg-yellow-200"
58+ className = { `inline-flex justify-center items-center text-[10px] font-medium p-2 ${
59+ apiDetails . device === "cuda"
60+ ? "text-green-800 bg-green-200"
61+ : "text-yellow-800 bg-yellow-200"
5562 } `}
5663 >
57- { apiDetails . gpu . gpu ? "GPU Active" : "CPU Mode" }
58- { apiDetails . gpu . gpu && (
64+ { apiDetails . device === "cuda" ? "GPU Active" : "CPU Mode" }
65+ { apiDetails . device === "cuda" && (
5966 < >
60- { ` | Device : ${ apiDetails . gpu . device_name } ` }
67+ { ` | Dev : ${ apiDetails . gpu . device_name } ` }
6168 { ` | GPUs: ${ apiDetails . gpu . num_gpus } ` }
62- { ` | GPU Memory Total: ${ apiDetails . gpu . gpu_memory_total } ` }
63- { ` | GPU Memory Allocated : ${ apiDetails . gpu . gpu_memory_allocated } ` }
64- { ` | GPU Memory Cached: ${ apiDetails . gpu . gpu_memory_cached } ` }
65- { ` | GPU Memory Free: ${ apiDetails . gpu . gpu_memory_free } ` }
69+ { ` | Total Mem : ${ apiDetails . gpu . gpu_memory_total } ` }
70+ { ` | Alloc Mem : ${ apiDetails . gpu . gpu_memory_allocated } ` }
71+ { ` | Cached Mem : ${ apiDetails . gpu . gpu_memory_cached } ` }
72+ { ` | Free Mem : ${ apiDetails . gpu . gpu_memory_free } ` }
6673 </ >
6774 ) }
68- { ` | CPU Usage : ${ apiDetails . cpu . cpu_percent } %` }
69- { ` | CPU Cores: ${ apiDetails . cpu . cpu_cores } ` }
70- { ` | Logical CPU Cores: ${ apiDetails . cpu . cpu_logical_cores } ` }
71- { ` | Memory Usage : ${ apiDetails . memory . memory_percent } %` }
72- { ` | Total Memory : ${ apiDetails . memory . total_memory } ` }
73- { ` | Used Memory : ${ apiDetails . memory . used_memory } ` }
74- { ` | Free Memory : ${ apiDetails . memory . free_memory } ` }
75+ { ` | CPU: ${ apiDetails . cpu . cpu_percent } %` }
76+ { ` | Cores: ${ apiDetails . cpu . cpu_cores } ` }
77+ { ` | Log Cores: ${ apiDetails . cpu . cpu_logical_cores } ` }
78+ { ` | Mem Use : ${ apiDetails . memory . memory_percent } %` }
79+ { ` | Total: ${ apiDetails . memory . total_memory } ` }
80+ { ` | Used: ${ apiDetails . memory . used_memory } ` }
81+ { ` | Free: ${ apiDetails . memory . free_memory } ` }
7582 </ span >
7683 </ div >
7784 ) ;
78- } ;
85+ } ;
0 commit comments