0.3.3 • Published 1 year ago

@sfdl/prpc v0.3.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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.

0.3.0

1 year ago

0.2.0

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

2 years ago