Skip to content

Commit

Permalink
Take out unnecessary Job.save() (Qiskit#1217)
Browse files Browse the repository at this point in the history
* take out unnecessary Job.save()

Signed-off-by: Akihiko Kuroda <akihikokuroda2020@gmail.com>
  • Loading branch information
akihikokuroda authored and david-alber committed Feb 13, 2024
1 parent 8154cae commit 393b307
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions gateway/api/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,25 +168,13 @@ def save(
Job instance
"""

job = None
try:
job = Job(
program=program,
arguments=arguments,
author=author,
status=status,
config=jobconfig,
)
job.save()
except (Exception) as save_job_exception:
logger.error(
"Exception was caught saving a Job. \n Error trace: %s",
save_job_exception,
)
raise InternalServerErrorException(
"Unexpected error saving a job"
) from save_job_exception

job = Job(
program=program,
arguments=arguments,
author=author,
status=status,
config=jobconfig,
)
env = encrypt_env_vars(build_env_variables(token, job, json.dumps(arguments)))
try:
env["traceparent"] = carrier["traceparent"]
Expand All @@ -198,7 +186,7 @@ def save(
job.save()
except (Exception) as save_job_exception:
logger.error(
"Exception was caught saving the env_vars of the Job[%s]. \n Error trace: %s",
"Exception was caught saving the Job[%s]. \n Error trace: %s",
job.id,
save_job_exception,
)
Expand Down

0 comments on commit 393b307

Please sign in to comment.