@@ -521,27 +521,27 @@ def create_dataset(self, **kwargs):
521
521
any of the attribute names given in kwargs.
522
522
"""
523
523
dataset = self ._create (Dataset , kwargs )
524
- #iam_integration = kwargs.get("iam_integration")
525
524
iam_integration = kwargs .get ('iam_integration' ) or self .get_organization ().get_default_iam_integration ()
526
525
if iam_integration is not None :
527
526
if not isinstance (iam_integration , IAMIntegration ):
528
- raise TypeError (f"iam integration must be a reference an `IAMIntegration` object. Found { iam_integration } " )
529
-
530
- if not iam_integration .valid :
531
- raise ValueError ("Invalid integration is invalid. Please select another integration or remove default." )
527
+ raise TypeError (f"iam integration must be a reference an `IAMIntegration` object. Found { type (iam_integration )} " )
532
528
529
+ if not iam_integration .valid :
530
+ raise ValueError ("Invalid integration is invalid. Please select another integration or remove default." )
533
531
try :
534
- import time
535
- time .sleep (5 )
536
-
537
-
538
- res = self .execute ("""mutation setSignerForDatasetPyApi($signerId: ID!, $datasetId: ID!) { setSignerForDataset(data: { signerId: $signerId}, where: {id: $datasetId}){id}} """ , {'signerId' : iam_integration .uid , 'datasetId' : dataset .uid })
539
- #result = self.execute("""mutation validateDatasetPyApi($id: ID!){validateDataset(where: {id : $id}){valid checks{name, success}} }""", {'id' : dataset.uid})
540
- # TODO: I am not sure what to do with this check...
541
- #if not result['validateDataset']['valid']:
542
- # raise labelbox.exceptions.LabelboxError(f"Signer was unsuccessfully added to the dataset. {result}")
532
+ self .execute ("""
533
+ mutation setSignerForDatasetPyApi($signerId: ID!, $datasetId: ID!) {
534
+ setSignerForDataset(data: { signerId: $signerId}, where: {id: $datasetId}){id}}
535
+ """ , {'signerId' : iam_integration .uid , 'datasetId' : dataset .uid })
536
+ validation_result = self .execute ("""
537
+ mutation validateDatasetPyApi($id: ID!){validateDataset(where: {id : $id}){
538
+ valid checks{name, success}}}
539
+ """ , {'id' : dataset .uid })
540
+ if not validation_result ['validateDataset' ]['checks' ][0 ]['success' ]:
541
+ raise labelbox .exceptions .LabelboxError (
542
+ f"IAMIntegration { validation_result ['validateDataset' ]['checks' ]['name' ]} was not successfully added added to the project."
543
+ )
543
544
except Exception as e :
544
- breakpoint ()
545
545
dataset .delete ()
546
546
raise e
547
547
return dataset
0 commit comments