API Python endpoint : can we call another endpoint part of another API service ?

rona
Level 3
API Python endpoint : can we call another endpoint part of another API service ?

My question is related to the use of the API python endpoint in the API Designer.

Scenario : we have one API service 'service_A' in a DSS Project A and one API service 'service_B' in a DSS project B.

service_A includes a python endpoint 'endpoint_A'.

service_B includes a python endpoint 'endpoint_B'.

Please, could you confirm if endpoint_A can call the endpoint_B ? if yes, how to implement this call in endpoint_A ?

 

Annie

0 Kudos
4 Replies
AdrienL
Dataiker

Hi,

Yes it can, see Calling another endpoint. The example uses predict_record (assumes a prediction endpoint), but you should be able to instead call run_function for a python function.

0 Kudos
rona
Level 3
Author

Thanks for this information.

I read that the other endpoint in this example should be part of the same service.

'In order to facilitate this kind of setup, in a Python function or prediction endpoint, you can obtain a dataikuapi.APINodeClient that is already preconfigured to query other endpoints of the same service.'

example :  result = client.predict_record("other_endpoint", {"feature1" : "value1", "feature2" : 42})

In this call, there is no parameter to specify the API service in which the 'other_endpoint' is defined. 

Is there a way to add this information in the call ?

 

 

0 Kudos
AdrienL
Dataiker

No, as the API service is the deployment unit.

In that case, you'll have to fully instantiate an APINodeClient (instead of using get_self_client), that's where you can specify the service ID.

0 Kudos
rona
Level 3
Author

Thanks a lot !

It is clear.

0 Kudos

Labels

?
Labels (1)
A banner prompting to get Dataiku