|
2 | 2 | import json
|
3 | 3 | import logging
|
4 | 4 | import time
|
5 |
| -import warnings |
6 | 5 | from collections import namedtuple
|
7 | 6 | from datetime import datetime, timezone
|
8 | 7 | from pathlib import Path
|
|
37 | 36 |
|
38 | 37 | logger = logging.getLogger(__name__)
|
39 | 38 |
|
40 |
| -MAX_QUEUE_BATCH_SIZE = 1000 |
41 |
| - |
42 | 39 |
|
43 | 40 | class QueueMode(enum.Enum):
|
44 | 41 | Batch = "Batch"
|
45 | 42 | Dataset = "Dataset"
|
46 | 43 |
|
47 | 44 |
|
48 |
| -class QueueErrors(enum.Enum): |
49 |
| - InvalidDataRowType = 'InvalidDataRowType' |
50 |
| - AlreadyInProject = 'AlreadyInProject' |
51 |
| - HasAttachedLabel = 'HasAttachedLabel' |
52 |
| - |
53 |
| - |
54 | 45 | class Project(DbObject, Updateable, Deletable):
|
55 | 46 | """ A Project is a container that includes a labeling frontend, an ontology,
|
56 | 47 | datasets and labels.
|
@@ -578,55 +569,6 @@ def setup(self, labeling_frontend, labeling_frontend_options) -> None:
|
578 | 569 | timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
579 | 570 | self.update(setup_complete=timestamp)
|
580 | 571 |
|
581 |
| - def queue(self, data_row_ids: List[str]): |
582 |
| - """Add Data Rows to the Project queue""" |
583 |
| - |
584 |
| - method = "submitBatchOfDataRows" |
585 |
| - return self._post_batch(method, data_row_ids) |
586 |
| - |
587 |
| - def dequeue(self, data_row_ids: List[str]): |
588 |
| - """Remove Data Rows from the Project queue""" |
589 |
| - |
590 |
| - method = "removeBatchOfDataRows" |
591 |
| - return self._post_batch(method, data_row_ids) |
592 |
| - |
593 |
| - def _post_batch(self, method, data_row_ids: List[str]): |
594 |
| - """Post batch methods""" |
595 |
| - |
596 |
| - if self.queue_mode() != QueueMode.Batch: |
597 |
| - raise ValueError("Project must be in batch mode") |
598 |
| - |
599 |
| - if len(data_row_ids) > MAX_QUEUE_BATCH_SIZE: |
600 |
| - raise ValueError( |
601 |
| - f"Batch exceeds max size of {MAX_QUEUE_BATCH_SIZE}, consider breaking it into parts" |
602 |
| - ) |
603 |
| - |
604 |
| - query = """mutation %sPyApi($projectId: ID!, $dataRowIds: [ID!]!) { |
605 |
| - project(where: {id: $projectId}) { |
606 |
| - %s(data: {dataRowIds: $dataRowIds}) { |
607 |
| - dataRows { |
608 |
| - dataRowId |
609 |
| - error |
610 |
| - } |
611 |
| - } |
612 |
| - } |
613 |
| - } |
614 |
| - """ % (method, method) |
615 |
| - |
616 |
| - res = self.client.execute(query, { |
617 |
| - "projectId": self.uid, |
618 |
| - "dataRowIds": data_row_ids |
619 |
| - })["project"][method]["dataRows"] |
620 |
| - |
621 |
| - # TODO: figure out error messaging |
622 |
| - if len(data_row_ids) == len(res): |
623 |
| - raise ValueError("No dataRows were submitted successfully") |
624 |
| - |
625 |
| - if len(data_row_ids) > 0: |
626 |
| - warnings.warn("Some Data Rows were not submitted successfully") |
627 |
| - |
628 |
| - return res |
629 |
| - |
630 | 572 | def _update_queue_mode(self, mode: QueueMode) -> QueueMode:
|
631 | 573 |
|
632 | 574 | if self.queue_mode() == mode:
|
|
0 commit comments