Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions perceval_interop/myqlm/qpu_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import time
import traceback

from qat.comm.exceptions.ttypes import QPUException, ErrorType
from qat.core import HardwareSpecs, Job as MyQLMJob, Result as MyQLMResult
Expand Down Expand Up @@ -193,16 +194,21 @@ def _submit_job(self, job: MyQLMJob) -> MyQLMResult:
time.sleep(self._SLEEP_TIME)

pcvl_results = self._job.get_results()
get_logger().debug("Results obtained from the job")

except KeyboardInterrupt:
self._job.cancel()
raise RuntimeError("Job has been canceled.")
except:
except Exception as e:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Il y a confusion des genres entre exception & code d'erreur.
L'exception sert à transmettre ce genre d'info (job failed), l'exception est peut-être plus importante que l'échec du job, etc ...

if self._job.status.failed:
get_logger().warn(f'The job failed: {self._job.status.stop_message}', channel.user)
pcvl_results = {'error': self._job.status.stop_message}
else:
raise
try:
self._job.cancel()
except Exception as cancel_error:
raise cancel_error from e
raise e

if job_context is not None:
pcvl_results["job_context"] = job_context
Expand Down Expand Up @@ -230,7 +236,12 @@ def submit_job(self, job: MyQLMJob) -> MyQLMResult:
"""

try:
return self._submit_job(job)
get_logger().info("Got a new job", channel.user)
res = self._submit_job(job)
get_logger().info("Job finished successfully", channel.user)
return res

except Exception as e:
get_logger().error(f"The job failed: {type(e).__name__}: {e}", channel.user)
get_logger().error(traceback.format_exc(), channel.user)
raise QPUException(code=ErrorType.ABORT, modulename="QuandelaQPUHandler", message=str(e)) # Error ABORT (code 1) raised when the execution is stopped
Loading