Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.9.1]

### Added

* Support for Business Blueprint API. [#118]
* This feature is **not supported** in DAR service yet, it is added for internal testing purposes.
* `read_business_blueprint_template_collection` method to list business blueprint templates collection.
* `read_business_blueprint_template_by_id` method to fetch information of a specific business blueprint template for the given business_blueprint_id

[#118]: https://github.com/SAP/data-attribute-recommendation-python-sdk/pull/118

## [0.9.0]

Expand Down Expand Up @@ -215,7 +225,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* First public release

[Unreleased]: https://github.com/SAP/data-attribute-recommendation-python-sdk/compare/rel/0.9.0...HEAD
[Unreleased]: https://github.com/SAP/data-attribute-recommendation-python-sdk/compare/rel/0.9.1...HEAD
[0.9.1]: https://github.com/SAP/data-attribute-recommendation-python-sdk/compare/rel/0.9.0...rel/0.9.1
[0.9.0]: https://github.com/SAP/data-attribute-recommendation-python-sdk/compare/rel/0.8.2...rel/0.9.0
[0.8.2]: https://github.com/SAP/data-attribute-recommendation-python-sdk/compare/rel/0.8.1...rel/0.8.2
[0.8.1]: https://github.com/SAP/data-attribute-recommendation-python-sdk/compare/rel/0.8.0...rel/0.8.1
Expand Down
24 changes: 24 additions & 0 deletions sap/aibus/dar/client/model_manager_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,3 +617,27 @@ def is_deployment_failed(deployment_resource: dict):
DeploymentStatus.STOPPED.value,
DeploymentStatus.FAILED.value,
]

def read_business_blueprint_template_collection(self) -> dict:
"""
Reads the collection of BusinessBlueprint Template.
:return: BusinessBlueprint collection as dict
"""
response = self.session.get_from_endpoint(
ModelManagerPaths.ENDPOINT_BUSINESS_BLUEPRINT_TEMPLATE_COLLECTION
)
return response.json()

def read_business_blueprint_template_by_id(
self, business_blueprint_id: str
) -> dict:
"""
Reads the BusinessBlueprintTemplate with the given *business_blueprint_id*.
:param business_blueprint_id: ID of the BusinessBlueprint to be retrieved
:return: a single BusinessBlueprintTemplate as dict
"""
endpoint = ModelManagerPaths.format_business_blueprint_endpoint_by_id(
business_blueprint_id
)
response = self.session.get_from_endpoint(endpoint)
return response.json()
27 changes: 27 additions & 0 deletions sap/aibus/dar/client/model_manager_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class ModelManagerPaths:
#: Path for the Deployment collection
ENDPOINT_DEPLOYMENT_COLLECTION = "/model-manager/api/v3/deployments"

#: Path for the BusinessBlueprint collection
ENDPOINT_BUSINESS_BLUEPRINT_TEMPLATE_COLLECTION = (
"/model-manager/api/v3/businessBlueprints"
)

@classmethod
def format_model_templates_endpoint_by_id(cls, model_template_id: str) -> str:
# How can I fix the formatting of the doctest below without introducing a lot
Expand Down Expand Up @@ -128,3 +133,25 @@ def format_deployment_endpoint_by_id(cls, deployment_id: str):
:return: endpoint, to be used as URL component
"""
return cls.ENDPOINT_DEPLOYMENT_COLLECTION + "/" + deployment_id

@classmethod
def format_business_blueprint_endpoint_by_id(
cls, business_blueprint_id: str
) -> str:
"""
Returns the path of a BusinessBlueprintTemplate with given identifier.

.. doctest::

>>> ModelManagerPaths.format_business_blueprint_endpoint_by_id(\
'4788254b-0bad-4757-a67f-92d5b55f322d')
'/model-manager/api/v3/businessBlueprints/4788254b-0bad-4757-a67f-92d5b55f322d'

:param business_blueprint_id: identifier of BusinessBlueprintTemplate
:return: endpoint, to be used as URL component
"""
return (
cls.ENDPOINT_BUSINESS_BLUEPRINT_TEMPLATE_COLLECTION
+ "/"
+ business_blueprint_id
)
24 changes: 24 additions & 0 deletions tests/sap/aibus/dar/client/test_model_manager_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,3 +954,27 @@ def test_deployment_exists_and_is_unhealthy(
assert mock_create.call_args_list == [call(model_name)]

assert response == mock_create.return_value


class TestModelManagerClientBusinessBlueprintTemplate:
def test_read_model_template_collection(self, model_manager_client):
response = model_manager_client.read_business_blueprint_template_collection()
assert_get_response_is_json(model_manager_client, response)
expected_endpoint = "/model-manager/api/v3/businessBlueprints"
assert_get_from_endpoint_called_with_endpoint(
model_manager_client, expected_endpoint
)

def test_read_model_template_by_id(self, model_manager_client):
business_blueprint_id = "4788254b-0bad-4757-a67f-92d5b55f322d"

response = model_manager_client.read_business_blueprint_template_by_id(
"4788254b-0bad-4757-a67f-92d5b55f322d"
)
assert_get_response_is_json(model_manager_client, response)
expected_endpoint = "/model-manager/api/v3/businessBlueprints/{}".format(
business_blueprint_id
)
assert_get_from_endpoint_called_with_endpoint(
model_manager_client, expected_endpoint
)
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.0
0.9.1