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/SK-1225 | Use api/v1 in APIClient start_session #758

Merged
merged 6 commits into from
Nov 26, 2024

Conversation

benjaminastrand
Copy link
Contributor

@benjaminastrand benjaminastrand commented Nov 22, 2024

The function start_session now makes two POST requests in sequence instead of one:

  1. host_url/api/v1/sessions - to create a session
  2. host_url/api/v1/sessions/start - to start the session

The 2nd request is made only if the 1st request returns status code 201, indicating that the session has been created, and the response from the 2nd request is returned. Otherwise, the response from the 1st request is returned.

Also, the method set_active_model in APIClient now sets the active helper based on the file extension of the seed model file used (".npz" -> numpyhelper, ".bin" -> binaryhelper)

@benjaminastrand benjaminastrand changed the title Use api/v1 in APIClient start_session Refactor/SK-1225 | Use api/v1 in APIClient start_session Nov 22, 2024
@github-actions github-actions bot added the minor label Nov 22, 2024
@benjaminastrand benjaminastrand marked this pull request as draft November 22, 2024 14:20
@benjaminastrand benjaminastrand marked this pull request as ready for review November 22, 2024 14:25
@benjaminastrand benjaminastrand marked this pull request as draft November 22, 2024 14:27
Copy link
Contributor

@niklastheman niklastheman left a comment

Choose a reason for hiding this comment

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

Nice work! I left a comment.

},
verify=self.verify,
headers=self.headers,
)

if response.status_code == 201:
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool! An improvement could be to indicate to the user what has gone wrong if status code != 201.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The method will return the result from the first request, so the user already has access to this information.

@benjaminastrand benjaminastrand marked this pull request as ready for review November 22, 2024 15:03
@benjaminastrand benjaminastrand marked this pull request as draft November 25, 2024 08:06
@benjaminastrand
Copy link
Contributor Author

Setting the active helper in set_active_model so that the user doesn't need to upload a package to set the helper type via APIClient.

@benjaminastrand benjaminastrand marked this pull request as ready for review November 25, 2024 11:09
@benjaminastrand benjaminastrand merged commit 9d3431d into master Nov 26, 2024
17 checks passed
@benjaminastrand benjaminastrand deleted the refactor/SK-1225 branch November 26, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants