|
1 | 1 | # type: ignore |
2 | 2 | from datetime import datetime, timezone |
3 | 3 | import json |
| 4 | +from labelbox.schema.iam_integration import IAMIntegration |
4 | 5 | import logging |
5 | 6 | import mimetypes |
6 | 7 | import os |
@@ -519,7 +520,27 @@ def create_dataset(self, **kwargs): |
519 | 520 | InvalidAttributeError: If the Dataset type does not contain |
520 | 521 | any of the attribute names given in kwargs. |
521 | 522 | """ |
522 | | - return self._create(Dataset, kwargs) |
| 523 | + dataset = self._create(Dataset, kwargs) |
| 524 | + #iam_integration = kwargs.get("iam_integration") |
| 525 | + iam_integration = kwargs.get('iam_integration') or self.get_organization().get_default_iam_integration() |
| 526 | + if iam_integration is not None: |
| 527 | + if not isinstance(iam_integration, IAMIntegration): |
| 528 | + raise TypeError(f"iam integration must be a reference an `IAMIntegration` object. Found {iam_integration}") |
| 529 | + try: |
| 530 | + import time |
| 531 | + time.sleep(5) |
| 532 | + print(iam_integration.uid) |
| 533 | + res = self.execute("""mutation setSignerForDatasetPyApi($signerId: ID!, $datasetId: ID!) { setSignerForDataset(data: { signerId: $signerId}, where: {id: $datasetId}){id}} """, {'signerId' : iam_integration.uid, 'datasetId' : dataset.uid}) |
| 534 | + #result = self.execute("""mutation validateDatasetPyApi($id: ID!){validateDataset(where: {id : $id}){valid checks{name, success}} }""", {'id' : dataset.uid}) |
| 535 | + # TODO: I am not sure what to do with this check... |
| 536 | + #if not result['validateDataset']['valid']: |
| 537 | + # raise labelbox.exceptions.LabelboxError(f"Signer was unsuccessfully added to the dataset. {result}") |
| 538 | + except Exception as e: |
| 539 | + breakpoint() |
| 540 | + dataset.delete() |
| 541 | + raise e |
| 542 | + return dataset |
| 543 | + |
523 | 544 |
|
524 | 545 | def create_project(self, **kwargs): |
525 | 546 | """ Creates a Project object on the server. |
@@ -617,3 +638,5 @@ def create_model(self, name, ontology_id): |
617 | 638 | "ontologyId": ontology_id |
618 | 639 | }) |
619 | 640 | return Model(self, result['createModel']) |
| 641 | + |
| 642 | + |
0 commit comments