Skip to content

Writing Custom Functions in Rust #5

@depatchedmode

Description

@depatchedmode

Feature Description

As we solicit feedback from folks, they need to be able to write custom functions in order to:

  1. Evaluate and understand the capabilities of the Everywhere Computer
  2. Imagine clear use cases within their business

Use Cases

  • Creating bespoke workflows for your own problem domain
  • Really running EC through the trials
  • Writing a basic "Hello World" rust module and seeing how it runs as a workflow

Signals of Success

More function diversity in each run, and overall.

Current Workarounds (optional)

Technically possible write now, but requires making changes to core code. See Philipp's tear down of how it's done presently: https://www.loom.com/share/19c4651b5ae6419ea091cd6c2fcb049f?sid=8739f44e-e88e-4a29-9446-5eb9a39d59aa

Summary of current process is:

  1. in your local Homestar repo:
  • write a function in homestar-functions/src/lib.rs
  • add type definitions to 'homestar-functions/wit/host.wit`
  • compile by running cargo build -p homestar-functions-test --target wasm32-unkown-unknown --profile release-wasm-fn
  • now turn it into a Wasm component: wasm-tools component new ... -o functions.wasm
  • ingest into local IPFS node
  1. in your local Control Panel repo:
  • launch the control panel npm run dev
  • make function available in dropdown. update the VITE_WORKFLOW_RESOURCE with the newly created module's CID in .env
  • add the function signature to the const FUNCTION_NAMES array in NewFunctionNode.svelte
  • in function-template.ts:
    • rewrite generateFunction as so:
       // philipp's snippet goes here
      
    • specify default parameters in the const DEFAULT_PARAMS object
  • in graph.ts add function definitions to const FUNCTION_PARAMS

Extreme MVP is to document the workaround of manually writing and ingesting wasm modules.
Consider this a map of the work to be done in pursuit of a cleaner DX for authoring -> publishing in your local registry of functions.

Evidence of Value (Optional)

Table stakes! You can't have a computer if there's nothing to compute.

Tasks & Jobs Stories

  • Decide where to store function configuration — in the getting-started repo?
    • Make a decision on whether to change that repo's name everywhere-computer/getting-started#3
  • Control Panel: generalize function invocation
  • Control Panel: move parameter editing in visual workflow builder to its own pane, to avoid the need for different node sizes based on
  • Control Panel: display correct parameter inputs based on parameter type definition
  • Control Panel: support for multiple modules
  • Control Panel: ingestion of modules and functions via UI (drag n' drop, file picker)
  • Guide: Writing Custom Functions docs#4
  • Control Panel: Track the usage of custom functions

Additional Context (Optional)

Boris is going to start by dog fooding the process.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions