Skip to content
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

Translate all job statuses to Qiskit terminology in client #1062

Merged
merged 19 commits into from
Nov 6, 2023

Conversation

caleb-johnson
Copy link
Collaborator

@caleb-johnson caleb-johnson commented Oct 30, 2023

Fixes #1039

Summary

In this PR, we translate job statuses from all job clients to Qiskit terminology. Rather than changing the DB structure (currently uses ray status names), we will just do a translation in the serverless client when the user requests the status.

Serverless --> Qiskit nomenclature changes

Pending --> Initializing
Stopped --> Canceled
Succeeded --> Done
Failed --> Error

@caleb-johnson caleb-johnson marked this pull request as ready for review October 30, 2023 17:21
Copy link
Member

@IceKhan13 IceKhan13 left a comment

Choose a reason for hiding this comment

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

Also, when changing records in existing db you need to take care of entries in DB that are already there and convert them too.


Other hotfix option to close this issue would be just to do mapping in client, so you will not need to change anything on a backend and just show in client mapped statuses. Something like

def gateway_to_runtime_statuses(gateway_status):
     mapping = {
         "SUCCEEDED": "DONE"
     }
     return mapping.get(gateway_status, f"APIStatus[{gateway_status}]")

gateway/api/migrations/0001_initial.py Outdated Show resolved Hide resolved
@IceKhan13
Copy link
Member

Basically what migrations are doing:

  • they are checking in which state db is (which migration version is applied to DB recenty)
  • if there are upapplied migrations, they are applied
  • if any of previous migrations changed, migration will fail

@IceKhan13 IceKhan13 marked this pull request as draft October 31, 2023 13:25
@caleb-johnson caleb-johnson changed the title Change job status verbiage Translate all job status indicators to Qiskit terminology in client Nov 1, 2023
@caleb-johnson caleb-johnson changed the title Translate all job status indicators to Qiskit terminology in client Translate all job statuses to Qiskit terminology in client Nov 1, 2023
@@ -127,7 +127,7 @@ def __init__(self, client: JobSubmissionClient):
self._job_client = client

def status(self, job_id: str):
return self._job_client.get_job_status(job_id)
return self._job_client.get_job_status(job_id).value

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since status is an unimplemented BaseJobClient method, I think both the ray and gateway job clients should return a string indicating the status. I updated this in this PR because it affects how I do the status translation in the user-facing job client

Copy link
Member

Choose a reason for hiding this comment

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

so, you basically do not want to return status class? and return status string?
I have no objections, just to confirm :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I figured since the gateway job client returns a string, we may as well return a string from the ray job client as well, since they both derive from the same base class. Not a big deal, but I thought it was a clean simplification.

@@ -473,7 +473,7 @@ def __init__(

def status(self):
"""Returns status of the job."""
return self._job_client.status(self.job_id)
return _map_status_to_serverless(self._job_client.status(self.job_id))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We will do the translation from any supported job client status to Qiskit terminology here in the user-facing Job client. This is the only place we'll do the translation. Everything underneath this will be Ray terminology.

@@ -496,7 +496,7 @@ def result(self, wait=True, cadence=5, verbose=False):
if wait:
if verbose:
logging.info("Waiting for job result.")
while not self._in_terminal_state():
while not self.in_terminal_state():
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't have a JobStatus object like ray that we can query like Ray's JobStatus.is_terminal, so we will make this Job.in_terminal_state method public, so clients have a way to query whether the job has finished.

@caleb-johnson
Copy link
Collaborator Author

@IceKhan13 , I've fixed this up as you suggested. I don't currently have an idea about this strange sphinx error, but Im looking into it. Doesn't seem to be related to the work in this PR, so it's a little confusing

@caleb-johnson
Copy link
Collaborator Author

caleb-johnson commented Nov 1, 2023

@IceKhan13 , I've fixed this up as you suggested. I don't currently have an idea about this strange sphinx error, but Im looking into it. Doesn't seem to be related to the work in this PR, so it's a little confusing

Hmm, I fixed it locally by removing Program from the docstring in the init file, but the error is still happening in CI. Can't reproduce this locally after removing Program from the docstring.

try:
return status_map[status]
except KeyError as exc:
raise KeyError(f"Cannot interpret unknown job status: {status}") from exc
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe we shouldn't error, maybe we should just print the status like you suggested? Not really sure

Copy link
Member

@IceKhan13 IceKhan13 Nov 2, 2023

Choose a reason for hiding this comment

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

I think printing is more user friendly :)

@IceKhan13
Copy link
Member

Hmm, I fixed it locally by removing Program from the docstring in the init file, but the error is still happening in CI. Can't reproduce this locally after removing Program from the docstring.

merge main and you will be good :)

@IceKhan13
Copy link
Member

PR looks good! simple and clean like all great things 😃

@caleb-johnson
Copy link
Collaborator Author

Also, when changing records in existing db you need to take care of entries in DB that are already there and convert them too.

Other hotfix option to close this issue would be just to do mapping in client, so you will not need to change anything on a backend and just show in client mapped statuses. Something like

def gateway_to_runtime_statuses(gateway_status):
     mapping = {
         "SUCCEEDED": "DONE"
     }
     return mapping.get(gateway_status, f"APIStatus[{gateway_status}]")

Any particular reason you included the APIStatus[] in the print statement? As of now, status just prints the status name in all caps.

Copy link
Member

@IceKhan13 IceKhan13 left a comment

Choose a reason for hiding this comment

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

LGTM

@IceKhan13 IceKhan13 added the release candidate PR which is a candidate for next release label Nov 6, 2023
@caleb-johnson caleb-johnson merged commit 7a62247 into Qiskit:main Nov 6, 2023
7 checks passed
@caleb-johnson caleb-johnson deleted the job-status branch November 6, 2023 18:47
caleb-johnson added a commit to caleb-johnson/quantum-serverless that referenced this pull request Nov 6, 2023
@caleb-johnson caleb-johnson restored the job-status branch November 6, 2023 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release candidate PR which is a candidate for next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Job completed status should match that of Qiskit
2 participants