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

Refactor client and fix tests #1513

Merged
merged 26 commits into from
Oct 22, 2024
Merged

Refactor client and fix tests #1513

merged 26 commits into from
Oct 22, 2024

Conversation

korgan00
Copy link
Collaborator

@korgan00 korgan00 commented Oct 10, 2024

Summary

Objectives:

  • Remove BaseJobClient and migrate it to BaseClient
  • Remove RayJobClient and migrate it to RayClient
  • Remove LocalJobClient and migrate it to LocalClient
  • Remove GatewayJobClient and migrate it to ServerlessClient
  • From Job rename the variable to use the client instead of job_client.
  • From QiskitFunctions rename the variable to use the client instead of job_client.

Details and comments

Additionally:

  • Moved the BaseClient implementations (Ray, Local and Serverless) to their own files.
  • BaseClient now is officially an abstract class (ABS and @abstractmethod).
  • Fixed and barely improved tests.
  • Removed ComputedResource because it wasn't used correctly.

time.sleep(1)
while time.time() < must_finish and not client:
try:
client = JobSubmissionClient(connection_url)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Trying to know if Ray server started. I didn't found a better way but I'm sure it is. For the moment, this works.

@@ -40,9 +46,10 @@ def test_save_result(self):
)
self.assertTrue(result)

@patch("requests.get", Mock(return_value=ResponseMock()))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

prevent token validation to fail.

@korgan00
Copy link
Collaborator Author

I have to review the documentation.

@Tansito Tansito marked this pull request as draft October 10, 2024 13:36
@Tansito
Copy link
Member

Tansito commented Oct 10, 2024

I converted it to draft @korgan00 just to let the team knows that we want a review on this but we need to fix tests yet

@Tansito Tansito requested review from a team and removed request for paaragon, IceKhan13, Tansito, akihikokuroda and psschwei October 10, 2024 13:42
Copy link
Member

@Tansito Tansito left a comment

Choose a reason for hiding this comment

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

I left several comments but really good job with this refactor @korgan00 , congrats. I'm very happy with the result.

client/tests/core/test_pattern.py Outdated Show resolved Hide resolved
client/qiskit_serverless/core/client.py Outdated Show resolved Hide resolved
client/qiskit_serverless/core/client.py Outdated Show resolved Hide resolved
client/qiskit_serverless/core/client.py Show resolved Hide resolved
client/qiskit_serverless/core/clients/LocalClient.py Outdated Show resolved Hide resolved
client/qiskit_serverless/core/clients/LocalClient.py Outdated Show resolved Hide resolved
client/qiskit_serverless/core/clients/RayClient.py Outdated Show resolved Hide resolved
client/qiskit_serverless/core/clients/ServerlessClient.py Outdated Show resolved Hide resolved
@Tansito
Copy link
Member

Tansito commented Oct 10, 2024

Also @korgan00 , most of the problems in the tests are related with the changes in the API. I can help you tomorrow looking at them but with some of the changes that I'm requesting you we should be able to solve some of them.

@korgan00
Copy link
Collaborator Author

korgan00 commented Oct 11, 2024

Per offline conversations we also talked about changing get_program with get_function to make it more coherent with QiskitFunctions.

@korgan00
Copy link
Collaborator Author

Since file management is a Serveless feature that is not available in Ray or Local, should we remove it from the Base? This way we will reduce the NotImplementedError exceptions.

@Tansito Tansito marked this pull request as ready for review October 14, 2024 16:07
@Tansito
Copy link
Member

Tansito commented Oct 14, 2024

Moving PR to review 🎉

@Tansito Tansito requested review from IceKhan13 and Tansito October 14, 2024 16:08
@@ -29,6 +27,7 @@ jobs:
shell: bash
run: |
cd tests/basic
rm ./06_function.py
Copy link
Member

Choose a reason for hiding this comment

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

These changes were necessary. Basically currently 06_function doesn't work in this test with the current docker-compose configuration and it was generating problems in the execution of the test.

@Tansito Tansito self-requested a review October 14, 2024 16:13
Copy link
Member

@Tansito Tansito left a comment

Choose a reason for hiding this comment

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

I opened a couple of closed conversations about breaking changes in get_job_by_id and functions.get methods. We can take a look tomorrow @korgan00 and clarify them. Maybe I missed them somewhere.

@korgan00
Copy link
Collaborator Author

korgan00 commented Oct 15, 2024

Since the client and the job files has huge changes, they are not shown by default in the changes preview.You have to load them intentionally. I put the deprecation redirections directly in the base file because it is better to maintain than spread and repeat the code in every client implementation.

@Tansito Tansito self-requested a review October 15, 2024 13:55
Copy link
Member

@Tansito Tansito left a comment

Choose a reason for hiding this comment

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

Solved my questions and concerns with @korgan00 on a call. From my part everything looks good but @IceKhan13 if you can double check I would appreciate it 👍

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.

Waaaay cleaner now!

Thank you @korgan00!

client/qiskit_serverless/core/files.py Show resolved Hide resolved
@korgan00 korgan00 merged commit a297ef1 into main Oct 22, 2024
10 checks passed
@korgan00 korgan00 deleted the client-refactor branch October 23, 2024 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants