Dev#49
Conversation
- Replace Windows batch file approach with direct system2("java") invocation in new runMaxent() helper; works cross-platform, no .bat file needed.
- Update checkJava() to resolve Java via JAVA_HOME and common install directories when SyncroSim's minimal PATH does not include Java, patching the R session PATH so all subsequent calls succeed.
- Remove fsep = "\\" from file.path() calls used by R file operations.
- Clean up section organization in 08-fit-model-functions.R.
Split the single shared conda environment into separate Python and R environments to allow independent dependency management and avoid conflicts between the two runtimes.
updated 00-constants.R to set bitmapType = "cairo" on Unix when Cairo is available, removing the X11 display dependency for PNG output in R transformers.
Explicitly set blockxsize=256, blockysize=256 when writing tiled template rasters to ensure valid GeoTIFF tiling on Linux.
- Updated launchShinyApp to detect headless Unix environments (no DISPLAY) and bind to 0.0.0.0:3838 with launch.browser = FALSE, making the interactive viewers accessible via port forwarding or SSH tunnel. - Added an appName parameter so the live status message identifies the accessible app
…ehabitatHR library
…ries" This reverts commit 1a99104.
This reverts commit 2b5316d.
…t use adehabitatHR library" This reverts commit 4e7f0b7.
Spg linux compatibility
|
Note
|
| Layer / File(s) | Summary |
|---|---|
Environment Configuration & Constants src/00-constants.R, src/wisdm-py-conda.yml, src/wisdm-r-conda.yml, src/wisdm-conda.yml |
Sets options(bitmapType = "cairo") on Unix when available; original wisdm-conda.yml cleared and replaced by separate Python and R Conda specs. |
Shiny Launch & Java PATH Handling src/00-helper-functions.R |
launchShinyApp() gains appName; headless-Unix branch runs Shiny on 0.0.0.0:3838 without browser; checkJava() patches R session PATH when java is missing. |
MaxEnt Invocation & fitModel Refactor src/08-fit-model-functions.R |
fitModel()'s maxent branch now calls runMaxent() which invokes Java via system2; lambda loading paths updated for full vs CV fits; batch-file workflow removed; CV messaging reformatted; many model helper section headers added. |
Cross-Platform Path Handling & Tiling src/04-background-data-functions.R, src/8-fit-maxent.R, src/8-fit-glm.R, src/10-ensemble-model.py, src/2-spatial-data-preparation.py |
Switched to file.path()/POSIX-style separators, removed unconditional slash gsub and Windows batch outputs, and set raster blockxsize/blockysize to 256. |
Shiny App Naming src/6-variable-reduction.R, src/7-hyperparameter-tuning.R |
Calls to launchShinyApp() now include explicit appName values for UI messaging. |
Multiprocessing Configuration src/9-apply-model.R |
Adds desync_max_sec = 10 to setup_session() in Partial library branch. |
Pipeline Configuration & Version Bump src/package.xml |
Package version bumped to 2.5.1; transformers updated to use wisdm-py-conda.yml or wisdm-r-conda.yml with condaEnvVersion="6". |
Documentation docs/_scenarios/section2.md, docs/_scenarios/section3.md, docs/_scenarios/section6.md, docs/index.md |
Formatting and explanatory notes added: Background Data Generation formatting, background-site regeneration behavior on re-run, MESS/MoD limited to continuous variables, and SyncroSim requirement updated to 3.1.27+. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~75 minutes
Possibly related PRs
- ApexRMS/wisdm#45: Overlaps in MaxEnt and launchShinyApp changes.
- ApexRMS/wisdm#39: Related MaxEnt invocation and Java handling edits.
- ApexRMS/wisdm#43: Related MaxEnt fitting workflow modifications.
Suggested reviewers
- katieb1
- afilazzola
Poem
🐰 I hopped through slashes, cairo in my pack,
Java called directly — no .bat on my back.
Conda split tidy, R and Python in line,
Shiny wakes headless, named apps: all fine.
A small carrot for docs, the release looks divine.
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. | |
| Title check | ❓ Inconclusive | The title 'Dev' is vague and generic, providing no meaningful information about the changeset's primary purpose or scope. | Replace with a descriptive title summarizing the main changes, such as 'Refactor platform-specific paths, improve Shiny app handling, and update conda environments' or similar. |
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
dev
Tip
💬 Introducing Slack Agent: The best way for teams to turn conversations into code.
Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
- Generate code and open pull requests
- Plan features and break down work
- Investigate incidents and troubleshoot customer tickets together
- Automate recurring tasks and respond to alerts with triggers
- Summarize progress and report instantly
Built for teams:
- Shared memory across your entire org—no repeating context
- Per-thread sandboxes to safely plan and execute work
- Governance built-in—scoped access, auditability, and budget controls
One agent for your entire SDLC. Right inside Slack.
Comment @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/00-helper-functions.R (1)
629-643: ⚡ Quick winMake the headless Shiny port configurable.
Line 629 hardcodes port
3838, which can cause startup failures when multiple jobs run on the same host. Allow an env override to reduce collisions.Suggested patch
- port <- 3838 + port <- suppressWarnings(as.integer(Sys.getenv("WISDM_SHINY_PORT", "3838"))) + if (is.na(port) || port < 1L || port > 65535L) { + port <- 3838L + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/00-helper-functions.R` around lines 629 - 643, The port is hardcoded to 3838; change the code that sets port (the port variable used before progressBar and shiny::runApp) to read an environment override (e.g., Sys.getenv("SHINY_PORT") or similar), coerce it to an integer with a safe fallback to 3838 when missing/invalid, and use that variable in the progressBar message (which uses appName) and in shiny::runApp(appDir = appPath, host = "0.0.0.0", port = port, launch.browser = FALSE); ensure invalid/NA env values are handled so the fallback 3838 is used.src/08-fit-model-functions.R (1)
636-636: 💤 Low valueConsider validating
maxent.jarexistence before invocation.If
maxent.jaris missing from the package directory, the Java invocation will fail with a generic "jarfile not found" error. An early check would provide a clearer diagnostic.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/08-fit-model-functions.R` at line 636, Check that the computed jarPath (jarPath <- file.path(ssimEnvironment()$PackageDirectory, "maxent.jar")) actually exists before calling Java; if file.exists(jarPath) is FALSE, stop with a clear diagnostic (e.g., stop("maxent.jar not found in package directory: ", jarPath)) so callers get an explicit error rather than a generic "jarfile not found" from Java.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/08-fit-model-functions.R`:
- Around line 692-694: The call to system2("java", args = args) ignores its exit
status so Java/MaxEnt failures go unnoticed; capture the return value from
system2 (e.g., exit_code <- system2(..., stdout=..., stderr=...)) and check for
non-zero, then stop() or throw an informative error that includes the exit code
and any captured stdout/stderr before proceeding to read.maxent and expecting
species.lambdas; update the block that builds args and invokes system2 to
perform this check and fail fast with a clear message referencing system2, args,
and read.maxent/species.lambdas.
---
Nitpick comments:
In `@src/00-helper-functions.R`:
- Around line 629-643: The port is hardcoded to 3838; change the code that sets
port (the port variable used before progressBar and shiny::runApp) to read an
environment override (e.g., Sys.getenv("SHINY_PORT") or similar), coerce it to
an integer with a safe fallback to 3838 when missing/invalid, and use that
variable in the progressBar message (which uses appName) and in
shiny::runApp(appDir = appPath, host = "0.0.0.0", port = port, launch.browser =
FALSE); ensure invalid/NA env values are handled so the fallback 3838 is used.
In `@src/08-fit-model-functions.R`:
- Line 636: Check that the computed jarPath (jarPath <-
file.path(ssimEnvironment()$PackageDirectory, "maxent.jar")) actually exists
before calling Java; if file.exists(jarPath) is FALSE, stop with a clear
diagnostic (e.g., stop("maxent.jar not found in package directory: ", jarPath))
so callers get an explicit error rather than a generic "jarfile not found" from
Java.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 1a83b5f8-1e62-4563-a2be-b01b909ad003
📒 Files selected for processing (19)
docs/_scenarios/section2.mddocs/_scenarios/section3.mddocs/_scenarios/section6.mddocs/index.mdsrc/00-constants.Rsrc/00-helper-functions.Rsrc/04-background-data-functions.Rsrc/08-fit-model-functions.Rsrc/10-ensemble-model.pysrc/2-spatial-data-preparation.pysrc/6-variable-reduction.Rsrc/7-hyperparameter-tuning.Rsrc/8-fit-glm.Rsrc/8-fit-maxent.Rsrc/9-apply-model.Rsrc/package.xmlsrc/wisdm-conda.ymlsrc/wisdm-py-conda.ymlsrc/wisdm-r-conda.yml
💤 Files with no reviewable changes (1)
- src/wisdm-conda.yml
coderabbit update Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/08-fit-model-functions.R`:
- Around line 600-606: The Windows branch in checkJava (the if (os == "Windows")
block) incorrectly uses shell() with ignore.stdout/ignore.stderr which shell()
doesn't support, causing checkJava to fail on Windows; replace that shell(...)
call with system2("java", args = "-version", stdout = FALSE, stderr = FALSE) so
the Java probe suppresses output correctly and mirrors the non-Windows check,
ensuring checkJava and downstream MaxEnt detection work on Windows.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 6a479d62-79e4-4e29-be4f-77bcf02a120e
📒 Files selected for processing (1)
src/08-fit-model-functions.R
Replaced platform-specific Java version check with a unified system2 call.
Script Organization
Readability
Generalizability
Summary by CodeRabbit
New Features
Documentation
Improvements