Hi,
At Ancestralize, we are planning to use TypeScript as our main programming language, as we believe it is a great fit for both our frontend and our backend. What is the best way to integrate the SMILE engine into such a backend?
Thanks,
Gabor
What is the best way to integrate SMILE into a TypeScript backend?
-
- Posts: 2
- Joined: Wed Aug 24, 2022 4:32 pm
-
- Site Admin
- Posts: 1442
- Joined: Mon Nov 26, 2007 5:51 pm
Re: What is the best way to integrate SMILE into a TypeScript backend?
I believe your options for SMILE integration are:
1. if the backend runs on Node, write an add-on with N-API (https://nodejs.org/api/n-api.html#node-api). The add-on would link SMILE and perform the calculations. Please note that we have never done anything with Node add-ons, this suggestion is based on internet search only.
2. write an external program, which your Typescript backend would execute. We have this approach implemented in BayesBox (but the caller is a Java program). The choice of language (C++ vs. Python, Java, .NET, R) would be yours. In BayesBox we pass inputs/read outputs using standard in/out.
3. write an AWS Lambda (or Azure equivalent), call lambda from Typescript on the backend. BayesBox has this as an optional backend. For best performance, use C++ for Lambda, but Python and Java are also supported on AWS. This approach would scale quite nicely, if you ever need large throughput.
1. if the backend runs on Node, write an add-on with N-API (https://nodejs.org/api/n-api.html#node-api). The add-on would link SMILE and perform the calculations. Please note that we have never done anything with Node add-ons, this suggestion is based on internet search only.
2. write an external program, which your Typescript backend would execute. We have this approach implemented in BayesBox (but the caller is a Java program). The choice of language (C++ vs. Python, Java, .NET, R) would be yours. In BayesBox we pass inputs/read outputs using standard in/out.
3. write an AWS Lambda (or Azure equivalent), call lambda from Typescript on the backend. BayesBox has this as an optional backend. For best performance, use C++ for Lambda, but Python and Java are also supported on AWS. This approach would scale quite nicely, if you ever need large throughput.
-
- Posts: 2
- Joined: Wed Aug 24, 2022 4:32 pm
Re: What is the best way to integrate SMILE into a TypeScript backend?
Thank you, those are good ideas. I was hoping there might be an easier way to do it, but I guess writing a thin API or Node addon shouldn't be too hard.
Have you considered creating a language-neutral API for SMILE at some point? Maybe a CLI, an HTTP API, or a WebAssembly component...
Have you considered creating a language-neutral API for SMILE at some point? Maybe a CLI, an HTTP API, or a WebAssembly component...
-
- Site Admin
- Posts: 1442
- Joined: Mon Nov 26, 2007 5:51 pm
Re: What is the best way to integrate SMILE into a TypeScript backend?
We did not, this would be have to be a large effort if all of the SMILE functionality would be covered. The minimal CLI which gets the network and evidence on input and returns the calculated probabilities could be extracted from our BayesBox sources, but it's quite easy to write in any supported language.Have you considered creating a language-neutral API for SMILE at some point?