4
4
"context"
5
5
"encoding/json"
6
6
"errors"
7
+ "net/http"
7
8
"strconv"
8
9
"time"
9
10
@@ -291,7 +292,14 @@ func (t *TritonClientService) ModelHTTPInfer(
291
292
timeout )
292
293
defer fasthttp .ReleaseResponse (modelInferResponse )
293
294
295
+ if modelInferResponse == nil {
296
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , errors .New ("modelInferResponse is nil" ))
297
+ }
298
+
294
299
if inferErr != nil || modelInferResponse .StatusCode () != fasthttp .StatusOK {
300
+ if inferErr == nil && modelInferResponse .Body () != nil {
301
+ inferErr = errors .New ("Triton error resp: " + string (modelInferResponse .Body ()))
302
+ }
295
303
return nil , t .httpErrorHandler (modelInferResponse .StatusCode (), inferErr )
296
304
}
297
305
// decode Result.
@@ -341,6 +349,9 @@ func (t *TritonClientService) CheckServerAlive(timeout time.Duration) (bool, err
341
349
}
342
350
apiResp , httpErr := t .makeHTTPPostRequestWithDoTimeout (t .getServerURL ()+ TritonAPIForServerIsLive , nil , timeout )
343
351
defer fasthttp .ReleaseResponse (apiResp )
352
+ if apiResp == nil {
353
+ return false , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
354
+ }
344
355
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
345
356
return false , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
346
357
}
@@ -362,6 +373,9 @@ func (t *TritonClientService) CheckServerReady(timeout time.Duration) (bool, err
362
373
}
363
374
apiResp , httpErr := t .makeHTTPPostRequestWithDoTimeout (t .getServerURL ()+ TritonAPIForServerIsReady , nil , timeout )
364
375
defer fasthttp .ReleaseResponse (apiResp )
376
+ if apiResp == nil {
377
+ return false , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
378
+ }
365
379
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
366
380
return false , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
367
381
}
@@ -386,6 +400,9 @@ func (t *TritonClientService) CheckModelReady(modelName, modelVersion string, ti
386
400
t .getServerURL ()+ TritonAPIForModelPrefix + modelName + TritonAPIForModelVersionPrefix + modelVersion + "/ready" ,
387
401
nil , timeout )
388
402
defer fasthttp .ReleaseResponse (apiResp )
403
+ if apiResp == nil {
404
+ return false , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
405
+ }
389
406
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
390
407
return false , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
391
408
}
@@ -404,6 +421,9 @@ func (t *TritonClientService) ServerMetadata(timeout time.Duration) (*ServerMeta
404
421
}
405
422
apiResp , httpErr := t .makeHTTPPostRequestWithDoTimeout (t .getServerURL ()+ TritonAPIPrefix , nil , timeout )
406
423
defer fasthttp .ReleaseResponse (apiResp )
424
+ if apiResp == nil {
425
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
426
+ }
407
427
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
408
428
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
409
429
}
@@ -431,6 +451,9 @@ func (t *TritonClientService) ModelMetadataRequest(
431
451
t .getServerURL ()+ TritonAPIForModelPrefix + modelName + TritonAPIForModelVersionPrefix + modelVersion ,
432
452
nil , timeout )
433
453
defer fasthttp .ReleaseResponse (apiResp )
454
+ if apiResp == nil {
455
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
456
+ }
434
457
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
435
458
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
436
459
}
@@ -460,6 +483,9 @@ func (t *TritonClientService) ModelIndex(
460
483
}
461
484
apiResp , httpErr := t .makeHTTPPostRequestWithDoTimeout (t .getServerURL ()+ TritonAPIForRepoIndex , reqBody , timeout )
462
485
defer fasthttp .ReleaseResponse (apiResp )
486
+ if apiResp == nil {
487
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
488
+ }
463
489
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
464
490
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
465
491
}
@@ -486,6 +512,9 @@ func (t *TritonClientService) ModelConfiguration(
486
512
t .getServerURL ()+ TritonAPIForModelPrefix + modelName +
487
513
TritonAPIForModelVersionPrefix + modelVersion + "/config" , timeout )
488
514
defer fasthttp .ReleaseResponse (apiResp )
515
+ if apiResp == nil {
516
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
517
+ }
489
518
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
490
519
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
491
520
}
@@ -512,6 +541,9 @@ func (t *TritonClientService) ModelInferStats(
512
541
t .getServerURL ()+ TritonAPIForModelPrefix + modelName + TritonAPIForModelVersionPrefix + modelVersion + "/stats" ,
513
542
timeout )
514
543
defer fasthttp .ReleaseResponse (apiResp )
544
+ if apiResp == nil {
545
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
546
+ }
515
547
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
516
548
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
517
549
}
@@ -532,6 +564,9 @@ func (t *TritonClientService) ModelLoadWithHTTP(
532
564
apiResp , httpErr := t .makeHTTPPostRequestWithDoTimeout (
533
565
t .getServerURL ()+ TritonAPIForRepoModelPrefix + modelName + "/load" , modelConfigBody , timeout )
534
566
defer fasthttp .ReleaseResponse (apiResp )
567
+ if apiResp == nil {
568
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
569
+ }
535
570
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
536
571
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
537
572
}
@@ -564,6 +599,10 @@ func (t *TritonClientService) ModelUnloadWithHTTP(
564
599
) (* RepositoryModelUnloadResponse , error ) {
565
600
apiResp , httpErr := t .makeHTTPPostRequestWithDoTimeout (
566
601
t .getServerURL ()+ TritonAPIForRepoModelPrefix + modelName + "/unload" , modelConfigBody , timeout )
602
+ defer fasthttp .ReleaseResponse (apiResp )
603
+ if apiResp == nil {
604
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
605
+ }
567
606
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
568
607
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
569
608
}
@@ -624,6 +663,9 @@ func (t *TritonClientService) ShareMemoryStatus(
624
663
}
625
664
apiResp , httpErr := t .makeHTTPGetRequestWithDoTimeout (uri , timeout )
626
665
defer fasthttp .ReleaseResponse (apiResp )
666
+ if apiResp == nil {
667
+ return false , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
668
+ }
627
669
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
628
670
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
629
671
}
@@ -669,6 +711,9 @@ func (t *TritonClientService) ShareCUDAMemoryRegister(
669
711
apiResp , httpErr := t .makeHTTPPostRequestWithDoTimeout (
670
712
t .getServerURL ()+ TritonAPIForCudaMemoryRegionPrefix + regionName + "/register" , reqBody , timeout )
671
713
defer fasthttp .ReleaseResponse (apiResp )
714
+ if apiResp == nil {
715
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
716
+ }
672
717
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
673
718
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
674
719
}
@@ -695,6 +740,9 @@ func (t *TritonClientService) ShareCUDAMemoryUnRegister(
695
740
apiResp , httpErr := t .makeHTTPPostRequestWithDoTimeout (
696
741
t .getServerURL ()+ TritonAPIForCudaMemoryRegionPrefix + regionName + "/unregister" , nil , timeout )
697
742
defer fasthttp .ReleaseResponse (apiResp )
743
+ if apiResp == nil {
744
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
745
+ }
698
746
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
699
747
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
700
748
}
@@ -732,6 +780,9 @@ func (t *TritonClientService) ShareSystemMemoryRegister(
732
780
apiResp , httpErr := t .makeHTTPPostRequestWithDoTimeout (
733
781
t .getServerURL ()+ TritonAPIForSystemMemoryRegionPrefix + regionName + "/register" , reqBody , timeout )
734
782
defer fasthttp .ReleaseResponse (apiResp )
783
+ if apiResp == nil {
784
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
785
+ }
735
786
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
736
787
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
737
788
}
@@ -758,6 +809,9 @@ func (t *TritonClientService) ShareSystemMemoryUnRegister(
758
809
apiResp , httpErr := t .makeHTTPPostRequestWithDoTimeout (
759
810
t .getServerURL ()+ TritonAPIForSystemMemoryRegionPrefix + regionName + "/unregister" , nil , timeout )
760
811
defer fasthttp .ReleaseResponse (apiResp )
812
+ if apiResp == nil {
813
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
814
+ }
761
815
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
762
816
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
763
817
}
@@ -784,6 +838,9 @@ func (t *TritonClientService) GetModelTracingSetting(
784
838
apiResp , httpErr := t .makeHTTPGetRequestWithDoTimeout (
785
839
t .getServerURL ()+ TritonAPIForModelPrefix + modelName + "/trace/setting" , timeout )
786
840
defer fasthttp .ReleaseResponse (apiResp )
841
+ if apiResp == nil {
842
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
843
+ }
787
844
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
788
845
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
789
846
}
@@ -816,6 +873,9 @@ func (t *TritonClientService) SetModelTracingSetting(
816
873
apiResp , httpErr := t .makeHTTPPostRequestWithDoTimeout (
817
874
t .getServerURL ()+ TritonAPIForModelPrefix + modelName + "/trace/setting" , reqBody , timeout )
818
875
defer fasthttp .ReleaseResponse (apiResp )
876
+ if apiResp == nil {
877
+ return nil , t .httpErrorHandler (http .StatusInternalServerError , utils .ErrApiRespNil )
878
+ }
819
879
if httpErr != nil || apiResp .StatusCode () != fasthttp .StatusOK {
820
880
return nil , t .httpErrorHandler (apiResp .StatusCode (), httpErr )
821
881
}
0 commit comments