Type: Package
Title: 'FaaSr' Local Test Development Package
Version: 2.0.0
Maintainer: Figueiredo Renato <renato.figueiredo@oregonstate.edu>
Description: Provides a local execution environment for testing and developing the 'FaaSr' workflows without requiring cloud infrastructure. The 'FaaSr' package enables R developers to validate and test workflows locally before deploying to Function-as-a-Service (FaaS) platforms. Key features include: 1) Parsing and validating JSON workflow configurations compliant with the 'FaaSr' schema 2) Simulated S3 storage operations using local file system with local logging 3) Support for conditional branching 4) Support for parallel rank functions execution 5) Workflow cycle detection and validation 6) No cloud credentials or infrastructure required for testing This package is designed for development and testing purposes. For production deployment to cloud FaaS platforms, use the main 'FaaSr' package available at https://faasr.io/.
License: MIT + file LICENSE
URL: https://github.com/FaaSr/FaaSr-package-v2
BugReports: https://github.com/FaaSr/FaaSr-package-v2/issues
Depends: R (≥ 3.5.0)
Imports: jsonlite, cli, jsonvalidate, uuid
Suggests: testthat, knitr, rmarkdown
VignetteBuilder: knitr
Encoding: UTF-8
Language: en-US
RoxygenNote: 7.3.3
NeedsCompilation: no
Packaged: 2026-03-19 16:36:10 UTC; figueren
Author: Figueiredo Renato ORCID iD [aut, cre, ths, cph], Park Sungjae ORCID iD [aut], Mu Nan [ctb], Ku Yun-Jung [ctb], Daneshmand Vahid [ctb], Thomas R. Quinn [aut], Carey Cayelan [ctb], Tran Hoang [aut], Ramrakhiani Ashish Tulso [aut]
Repository: CRAN
Date/Publication: 2026-03-19 16:50:02 UTC

Get local FaaSr files directory

Description

Internal function to get the files directory for local FaaSr data storage. Creates the directory if it doesn't exist.

Usage

.fa_files_root()

Value

Character string path to the files directory


Get local FaaSr data root directory

Description

Internal function to get the root directory for local FaaSr data storage. Uses the FAASR_DATA_ROOT environment variable if set, otherwise defaults to 'faasr_data' in the current working directory.

Usage

.fa_local_root()

Value

Character string path to the root directory


Get local FaaSr logs directory

Description

Internal function to get the logs directory for local FaaSr data storage. Creates the directory if it doesn't exist.

Usage

.fa_logs_root()

Value

Character string path to the logs directory


Build adjacency list from ActionList

Description

Internal function to build an adjacency list representation of the workflow graph from the ActionList using InvokeNext references.

Usage

.faasr_build_adjacency(action_list)

Arguments

action_list

List containing the workflow action definitions

Value

List where each element contains the names of functions that can be invoked next


Build reverse dependency map

Description

Builds a map showing which actions each action depends on (its predecessors). Only includes UNCONDITIONAL dependencies - conditional branches are handled dynamically.

Usage

.faasr_build_reverse_deps(action_list)

Arguments

action_list

List containing the workflow action definitions

Value

Named list where each element is a character vector of predecessor action names


Check predecessor type consistency in workflow

Description

Internal function to validate that all predecessors of each function are of the same type. Predecessors must be either all unconditional, all from the same conditional source, or no predecessors (starting node). Mixed predecessor types create ambiguous semantics.

Usage

.faasr_check_predecessor_consistency(action_list)

Arguments

action_list

List containing the workflow action definitions

Value

TRUE if consistent, stops with error if inconsistent


Check if action is ready to execute

Description

Checks if all required predecessors have completed by looking at the completed set. Only waits for predecessors that have been enqueued (added to execution plan). This handles conditional branching where some predecessors may never execute.

Usage

.faasr_check_ready_simple(
  action_name,
  reverse_deps,
  completed,
  enqueued_actions
)

Arguments

action_name

Character string name of the action to check

reverse_deps

Named list mapping actions to their predecessor actions

completed

Character vector of completed execution keys

enqueued_actions

Character vector of action names that have been enqueued

Value

TRUE if ready to execute, FALSE otherwise


Detect cycles in workflow graph using BFS

Description

Internal function to detect cycles in the workflow graph using BFS traversal. Uses a three-state tracking system (unvisited=0, in_progress=1, done=2) to detect back-edges. Workflows must be acyclic (DAG) to be valid.

Usage

.faasr_check_workflow_cycle_bfs(faasr, start_node)

Arguments

faasr

List containing the parsed workflow configuration

start_node

Character string name of the starting function

Value

TRUE if no cycles detected, stops with error if cycle found


Simplified FaaSr workflow configuration check

Description

Validates a FaaSr workflow configuration for JSON schema compliance and cycle detection. Unlike the full faasr_configuration_check, this does not check predecessor consistency because the simplified execution approach handles mixed predecessors correctly.

Usage

.faasr_configuration_check_simple(faasr, state_dir)

Arguments

faasr

List containing the parsed workflow configuration

state_dir

Character string path to the state directory

Value

TRUE if configuration is valid, error message string otherwise


Find predecessor functions with their types in workflow

Description

Internal function to find all predecessor functions for a given target function and categorize them by type (unconditional vs conditional).

Usage

.faasr_find_predecessors_with_types(action_list, target_func)

Arguments

action_list

List containing the workflow action definitions

target_func

Character string name of the target function

Value

List of predecessor information with name, type, source, and branch


Generate invocation ID based on workflow configuration

Description

Internal function to generate a unique invocation ID for the workflow execution. Priority: 1) Use InvocationID if provided, 2) Use InvocationIDFromDate if valid, 3) Generate UUID

Usage

.faasr_generate_invocation_id(wf)

Arguments

wf

List containing the parsed workflow configuration

Value

Character string invocation ID


Parse InvokeNext string to extract function name and rank

Description

Internal function to parse InvokeNext strings that may contain rank notation. Supports formats like "FunctionName" and "FunctionName(3)" for parallel execution.

Usage

.faasr_parse_invoke_next_string(invoke_string)

Arguments

invoke_string

Character string to parse

Value

List containing func_name, condition, and rank


Write invocation ID to temporary file

Description

Internal function to write invocation ID to a temporary file for the current execution context.

Usage

.faasr_write_invocation_id(invocation_id, state_dir)

Arguments

invocation_id

Character string invocation ID

state_dir

Character string path to the state directory

Value

Invisibly returns TRUE on success


Write rank information to temporary file

Description

Internal function to write rank information to a temporary file for the current execution context.

Usage

.faasr_write_rank_info(rank_info, state_dir)

Arguments

rank_info

Character string rank information in format "current/max" or NULL

state_dir

Character string path to the state directory

Value

Invisibly returns TRUE on success


Delete a file from local storage

Description

Deletes a file from the local FaaSr storage. This function mirrors the signature of the production FaaSr API but operates on local filesystem.

Usage

faasr_delete_file(server_name = NULL, remote_folder = "", remote_file)

Arguments

server_name

Character string specifying the server name (ignored in local implementation)

remote_folder

Character string path to the remote folder containing the file to delete

remote_file

Character string name of the remote file to delete

Value

Invisibly returns TRUE on success

Examples

## Not run: 
# Delete a file from remote storage
faasr_delete_file(remote_file = "temp_data.csv")

# Delete a file from a specific remote folder
faasr_delete_file(remote_folder = "temp", remote_file = "data.csv")

## End(Not run)

Get (download) a file from local storage

Description

Downloads a file from the local FaaSr storage to the local filesystem. This function mirrors the signature of the production FaaSr API but operates on local filesystem.

Usage

faasr_get_file(
  server_name = NULL,
  remote_folder = "",
  remote_file,
  local_folder = ".",
  local_file
)

Arguments

server_name

Character string specifying the server name (ignored in local implementation)

remote_folder

Character string path to the remote folder containing the file to download

remote_file

Character string name of the remote file to download

local_folder

Character string path to the local folder where the file will be saved

local_file

Character string name for the file in local storage

Value

Invisibly returns TRUE on success

Examples

## Not run: 
# Download a file from remote storage
faasr_get_file(remote_file = "data.csv", local_file = "downloaded_data.csv")

# Download to a specific local folder
faasr_get_file(remote_folder = "processed", remote_file = "data.csv",
               local_folder = "output", local_file = "data.csv")

## End(Not run)

List files in local storage with optional prefix

Description

Lists all files in the local FaaSr storage, optionally filtered by a prefix. This function mirrors the signature of the production FaaSr API but operates on local filesystem.

Usage

faasr_get_folder_list(server_name = NULL, faasr_prefix = "")

Arguments

server_name

Character string specifying the server name (ignored in local implementation)

faasr_prefix

Character string prefix to filter file names (optional)

Value

Character vector of file names matching the criteria

Examples

## Not run: 
# List all files in storage
files <- faasr_get_folder_list()

# List files with a specific prefix
csv_files <- faasr_get_folder_list(faasr_prefix = "data_")

## End(Not run)

Get the invocation ID for the current workflow

Description

Returns the invocation ID for the current workflow execution. This function mirrors the signature of the production FaaSr API but operates on local filesystem.

Usage

faasr_invocation_id()

Value

Character string invocation ID, or NULL if not available

Examples

## Not run: 
# Get current invocation ID
inv_id <- faasr_invocation_id()
if (!is.null(inv_id)) {
  cat("Invocation ID:", inv_id, "\n")
}

## End(Not run)

Append a log message to local logs

Description

Appends a log message with timestamp to the local FaaSr log file. This function mirrors the signature of the production FaaSr API but operates on local filesystem.

Usage

faasr_log(log_message)

Arguments

log_message

Character string message to log

Value

Invisibly returns TRUE on success

Examples

## Not run: 
# Log a simple message
faasr_log("Starting data processing")

# Log with more detail
faasr_log(paste("Processing", nrow(data), "rows of data"))

## End(Not run)

Put (upload) a file to local storage

Description

Uploads a file from the local filesystem to the local FaaSr storage. This function mirrors the signature of the production FaaSr API but operates on local filesystem.

Usage

faasr_put_file(
  server_name = NULL,
  local_folder = ".",
  local_file,
  remote_folder = "",
  remote_file
)

Arguments

server_name

Character string specifying the server name (ignored in local implementation)

local_folder

Character string path to the local folder containing the file to upload

local_file

Character string name of the local file to upload

remote_folder

Character string path to the remote folder where the file will be stored

remote_file

Character string name for the file in remote storage

Value

Invisibly returns TRUE on success

Examples

## Not run: 
# Upload a local file to remote storage
faasr_put_file(local_file = "data.csv", remote_file = "input/data.csv")

# Upload from a specific local folder
faasr_put_file(local_folder = "input", local_file = "data.csv", 
               remote_folder = "processed", remote_file = "data.csv")

## End(Not run)

Get current rank information for the executing function

Description

Returns the current rank information for the executing function in a parallel workflow. This function mirrors the signature of the production FaaSr API but operates on local filesystem.

Usage

faasr_rank()

Value

List containing Rank and MaxRank, or empty list if no rank information is available

Examples

## Not run: 
# Get current rank information
rank_info <- faasr_rank()
if (length(rank_info) > 0) {
  cat("Current rank:", rank_info$Rank, "of", rank_info$MaxRank, "\n")
}

## End(Not run)

FaaSr test execution

Description

Workflow execution that dynamically handles conditional branching and predecessor dependencies without precomputation.

Usage

faasr_test(json_path)

Arguments

json_path

path to workflow JSON

Value

TRUE if all functions run successfully; stops on error