mirai

Featured

Help users write correct R code for async, parallel, and distributed computing using mirai. Use when users need to run R code asynchronously or in parallel, write mirai code with correct dependency passing, set up parallel workers, convert from future or parallel, use mirai_map, integrate with Shiny or promises, or configure cluster/HPC computing.

AI & Automation 474 stars 42 forks Updated 3 days ago MIT

Install

View on GitHub

Quality Score: 92/100

Stars 20%
89
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

mirai is a minimalist R framework for async, parallel, and distributed evaluation, built on nanonext. ## Core Principle: Explicit Dependency Passing mirai evaluates expressions in a **clean environment** on a daemon process. Nothing from the calling environment is available unless passed explicitly — this is the #1 source of mistakes. ```r # WRONG: my_data and my_func are not available on the daemon m <- mirai(my_func(my_data)) ``` There are two ways to pass objects, and the names used **must match** the names referenced in the expression. ### `.args` (recommended) Objects in `.args` populate the expression's **local evaluation environment** — available directly by name inside the expression. ```r m <- mirai(my_func(my_data), .args = list(my_func = my_func, my_data = my_data)) ``` ### `...` (dot-dot-dot) Objects passed via `...` are assigned to the **daemon's global environment**. Use this when objects need to be found by R's standard scoping rules (e.g., helper functions called by other functions). ```r m <- mirai(my_func(my_data), my_func = my_func, my_data = my_data) ``` ### Shortcut: pass the whole calling environment ```r # .args form — populates local eval env process <- function(x, y) mirai(x + y, .args = environment()) # ... form — single unnamed environment, populates daemon global env df_matrix <- function(x, y) mirai(as.matrix(rbind(x, y)), environment()) ``` ### When to use which | Scenario | Use | |----------|-----| | Data and simple functions | `....

Details

Author
posit-dev
Repository
posit-dev/skills
Created
9 months ago
Last Updated
3 days ago
Language
R
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category