Skip to content

Exclusive access task #1025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 1, 2025
Merged

Exclusive access task #1025

merged 14 commits into from
May 1, 2025

Conversation

yzcj105
Copy link
Contributor

@yzcj105 yzcj105 commented Apr 29, 2025

Add exclusive access

os.environ['ZAPIER_WEBHOOK_URL'] = "XXXX"
os.environ['ZAPIER_WEBHOOK_KEY'] = "XXXXX"
os.environ['VERCEL_API_URL'] = "XXXXX"
from bloqade.analog.task.exclusive import HTTPHandler, ExclusiveRemoteTask
result = prog.quera.custom().run_async(10, ExclusiveRemoteTask)
result.fetch()
result.report().show()

The environment variables should be set before import ExclusiveRemoteTask.

Test

  • simple unit test for HTTPHandler and ExclusiveRemoteTask
  • Integration test with a simple example. Code has been mailed to @weinbe58 and @jon-wurtz .

Waiting time

  • Once job has been submitted, the status would be "Accepted".
  • In about 2-10mins, it will show up in the dashboard, the status would become "Enqueued".
  • It takes some time (a few hours) until job finished. The status would become "Completed".

@yzcj105 yzcj105 requested review from weinbe58 and jon-wurtz April 29, 2025 14:03
@yzcj105 yzcj105 added the enhancement New feature or request label Apr 29, 2025
Copy link
Contributor

github-actions bot commented Apr 29, 2025

PR Preview Action v1.6.1
Preview removed because the pull request was closed.
2025-05-01 15:09 UTC

Copy link
Member

@weinbe58 weinbe58 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constructor of the class needs some work to make it not crash the CI if you have any questions lets just set up a pair coding session to fix the issue.

Comment on lines 118 to 121
@property
@abc.abstractmethod
def parallel_decoder(self) -> ParallelDecoder: ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be deleted, this is needed to get things working with the Report object.



@ExclusiveRemoteTask.set_serializer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

removing a space here.

Comment on lines 180 to 201
class ExclusiveRemoteTask(CustomRemoteTaskABC):
def __init__(
self,
task_ir: QuEraTaskSpecification,
metadata: Dict[str, ParamType],
parallel_decoder: ParallelDecoder | None,
http_handler: HTTPHandlerABC | None = HTTPHandler(),
task_id: str = None,
task_result_ir: QuEraTaskResults = None,
):
self._http_handler = http_handler
self._task_ir = task_ir
self._metadata = metadata
self._parallel_decoder = parallel_decoder
float_sites = list(
map(lambda x: (float(x[0]), float(x[1])), task_ir.lattice.sites)
)
self._geometry = Geometry(
float_sites, task_ir.lattice.filling, parallel_decoder
)
self._task_id = task_id
self._task_result_ir = task_result_ir
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per our discussion 1 on 1, use a dataclass to clean up this implementation, Also you should use default_factories for the default values instead of instances of objects that are mutable.

else:
self._task_result_ir = QuEraTaskResults(
task_status=QuEraTaskStatusCode.Failed)
print(self.task_result_ir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(self.task_result_ir)

removing debug print statements.

@weinbe58
Copy link
Member

Also you should add a test using the Test interface we discussed.

Copy link
Contributor

github-actions bot commented Apr 30, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
8445 7453 88% 0% 🟢

New Files

File Coverage Status
src/bloqade/analog/task/exclusive.py 36% 🟢
TOTAL 36% 🟢

Modified Files

No covered modified files...

updated for commit: 06b090c by action🐍

Copy link

codecov bot commented Apr 30, 2025

Codecov Report

Attention: Patch coverage is 36.11111% with 115 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/bloqade/analog/task/exclusive.py 36.11% 115 Missing ⚠️

📢 Thoughts on this report? Let us know!

@yzcj105
Copy link
Contributor Author

yzcj105 commented Apr 30, 2025

Updates:

  • Use @dataclass for ExclusiveRemoteTask
    ** clean up the init and use __post_init__ instead
    ** use field(default_factory=HTTPHandler) to avoid creating new obj in the default arguments of __init__ function, so that during import, no objects are created.
  • reformatted by black and remove unused imports and duplicated imports.

Test

  • Tested both case for single job and batch job
  • Test load( save(results, "result.json")) contains exact same data as the variable results

@jon-wurtz
Copy link
Contributor

Looks good to me, my test script runs 👍. @weinbe58 merge at your convenience.

@weinbe58 weinbe58 merged commit fb95cb4 into main May 1, 2025
7 of 8 checks passed
@weinbe58 weinbe58 deleted the exclusive-access-task branch May 1, 2025 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants