Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
^LICENSE\.md$
^codecov\.yml$
^\.vscode$
^\.claude$
^cran-comments\.md$
^tests/testthat/\.fz$
17 changes: 2 additions & 15 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'release'}
- {os: macos-latest, r: 'release'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -44,16 +41,6 @@ jobs:
extra-packages: any::rcmdcheck
needs: check

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install fz Python package
run: |
python -m pip install --upgrade pip
pip install fz || echo "fz package installation failed, continuing anyway"

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
39 changes: 39 additions & 0 deletions .github/workflows/test-with-python.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on:
push:
branches: [main, master, develop, 'claude/**']
pull_request:
branches: [main, master, develop]

name: test-with-python

jobs:
test-with-python:
runs-on: ubuntu-latest

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
NOT_CRAN: "true"
FZ_MAX_RETRIES: "1"

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
r-version: 'release'
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::testthat
needs: check

- uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install fz Python package
run: pip install funz-fz

- name: Run tests
run: Rscript -e "testthat::test_local()"
24 changes: 15 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
Package: fz
Type: Package
Title: R Wrapper for Fz Core Functions
Version: 0.1.0
Title: R Wrapper for the 'funz-fz' Parametric Simulation Framework
Version: 1.1
Authors@R: c(
person("Author", "Name", email = "author@example.com", role = c("aut", "cre"))
person("Yann", "Richet", email = "yann.richet@asnr.fr",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-5677-8458"))
)
Description: Provides R bindings to fz core functions using reticulate.
This package allows R users to access fz functionality directly from R.
License: MIT + file LICENSE
Description: Provides R bindings to the 'funz-fz' Python package using
'reticulate'. The 'fz' framework wraps arbitrary simulation codes to run
parameter sweeps, design-of-experiments studies, and iterative
algorithm-driven analyses by substituting variable placeholders in text
input files and collecting outputs into data frames. Calculators can run
locally (shell), over SSH, or on 'SLURM' clusters.
License: BSD_3_clause + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
Language: en-US
RoxygenNote: 7.3.3
SystemRequirements: Python (>= 3.8), funz-fz Python package
Imports:
reticulate (>= 1.28)
Suggests:
Expand All @@ -20,7 +26,7 @@ Suggests:
Config/reticulate:
list(
packages = list(
list(package = "fz")
list(package = "funz-fz")
)
)
VignetteBuilder: knitr
Expand Down
24 changes: 3 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
MIT License

Copyright (c) 2025 Funz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
YEAR: 2025
ORGANIZATION: Funz
COPYRIGHT HOLDER: Funz
28 changes: 28 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# BSD 3-Clause License

Copyright (c) 2025, Funz

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 changes: 22 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

export(fz_available)
export(fz_install)
export(fzc)
export(fzd)
export(fzi)
export(fzl)
export(fzo)
export(fzr)
export(get_config)
export(get_interpreter)
export(get_log_level)
export(install)
export(install_algorithm)
export(install_model)
export(list_installed_algorithms)
export(list_installed_models)
export(list_models)
export(print_config)
export(reload_config)
export(set_interpreter)
export(set_log_level)
export(uninstall)
export(uninstall_algorithm)
export(uninstall_model)
importFrom(reticulate,import)
importFrom(reticulate,py_install)
importFrom(reticulate,py_module_available)
37 changes: 29 additions & 8 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
# fz 0.1.0
# fz 1.1

## Initial Release
First release, aligned with funz-fz 1.1 on PyPI.

* Initial release of fz R package
* Provides R wrapper for fz Python package using reticulate
* Functions for installing and checking fz availability
* Comprehensive test suite with testthat
* CI/CD setup with GitHub Actions for R CMD check and CRAN checks
* Documentation and vignettes
## Core functions

* `fzi(input_path, model)` — parse variable names and defaults from a template file
* `fzc(input_path, input_variables, model, output_dir)` — compile template by substituting variable values
* `fzo(output_path, model)` — read and parse output files
* `fzr(input_path, input_variables, model, ...)` — run full parametric study
* `fzl(models, calculators, check)` — list installed models and calculators
* `fzd(input_path, input_variables, model, output_expression, algorithm, ...)` — iterative algorithm-driven design of experiments

## Model and algorithm management

* `install_model(source, global)` / `install_algorithm(source, global)` — install from GitHub, URL, or local zip
* `uninstall_model(model_name, global)` / `uninstall_algorithm(algorithm_name, global)` — remove installed items
* `list_installed_models(global)` / `list_installed_algorithms(global)` — list what is installed
* `list_models()` — alias for `list_installed_models()`
* `install()` / `uninstall()` — generic aliases for model install/uninstall

## Configuration

* `get_interpreter()` / `set_interpreter(interpreter)` — get or set the formula interpreter (`"python"` or `"R"`)
* `get_log_level()` / `set_log_level(level)` — control logging verbosity
* `get_config()` / `print_config()` / `reload_config()` — inspect and reload `FZ_*` environment variable settings

## Package helpers

* `fz_install()` — install the `funz-fz` Python package via reticulate
* `fz_available()` — check whether the Python package is importable
139 changes: 139 additions & 0 deletions R/config.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#' Get the Current Interpreter
#'
#' Returns the global formula interpreter used when evaluating formula
#' expressions inside template files (e.g. \code{"python"} or \code{"R"}).
#'
#' @return Character string naming the current interpreter.
#' @export
#'
#' @examples
#' \dontrun{
#' if (fz_available()) {
#' get_interpreter() # e.g. "python"
#' }
#' }
get_interpreter <- function() {
get_fz()$get_interpreter()
}

#' Set the Interpreter
#'
#' Sets the global formula interpreter for evaluating expressions inside
#' template files.
#'
#' @param interpreter Character string: \code{"python"} or \code{"R"}.
#'
#' @return NULL (invisibly). Called for side effects.
#' @export
#'
#' @examples
#' \dontrun{
#' if (fz_available()) {
#' set_interpreter("R") # evaluate formulas with R
#' set_interpreter("python") # evaluate formulas with Python (default)
#' }
#' }
set_interpreter <- function(interpreter) {
get_fz()$set_interpreter(interpreter)
}

#' Get the Current Log Level
#'
#' Returns the current logging verbosity level.
#'
#' @return A log-level value (use \code{as.character()} to convert to a string
#' such as \code{"DEBUG"}, \code{"INFO"}, \code{"WARNING"}, \code{"ERROR"}).
#' @export
#'
#' @examples
#' \dontrun{
#' if (fz_available()) {
#' as.character(get_log_level()) # e.g. "WARNING"
#' }
#' }
get_log_level <- function() {
get_fz()$get_log_level()
}

#' Set the Log Level
#'
#' Controls how much output fz emits during execution.
#'
#' @param level Character string or log-level object: one of \code{"DEBUG"},
#' \code{"INFO"}, \code{"WARNING"}, \code{"ERROR"}.
#'
#' @return NULL (invisibly). Called for side effects.
#' @export
#'
#' @examples
#' \dontrun{
#' if (fz_available()) {
#' set_log_level("DEBUG") # maximum verbosity
#' set_log_level("WARNING") # default
#' set_log_level("ERROR") # errors only
#' }
#' }
set_log_level <- function(level) {
get_fz()$set_log_level(level)
}

#' Get the Global Configuration
#'
#' Returns the fz configuration object. Values are controlled by environment
#' variables such as \code{FZ_LOG_LEVEL}, \code{FZ_MAX_WORKERS},
#' \code{FZ_MAX_RETRIES}, and \code{FZ_SHELL_PATH}.
#'
#' @return A Python \code{Config} object. Access fields with \code{$}, e.g.
#' \code{get_config()$max_workers}.
#' @export
#'
#' @examples
#' \dontrun{
#' if (fz_available()) {
#' cfg <- get_config()
#' cfg$max_workers
#' cfg$max_retries
#' }
#' }
get_config <- function() {
get_fz()$get_config()
}

#' Print the Current Configuration
#'
#' Prints all fz configuration values in a human-readable format, including
#' which settings come from environment variables.
#'
#' @return NULL (invisibly). Called for side effects.
#' @export
#'
#' @examples
#' \dontrun{
#' if (fz_available()) {
#' print_config()
#' }
#' }
print_config <- function() {
get_fz()$print_config()
}

#' Reload Configuration from Environment Variables
#'
#' Re-reads all \code{FZ_*} environment variables and updates the live
#' configuration. Useful after changing environment variables within the
#' session.
#'
#' @return NULL (invisibly). Called for side effects.
#' @export
#'
#' @examples
#' \dontrun{
#' if (fz_available()) {
#' Sys.setenv(FZ_MAX_WORKERS = "8")
#' reload_config()
#' get_config()$max_workers # now 8
#' }
#' }
reload_config <- function() {
get_fz()$reload_config()
}
Loading
Loading