Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Funz/Funz.R
Browse files Browse the repository at this point in the history
  • Loading branch information
yannrichet committed Dec 28, 2023
2 parents 8378109 + b36de4a commit ce84b83
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 37 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
r-version: [ 3.6, oldrel, release, devel ]

env:
debian-deps: libssl-dev libcurl4-openssl-dev
debian-deps: libssl-dev libcurl4-openssl-dev libharfbuzz-dev libfribidi-dev
macos-deps: openssl-1.1.1h
windows-deps: openssl

Expand All @@ -31,7 +31,7 @@ jobs:
distribution: 'adopt'
java-version: 11

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.r-version }}

Expand All @@ -53,16 +53,19 @@ jobs:
run: |
echo "C:\rtools" >> $GITHUB_PATH
echo "C:\rtools40" >> $GITHUB_PATH
echo "C:\rtools41" >> $GITHUB_PATH
echo "C:\rtools42" >> $GITHUB_PATH
echo "C:\rtools43" >> $GITHUB_PATH
shell: bash
- name: Install Windows dependencies
if: ${{ runner.os == 'Windows' && env.windows-deps != '' }}
run: |
mingw32.exe pacman -Sy
mingw64.exe pacman -Sy
mingw32.exe pacman -Sy || echo "No mingw32.exe"
mingw64.exe pacman -Sy || echo "No mingw64.exe"
for i in ${{ env.windows-deps }}; do
echo -n " $i"
mingw32.exe pacman --sync --noconfirm mingw-w64-i686-$i
mingw64.exe pacman --sync --noconfirm mingw-w64-x86_64-$i mingw-w64-i686-$i
mingw32.exe pacman --sync --noconfirm mingw-w64-i686-$i || echo "No mingw32.exe"
mingw64.exe pacman --sync --noconfirm mingw-w64-x86_64-$i mingw-w64-i686-$i || echo "No mingw64.exe"
done
shell: bash

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
R: [3.6, 4.0, 4.1]
R: [3.6, oldrel, release, devel ]
runs-on: ${{ matrix.os }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -22,7 +22,7 @@ jobs:
with:
java-version: 11
distribution: 'adopt'
- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.R }}
- run: mkdir ${{ matrix.os }}-R${{ matrix.R }}
Expand All @@ -36,9 +36,9 @@ jobs:
- if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: sudo R CMD javareconf
- if: matrix.os == 'ubuntu-latest'
run: sudo apt install -y libcurl4-openssl-dev
run: sudo apt install -y libcurl4-openssl-dev libharfbuzz-dev libfribidi-dev
- run: |
Rscript -e "if (R.Version()$os!='linux-gnu') options(install.packages.compile.from.source='never'); install.packages('remotes', repos = 'https://cloud.r-project.org'); download.file('https://raw.githubusercontent.com/Funz/Funz.R/master/DESCRIPTION','DESCRIPTION'); remotes::install_deps(dependencies=TRUE)" > ${{ matrix.os }}-R${{ matrix.R }}/install.Rout; \
Rscript -e "if (R.Version()[['os']]!='linux-gnu') options(install.packages.compile.from.source='never'); install.packages('remotes', repos = 'https://cloud.r-project.org'); download.file('https://raw.githubusercontent.com/Funz/Funz.R/master/DESCRIPTION','DESCRIPTION'); remotes::install_deps(dependencies=TRUE)" > ${{ matrix.os }}-R${{ matrix.R }}/install.Rout; \
Rscript -e "install.packages('devtools', repos= 'https://cloud.r-project.org'); devtools::install_github('Funz/Funz.R',dependencies=FALSE, INSTALL_opts=c('--no-multiarch'))" > ${{ matrix.os }}-R${{ matrix.R }}/install.Rout; \
Rscript -e "library(Funz); install.Design('GradientDescent')" >> ${{ matrix.os }}-R${{ matrix.R }}/install.Rout
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Description: Binding to Funz <https://funz.github.io/> parametric computing envi
Also provide function to deal with Funz setup (eg. install plugin/binding to simulation software, algorithms, ...).
License: Apache License (>= 2)
Encoding: UTF-8
Imports: rJava (>= 1.0-0), Rserve (>= 1.8), xml2, utils, foreach, parallel, processx, gh
Imports: rJava (>= 1.0-0), Rserve (>= 1.8), xml2, utils, foreach, parallel, processx, curl, jsonlite
SystemRequirements: Java (>= 8)
URL: https://github.com/Funz/Funz.R
RoxygenNote: 7.2.3
53 changes: 27 additions & 26 deletions R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
.github_pattern))))
}

.github_repos <- gh::gh("/orgs/Funz/repos",.token=NA)
if (length(.github_repos)==0) .github_repos <- NA
# should blok at package install/lazy load if not connected: .github_repos <- gh::gh("/orgs/Funz/repos",.token=NA, per_page=100)
#if (length(.github_repos)==0)
.github_repos <- NA

############################ Models #################################

Expand Down Expand Up @@ -73,11 +74,12 @@ installed.Models <- function() {
#' }
available.Models <- function(refresh_repo = F) {
if (refresh_repo | any(is.na(.github_repos)))
.env$.github_repos <- gh::gh("/orgs/Funz/repos",.token=NA)
.github_repos <- jsonlite::fromJSON(readLines(curl::curl("https://api.github.com/orgs/Funz/repos?per_page=100"),warn=FALSE))
# not working behind some proxy: gh::gh("/orgs/Funz/repos",.token=NA, per_page=100)

gsub("plugin-","",
unlist(lapply(.github_repos,
function(r) {if (length(grep("plugin-",r$name))>0) r$name else NULL})),
unlist(lapply(.github_repos$name,
function(r) {if (length(grep("plugin-",r))>0) r else NULL})),
fixed=T)
}

Expand Down Expand Up @@ -155,7 +157,7 @@ setup.Model <- function(model, edit.script=FALSE) {
attr(node,"command") <- normalizePath(script)
cplugin = file.path(FUNZ_HOME,"plugins","calc",paste0(model,".cplugin.jar"))
if (file.exists(cplugin))
attr(node,"cplugin") <- paste0("file:/",normalizePath(cplugin))
attr(node,"cplugin") <- paste0("file://",normalizePath(cplugin))
}
if (isTRUE(node == "[ comment ]")) {
node <- NA
Expand All @@ -169,7 +171,7 @@ setup.Model <- function(model, edit.script=FALSE) {
attr(node,"command") <- normalizePath(script)
cplugin = file.path(FUNZ_HOME,"plugins","calc",paste0(model,".cplugin.jar"))
if (file.exists(cplugin))
attr(node,"cplugin") <- paste0("file:/",normalizePath(cplugin))
attr(node,"cplugin") <- paste0("file://",normalizePath(cplugin))
}
calculator.xml$CALCULATOR[[i+1]] <- node
names(calculator.xml$CALCULATOR)[[i+1]] <- "CODE"
Expand Down Expand Up @@ -233,14 +235,13 @@ install_github.Model <- function(model,force=F, edit.script=FALSE) {
#' install.Model('Modelica')
#' }
install.Model <- function(model,force=F, edit.script=FALSE) {
if (file.exists(model))
install_file.Model(model, force, edit.script)
else {
if (model %in% available.Models())
install_github.Model(model, force, edit.script)
else
stop("Model ",model," is not available.")
}
if (file.exists(model) && !dir.exists(model))
try({install_file.Model(model, force, edit.script); return()})

if (model %in% available.Models())
install_github.Model(model, force, edit.script)
else
stop("Model ",model," is not available.")
}


Expand Down Expand Up @@ -269,11 +270,12 @@ installed.Designs <- function() {
#' }
available.Designs <- function(refresh_repo = F) {
if (refresh_repo | any(is.na(.github_repos)))
.env$.github_repos <- gh::gh("/orgs/Funz/repos",.token=NA)
.github_repos <- jsonlite::fromJSON(readLines(curl::curl("https://api.github.com/orgs/Funz/repos?per_page=100"),warn=FALSE))
# not working behind some proxy: gh::gh("/orgs/Funz/repos",.token=NA, per_page=100)

gsub("algorithm-","",
unlist(lapply(.github_repos,
function(r) {if (length(grep("algorithm-",r$name))>0) r$name else NULL})),
unlist(lapply(.github_repos$name,
function(r) {if (length(grep("algorithm-",r))>0) r else NULL})),
fixed=T)
}

Expand Down Expand Up @@ -347,12 +349,11 @@ install_github.Design <- function(design,force=F) {
#' install.Design('GradientDescent')
#' }
install.Design <- function(design,force=F) {
if (file.exists(design))
install_file.Design(design, force)
else {
if (design %in% available.Designs())
install_github.Design(design, force)
else
stop("Design ",design," is not available.")
}
if (file.exists(design) && !dir.exists(design))
try({install_file.Design(design, force); return()})

if (design %in% available.Designs())
install_github.Design(design, force)
else
stop("Design ",design," is not available.")
}

0 comments on commit ce84b83

Please sign in to comment.