SAP AI API Client SDK
Project description
AI API Client SDK
Client SDK for AI API. This repo creates the ai_api_client_sdk library. Everything in ai_api_client_sdk folder will be packaged in the library.
The main client class is the AIAPIV2Client. Each instance of AIAPIV2Client has resource clients as properties. The resource client implementations can be found in folder resource_clients. The resources, response types etc. are represented by model classes. These can be found in folder models.
Usage
The user can use the library by creating an instance of AIAPIV2Client class. There are some required and optional parameters for the constructor of AIAPIV2Client class:
- base_url (string) (required): The base URL of AI API. (i.e. https://api.ai.nonexistingcluster.com/v2/lm)
- token_creator (optional) (Callable): This should be a function which returns a token for authorization. Either this function or auth_url, client_id and client_secret should be provided.
- auth_url: URL for creating the authorization token (i.e. https://blabla.authentication.sap.hana.ondemand.com/oauth/token)
- client_id (optional): clientid for xsuaa authentication
- client_secret(optional): clientsecret for xsuaa authentication
- resource_group (string) (optional): if provided, this will be used as default resource group id for requests to the AI API. The user can still provide resource_group with every request to the AI API, and that will override this one.
The AIAPIV2Client will have a property per resource (each one is an instance of a resource_client):
- artifact (an instance of ArtifactClient)
- configuration (an instance of ConfigurationClient)
- deployment (an instance of DeploymentClient)
- executable (an instance of ExecutableClient)
- execution (an instance of ExecutionClient)
- healthz (an instance of HealthzClient)
- metrics (an instance of MetricsClient)
- scenario (an instance of ScenarioClient)
Each resource client has these functions (if supported for that resource) to send requests to the AI API:
- create(*args, **kwargs): creates a resource
- delete(*args, **kwargs): deletes a resource
- get(*args, **kwargs): gets a single resource
- modify(*args, **kwargs): patches a resource
- query(*args, **kwargs): queries multiple resources
Example:
from ai_api_client_sdk.ai_api_v2_client import AIAPIV2Client
ai_api_v2_client = AIAPIV2Client(
base_url="<BASE_URL>",
auth_url="<AUTH_URL>",
client_id="<CLIENT_ID>",
client_secret="<CLIENT_SECRET>",
resource_group="<RESOURCE_GROUP_ID>"
)
scenario = ai_api_v2_client.scenario.get(scenario_id="<SCENARIO_ID>")
Tests
The unit tests are simply python unit tests. They can be run via nosetests or directly from IDE.
The integration_tests are also python tests. They run against intwdf cluster. But they need resource group provisioned/deprovisioned before/after running them. If they are triggered via nosetsts the setUpModule() and tearDownModule() functions in corresponding __init__.py are properly discovered and called. However when running the integration tests from IDE, those are functions cannot be discovered. Therefore when running from local via IDE, the provisioning/deprovisioning should be done somewhere else. You can do so, by simple uncommenting the corresponding lines in setUpClass() and tearDownClass() functions in AIAPIV2ClientE2ETestBase class.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for ai_api_client_sdk-1.13.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3f36cf5318b78d9576dfb6c4f286fd17cd01dcbfd7b4fdcecb678ffb89a8bb3 |
|
MD5 | a449c2e984c35e26db47a38141d5e099 |
|
BLAKE2b-256 | 40f2db116b051a2b3eb06d19adf86cdfc84251bf6b507fdaade88df7b26335eb |