@sfdl/prpc
TypeScript icon, indicating that this package has built-in type declarations

0.3.3 • Public • Published

prpc-python - Pyodide Remote Procedure Calls - Typescript Client

npm version npm - License GitHub issues

PRPC is an npm library which simplifies the process of integrating a Pyodide-Python layer (and much more)

PRPC seeks to simplify the integration of Pyodide + alternative APIs in a way that acts as an abstraction layer for the front-end. To do this is standardizes on an RPC call between the application layers, with a payload which instructs the API implementation on how to handle the request and return a response.

When Pyodide is used as a back-end it also simplifies the process of running the implementation in a WebWorker to allow complex data wrangling to take place without causing the UI to halt.

Installation

yarn add @sfdl/prpc or npm install --save-dev @sfdl/prpc

Usage

  1. import the required library and types
import { createApi, APITransport } from '@sfdl/prpc';
  1. initialize the API and wait for it to confirm that it is ready
const apiConfig = {
  transport: APITransport.WEB,
  options: {
    url: 'http://localhost:8000',
  },
};
const api = await createApi(apiConfig, () => {});
  1. make a call to the API
const apiResponse = await api.call("methodname", {/*payload*/})

For running in pyodide, set the apiConfig as follows:

const apiConfig = {
  transport: APITransport.PYODIDE,
  options: {
    nativePackages: ['numpy', 'pandas'],
    packages: ['<your package name>'],
  },
};

<your package name> can either be the PyPI package name, or the URL to a wheel file.

Package Sidebar

Install

npm i @sfdl/prpc

Weekly Downloads

0

Version

0.3.3

License

MIT

Unpacked Size

36.5 kB

Total Files

38

Last publish

Collaborators

  • kajws
  • davetickle_sfdl