@@ -381,7 +381,7 @@ def evaluate_classification(self, dataset: DatasetBase) -> "EvalJob":
381381 }
382382
383383 resp = self .client ._requests_post_rel_host (
384- "/ clf-metrics" , json = payload
384+ "clf-metrics" , json = payload
385385 ).json ()
386386
387387 return EvalJob (client = self .client , ** resp )
@@ -438,7 +438,7 @@ def get_confusion_matrices_at_evaluation_settings_id(
438438 self , eval_settings_id : int
439439 ) -> List [dict ]:
440440 return self .client ._requests_get_rel_host (
441- f"/ models/{ self .name } /evaluation-settings/{ eval_settings_id } /confusion-matrices"
441+ f"models/{ self .name } /evaluation-settings/{ eval_settings_id } /confusion-matrices"
442442 ).json ()
443443
444444 def get_metric_dataframes (self ):
@@ -599,7 +599,7 @@ def evaluate_ap(
599599 payload ["ious_to_keep" ] = ious_to_keep
600600
601601 resp = self .client ._requests_post_rel_host (
602- "/ ap-metrics" , json = payload
602+ "ap-metrics" , json = payload
603603 ).json ()
604604 # resp should have keys "missing_pred_labels", "ignored_pred_labels", with values
605605 # list of label dicts. convert label dicts to Label objects
@@ -695,6 +695,11 @@ def _requests_wrapper(
695695 ):
696696 assert method_name in ["get" , "post" , "put" , "delete" ]
697697
698+ if endpoint [0 ] == "/" :
699+ raise ValueError (
700+ "`endpoint` should not start with a forward slash."
701+ )
702+
698703 url = urljoin (self .host , endpoint )
699704 requests_method = getattr (requests , method_name )
700705
@@ -704,9 +709,10 @@ def _requests_wrapper(
704709 headers = None
705710 resp = requests_method (url , headers = headers , * args , ** kwargs )
706711 if not resp .ok :
707- if resp .status_code == 500 :
712+ try :
713+ raise ClientException (resp .json ()["detail" ])
714+ except (requests .exceptions .JSONDecodeError , KeyError ):
708715 resp .raise_for_status ()
709- raise ClientException (resp .json ()["detail" ])
710716
711717 return resp
712718
@@ -853,23 +859,23 @@ def __init__(
853859 setattr (self , k , v )
854860
855861 def status (self ) -> str :
856- resp = self .client ._requests_get_rel_host (f"/ jobs/{ self ._id } " ).json ()
862+ resp = self .client ._requests_get_rel_host (f"jobs/{ self ._id } " ).json ()
857863 return resp ["status" ]
858864
859865
860866class EvalJob (Job ):
861867 def metrics (self ) -> List [dict ]:
862868 return self .client ._requests_get_rel_host (
863- f"/ jobs/{ self ._id } /metrics"
869+ f"jobs/{ self ._id } /metrics"
864870 ).json ()
865871
866872 def confusion_matrices (self ) -> List [dict ]:
867873 return self .client ._requests_get_rel_host (
868- f"/ jobs/{ self ._id } /confusion-matrices"
874+ f"jobs/{ self ._id } /confusion-matrices"
869875 ).json ()
870876
871877 # TODO: replace value with a dataclass?
872878 def settings (self ) -> dict :
873879 return self .client ._requests_get_rel_host (
874- f"/ jobs/{ self ._id } /settings"
880+ f"jobs/{ self ._id } /settings"
875881 ).json ()
0 commit comments