Skip to content

Commit

Permalink
Merge pull request #18 from ethanwhite/install-updates
Browse files Browse the repository at this point in the history
Improve installation experience
  • Loading branch information
ethanwhite authored Jul 18, 2024
2 parents c05aa4c + 12d9053 commit a63f110
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 13 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ Suggests:
testthat (>= 1.0.0),
devtools,
knitr,
raster,
rmarkdown
VignetteBuilder: knitr
SystemRequirements: Python (>= 3.0) (version must be listed to patch to allow parsing)
License: MIT + file LICENSE
LazyData: true
RoxygenNote: 7.1.1
RoxygenNote: 7.2.3
Encoding: UTF-8
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

export(df_model)
export(get_data)
export(install_deepforest)
importFrom(reticulate,conda_remove)
importFrom(reticulate,import)
importFrom(reticulate,install_miniconda)
importFrom(reticulate,py_install)
importFrom(reticulate,r_to_py)
34 changes: 31 additions & 3 deletions R/deepforestr.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
#' Install the DeepForest Python package
#'
#' @examples
#' \dontrun{
#' deepforestr::install_deepforest()}
#'
#' @importFrom reticulate install_miniconda py_install conda_remove
#' @export
install_deepforest <- function() {
miniconda_path = reticulate::miniconda_path()
if (!dir.exists(miniconda_path)) {
reticulate::install_miniconda()
} else {
print(sprintf("Using existing miniconda install at %s", miniconda_path))
}
reticulate::py_install(c("gdal", "rasterio", "fiona"), method = "conda")
#if (reticulate::py_module_available("mkl")) {
# Remove package that has caused conflicts on Windows due to double install
# The correct version of mkl will be installed with deepforest (below)
# on systems where it is needed
# reticulate::conda_remove("r-reticulate", packages = c("mkl"))
#}
reticulate::py_install("DeepForest", method = "conda", pip = TRUE)
}

#' Get example data
#'
#' @param path path to the example data file
#'
#' @examples
#' \dontrun{
#' deepforestr::get_data("OSBS_029.png")
#' }
#'
#' @importFrom reticulate import r_to_py
#' @export
Expand All @@ -12,10 +39,11 @@ get_data <- function(path) {
}

#' Deepforest Model object
#'
#' @examples
#' deepforestr::df_model()
#'
#' @examples
#' \dontrun{
#' model = deepforestr::df_model()
#' }
#' @importFrom reticulate import r_to_py
#' @export
df_model <- function() {
Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ This will create a local Python installation that will only be used by R and ins
If installing on Windows you need to [install RTools](https://cran.r-project.org/bin/windows/Rtools/) before installing the R package.

```R
install.packages('reticulate') # Install R package for interacting with Python
reticulate::install_miniconda() # Install Python
reticulate::py_install(c('gdal', 'rasterio', 'fiona')) # Install spatial dependencies via conda
reticulate::conda_remove('r-reticulate', packages = c('mkl')) # Remove package that causes conflicts on Windows (and maybe macOS)
reticulate::py_install('DeepForest', pip=TRUE) # Install the Python retriever package
devtools::install_github('weecology/deepforestr') # Install the R package for running the retriever
install.packages('raster') # For visualizing output for rasters
devtools::install_github('weecology/deepforestr') # Install the R package from GitHub
deepforestr::install_deepforest() # Install Python & DeepForest; Takes ~3 minutes
```

**After running these commands restart R.**
Expand Down
5 changes: 3 additions & 2 deletions man/df_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/get_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions man/install_deepforest.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a63f110

Please sign in to comment.