|
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. |
@@ -570,55 +561,6 @@ def setup(self, labeling_frontend, labeling_frontend_options) -> None: |
570 | 561 | timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") |
571 | 562 | self.update(setup_complete=timestamp) |
572 | 563 |
|
573 | | - def queue(self, data_row_ids: List[str]): |
574 | | - """Add Data Rows to the Project queue""" |
575 | | - |
576 | | - method = "submitBatchOfDataRows" |
577 | | - return self._post_batch(method, data_row_ids) |
578 | | - |
579 | | - def dequeue(self, data_row_ids: List[str]): |
580 | | - """Remove Data Rows from the Project queue""" |
581 | | - |
582 | | - method = "removeBatchOfDataRows" |
583 | | - return self._post_batch(method, data_row_ids) |
584 | | - |
585 | | - def _post_batch(self, method, data_row_ids: List[str]): |
586 | | - """Post batch methods""" |
587 | | - |
588 | | - if self.queue_mode() != QueueMode.Batch: |
589 | | - raise ValueError("Project must be in batch mode") |
590 | | - |
591 | | - if len(data_row_ids) > MAX_QUEUE_BATCH_SIZE: |
592 | | - raise ValueError( |
593 | | - f"Batch exceeds max size of {MAX_QUEUE_BATCH_SIZE}, consider breaking it into parts" |
594 | | - ) |
595 | | - |
596 | | - query = """mutation %sPyApi($projectId: ID!, $dataRowIds: [ID!]!) { |
597 | | - project(where: {id: $projectId}) { |
598 | | - %s(data: {dataRowIds: $dataRowIds}) { |
599 | | - dataRows { |
600 | | - dataRowId |
601 | | - error |
602 | | - } |
603 | | - } |
604 | | - } |
605 | | - } |
606 | | - """ % (method, method) |
607 | | - |
608 | | - res = self.client.execute(query, { |
609 | | - "projectId": self.uid, |
610 | | - "dataRowIds": data_row_ids |
611 | | - })["project"][method]["dataRows"] |
612 | | - |
613 | | - # TODO: figure out error messaging |
614 | | - if len(data_row_ids) == len(res): |
615 | | - raise ValueError("No dataRows were submitted successfully") |
616 | | - |
617 | | - if len(data_row_ids) > 0: |
618 | | - warnings.warn("Some Data Rows were not submitted successfully") |
619 | | - |
620 | | - return res |
621 | | - |
622 | 564 | def _update_queue_mode(self, mode: QueueMode) -> QueueMode: |
623 | 565 |
|
624 | 566 | if self.queue_mode() == mode: |
@@ -935,7 +877,7 @@ class LabelingParameterOverride(DbObject): |
935 | 877 |
|
936 | 878 | LabelerPerformance = namedtuple( |
937 | 879 | "LabelerPerformance", "user count seconds_per_label, total_time_labeling " |
938 | | - "consensus average_benchmark_agreement last_activity_time") |
| 880 | + "consensus average_benchmark_agreement last_activity_time") |
939 | 881 | LabelerPerformance.__doc__ = ( |
940 | 882 | "Named tuple containing info about a labeler's performance.") |
941 | 883 |
|
|
0 commit comments