Skip to content

Commit

Permalink
returns bool
Browse files Browse the repository at this point in the history
  • Loading branch information
kliment-slice committed Oct 23, 2024
1 parent 97dafb0 commit fa954db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/ansys/simai/core/data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,17 @@ def cancel_build(self, model: Identifiable[Model]):
"""Cancel an ongoing build given the model.
Args:
model: a model object or model id whose ongoing build to cancel
model: a model object whose ongoing build to cancel.
Returns:
``True`` if ``is_being_trained=False`` in JSON response after successful cancellation.
Example:
.. code-block:: python
simai.models.cancel_build(new_model)
build_cancelled = simai.models.cancel_build(new_model)
"""

model_object = get_object_from_identifiable(model, self._client.models)
response = self._client._api.cancel_build(model_object.project_id)
return (
"Build cancelled"
if not response.get("is_being_trained")
else "Build cancellation unsuccessful, training in progress"
)
return not response.get("is_being_trained")
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,4 +666,4 @@ def test_cancel_existing_build(simai_client, model_factory):
response = simai_client.models.cancel_build(new_model)

assert len(responses.calls) == 1
assert response == "Build cancelled"
assert response is True

0 comments on commit fa954db

Please sign in to comment.