From c30b9f150e741939e414b3960662529523227c98 Mon Sep 17 00:00:00 2001 From: shubhusion Date: Mon, 3 Jun 2024 23:30:09 +0530 Subject: [PATCH] Update batch.py --- src/bloqade/task/batch.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/bloqade/task/batch.py b/src/bloqade/task/batch.py index 541fad58d..1f099cedc 100644 --- a/src/bloqade/task/batch.py +++ b/src/bloqade/task/batch.py @@ -4,6 +4,8 @@ `RemoteBatch`, which handle task execution, reporting, and error management. """ +import os +import warnings from decimal import Decimal from numbers import Real from collections import OrderedDict @@ -13,12 +15,12 @@ import datetime import sys from dataclasses import dataclass, field +from typing import Literal import pandas as pd import numpy as np from beartype.typing import Union, Optional, Dict, Any, List from beartype import beartype -from typing import Literal from bloqade.builder.typing import LiteralType from bloqade.serialize import Serializer from bloqade.task.base import Report @@ -32,6 +34,7 @@ from bloqade.submission.ir.task_results import ( QuEraShotStatusCode, QuEraTaskStatusCode, + QuEraTaskResults, ) # from bloqade.submission.base import ValidationError @@ -229,10 +232,12 @@ def _run( Private method to run tasks in the batch. Args: - multiprocessing (bool, optional): If True, tasks are run in parallel using multiple processes. - If False, tasks are run sequentially in a single process. Defaults to False. - num_workers (Optional[int], optional): The maximum number of processes that can be used to - execute the given calls if multiprocessing is True. If None, the number of workers will be the number of processors on the machine. + multiprocessing (bool, optional): + If True, tasks are run in parallel using multiple processes. + If False, tasks are run sequentially in a single process. Defaults to False. + num_workers (Optional[int], optional): The maximum number of processes that can be used + to execute the given calls if multiprocessing is True. + If None, the number of workers will be the number of processors on the machine. **kwargs: Arbitrary keyword arguments passed to the task's run method. Raises: @@ -361,9 +366,6 @@ class RemoteBatch(Filter): ) _resolved_at: Optional[str] = None - - def report(self) -> Report: - class SubmissionException(Exception): pass @@ -517,9 +519,13 @@ def _submit( Args: shuffle_submit_order (bool, optional): If True, tasks are submitted in a random order. - If False, tasks are submitted in the order they were added to the batch. Defaults to True. - ignore_submission_error (bool, optional): If True, submission errors are ignored and the method continues to submit the remaining tasks. - If False, the method stops at the first submission error. Defaults to False. + If False, tasks are submitted in the order they were added to the batch. + Defaults to True. + ignore_submission_error (bool, optional): + If True, submission errors are ignored and the method continues to submit the + remaining tasks. + If False, the method stops at the first submission error. + Defaults to False. **kwargs: Arbitrary keyword arguments. Returns: @@ -811,7 +817,7 @@ def resolve(self): for task_number, task in self.tasks.items(): try: result = task.result() - if result.status == QuEraTaskStatusCode.Complete: + if result.status == QuEraTaskStatusCode.Completed: continue if not result or (