From 63d26d46da195c66e60b780c9202c7504399441f Mon Sep 17 00:00:00 2001
From: Phillip Weinberg <weinbe58@gmail.com>
Date: Sun, 17 Sep 2023 13:35:41 -0400
Subject: [PATCH] rename `submit` to `run_async` (#592)

---
 README.md                        |  4 ++--
 src/bloqade/ir/routine/braket.py | 10 +++++-----
 src/bloqade/ir/routine/quera.py  |  6 +++---
 tests/test_batch2.py             |  2 +-
 tests/test_braket_emulator.py    |  6 +++---
 tests/test_quera_internal_api.py |  2 +-
 tests/test_report.py             |  2 +-
 tests/test_task.py               | 10 +++++-----
 8 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/README.md b/README.md
index 8a2ed104e..ce923aa21 100644
--- a/README.md
+++ b/README.md
@@ -191,7 +191,7 @@ calculation = (
     .braket.aquila()
 )
 ```
-For tasks executed through a remote API, there are three options to run your job. The first is an asynchronous call via `submit`, which will return a `RemoteBatch` object. This object has various methods to `fetch` and or `pull` results from the remote API, along with some other tools that can query the status of the task(s) in this batch. `run` is another method that blocks the script waiting for all the tasks to finish, susequently returning the `RemoteBatch`. The final option is to use the `__call__` method of the `calculation` object for hybrid workflows. The call object is effectively the same as calling `run`. However, specifying the `flatten` option will allow you to call `__call__` with arguments corresponding to the list of strings provided by `flatten`.
+For tasks executed through a remote API, there are three options to run your job. The first is an asynchronous call via `run_async`, which will return a `RemoteBatch` object. This is a non-blocking call and `RemoteBatch` acts like a future object. It has various methods to `fetch` and or `pull` results from the remote API, along with some other tools that can query the status of the task(s) in this batch. `run` is another method that blocks the script waiting for all the tasks to finish, susequently returning the `RemoteBatch`. The final option is to use the `__call__` method of the `calculation` object for hybrid workflows. The call object is effectively the same as calling `run`. However, specifying the `flatten` option will allow you to call `__call__` with arguments corresponding to the list of strings provided by `flatten`.
 
 The `RemoteBatch` object can be saved in JSON format using the `save_batch` and reloaded back into Python using the `load_batch` functions. This capability is useful for the asynchronous case, where you can save the batch and load it back later to retrieve the results.
 
@@ -224,7 +224,7 @@ program = (
 
 emulator_batch = program.braket.local_emulator().run(1000)
 
-hardware_batch = program.parallelize(20).braket.aquila().submit(1000)
+hardware_batch = program.parallelize(20).braket.aquila().run_async(1000)
 
 save_batch("emulator_results.json", emulator_batch)
 save_batch("hardware_results.json", hardware_batch)
diff --git a/src/bloqade/ir/routine/braket.py b/src/bloqade/ir/routine/braket.py
index 3d66263c3..8cb7ef859 100644
--- a/src/bloqade/ir/routine/braket.py
+++ b/src/bloqade/ir/routine/braket.py
@@ -81,7 +81,7 @@ def _compile(
         return batch
 
     @beartype
-    def submit(
+    def run_async(
         self,
         shots: int,
         args: Tuple[LiteralType, ...] = (),
@@ -91,7 +91,7 @@ def submit(
     ) -> RemoteBatch:
         """
         Compile to a RemoteBatch, which contain
-        Braket backend specific tasks, and submit to Braket.
+        Braket backend specific tasks, and run_async to Braket.
 
         Note:
             This is async.
@@ -122,7 +122,7 @@ def run(
     ) -> RemoteBatch:
         """
         Compile to a RemoteBatch, which contain
-        Braket backend specific tasks, submit to Braket,
+        Braket backend specific tasks, run_async to Braket,
         and wait until the results are coming back.
 
         Note:
@@ -140,7 +140,7 @@ def run(
 
         """
 
-        batch = self.submit(shots, args, name, shuffle, **kwargs)
+        batch = self.run_async(shots, args, name, shuffle, **kwargs)
         batch.pull()
         return batch
 
@@ -155,7 +155,7 @@ def __call__(
     ):
         """
         Compile to a RemoteBatch, which contain
-        Braket backend specific tasks, submit to Braket,
+        Braket backend specific tasks, run_async to Braket,
         and wait until the results are coming back.
 
         Note:
diff --git a/src/bloqade/ir/routine/quera.py b/src/bloqade/ir/routine/quera.py
index b69bb27b4..d2b59f939 100644
--- a/src/bloqade/ir/routine/quera.py
+++ b/src/bloqade/ir/routine/quera.py
@@ -91,7 +91,7 @@ def _compile(
         return batch
 
     @beartype
-    def submit(
+    def run_async(
         self,
         shots: int,
         args: Tuple[LiteralType, ...] = (),
@@ -102,7 +102,7 @@ def submit(
         """
         Compile to a RemoteBatch, which contain
             QuEra backend specific tasks,
-            and submit through QuEra service.
+            and run_async through QuEra service.
 
         Args:
             shots (int): number of shots
@@ -127,7 +127,7 @@ def run(
         shuffle: bool = False,
         **kwargs,
     ) -> RemoteBatch:
-        batch = self.submit(shots, args, name, shuffle, **kwargs)
+        batch = self.run_async(shots, args, name, shuffle, **kwargs)
         batch.pull()
         return batch
 
diff --git a/tests/test_batch2.py b/tests/test_batch2.py
index 68c7df603..334e70ccb 100644
--- a/tests/test_batch2.py
+++ b/tests/test_batch2.py
@@ -24,7 +24,7 @@
 task = prog.quera.mock()
 
 
-# future = task.submit(shots=100)  ## non0-blk
+# future = task.run_async(shots=100)  ## non0-blk
 
 # future.fetch()
 
diff --git a/tests/test_braket_emulator.py b/tests/test_braket_emulator.py
index 80fb40dd1..b7c26ad93 100644
--- a/tests/test_braket_emulator.py
+++ b/tests/test_braket_emulator.py
@@ -70,10 +70,10 @@ def test_error():
         .braket_local_simulator(1000)
     )
 
-    rydberg_densities = simulator_job.submit().report().rydberg_densities()
+    rydberg_densities = simulator_job.run_async().report().rydberg_densities()
 
     rydberg_densities = (
-        simulator_job.submit(multiprocessing=True).report().rydberg_densities()
+        simulator_job.run_async(multiprocessing=True).report().rydberg_densities()
     )
 
     # durations for rabi and detuning
@@ -92,5 +92,5 @@ def test_error():
 
     mis_udg_job = mis_udg_program.batch_assign(final_detuning=np.linspace(0, 80, 81))
 
-    hw_job = mis_udg_job.braket_local_simulator(100).submit()
+    hw_job = mis_udg_job.braket_local_simulator(100).run_async()
 """
diff --git a/tests/test_quera_internal_api.py b/tests/test_quera_internal_api.py
index bf9290791..e178a11ec 100644
--- a/tests/test_quera_internal_api.py
+++ b/tests/test_quera_internal_api.py
@@ -34,7 +34,7 @@ def test_quera_submit():
         .assign(run_time=2.0)
         .parallelize(20)
         .quera.device(config_file=config_file)
-        .submit(shots=10)
+        .run_async(shots=10)
     )
 
     bloqade.save_batch("quera_submit.json", batch)
diff --git a/tests/test_report.py b/tests/test_report.py
index f42fff3f5..a7bd5d731 100644
--- a/tests/test_report.py
+++ b/tests/test_report.py
@@ -30,7 +30,7 @@
 
 
 with tempfile.NamedTemporaryFile() as f:
-    future = prog.quera.mock(state_file=f.name).submit(shots=100)
+    future = prog.quera.mock(state_file=f.name).run_async(shots=100)
     future.pull()
     future2 = future.remove_tasks("Completed")
     future2
diff --git a/tests/test_task.py b/tests/test_task.py
index b5d301ad7..903e01b65 100644
--- a/tests/test_task.py
+++ b/tests/test_task.py
@@ -46,9 +46,9 @@
 
 
 # print(lattice.Square(3).apply(seq).__lattice__)
-# print(lattice.Square(3).apply(seq).braket(nshots=1000).submit().report().dataframe)
+# print(lattice.Square(3).apply(seq).braket(nshots=1000).run_async().report().dataframe)
 # print("bitstring")
-# print(lattice.Square(3).apply(seq).braket(nshots=1000).submit().report().bitstring)
+# print(lattice.Square(3).apply(seq).braket(nshots=1000).run_async().report().bitstring)
 
 # # pipe interface
 # report = (
@@ -61,7 +61,7 @@
 #     .apply(Linear(start=1.0, stop="x", duration=3.0))
 #     .assign(x=10)
 #     .braket(nshots=1000)
-#     .submit()
+#     .run_async()
 #     .report()
 # )
 
@@ -73,7 +73,7 @@
 #     Linear(start=1.0, stop="x", duration=3.0)
 # ).location(3).location(4).apply(Linear(start=1.0, stop="x", duration=3.0)).braket(
 #     nshots=1000
-# ).submit()
+# ).run_async()
 
 # # start.rydberg.detuning.location(2).location(3)
 
@@ -88,7 +88,7 @@
 #     .apply(Linear(start=1.0, stop="x", duration=3.0))
 #     .assign(x=1.0)
 #     .multiplex(10.0).braket(nshots=1000)
-#     .submit()
+#     .run_async()
 #     .report()
 #     .dataframe.groupby(by=["x"])
 #     .count()