Skip to content

Commit e8ba3d9

Browse files
committed
Fix mod_prepare_HPC
1 parent 4f4657e commit e8ba3d9

16 files changed

+47
-36
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Package: IASDT.R
33
Title: Modelling the distribution of invasive alien plant species in
44
Europe
55
Version: 0.1.04
6-
Date: 2025-04-08
6+
Date: 2025-04-09
77
Authors@R:
88
person("Ahmed", "El-Gabbas", , "ahmed.el-gabbas@ufz.de", role = c("aut", "cre"),
99
comment = c(ORCID = "0000-0003-2225-088X"))

R/DWF_EASIN_process.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ EASIN_process <- function(
264264
## Prepare working on parallel ----
265265

266266
IASDT.R::cat_time(
267-
paste0("Prepare working on parallel using ", n_cores, " cores."),
267+
paste0("Prepare working on parallel using ", n_cores, " cores"),
268268
level = 1)
269269

270270
if (n_cores == 1) {

R/DWF_Efforts_Summarize.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ efforts_summarize <- function(
7474
# Prepare working on parallel -----
7575

7676
IASDT.R::cat_time(
77-
paste0("Prepare working on parallel using ", n_cores, " cores."),
77+
paste0("Prepare working on parallel using ", n_cores, " cores"),
7878
level = 1)
7979

8080
if (n_cores == 1) {

R/DWF_GBIF_process.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ GBIF_process <- function(
184184
ChunkListRData <- stringr::str_replace_all(ChunkList, ".txt$", ".RData")
185185

186186
IASDT.R::cat_time(
187-
paste0("Prepare working on parallel using ", n_cores, " cores."),
187+
paste0("Prepare working on parallel using ", n_cores, " cores"),
188188
level = 1)
189189

190190
if (n_cores == 1) {
@@ -592,7 +592,7 @@ GBIF_process <- function(
592592
IASDT.R::cat_time("Split species data - grid/raster/plot", level = 1)
593593

594594
IASDT.R::cat_time(
595-
paste0("Prepare working on parallel using ", n_cores, " cores."),
595+
paste0("Prepare working on parallel using ", n_cores, " cores"),
596596
level = 1)
597597

598598
if (n_cores == 1) {

R/DWF_GBIF_species_data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ GBIF_species_data <- function(
207207
# Using ggplot2::ggsave directly does not show non-ascii characters
208208
# correctly
209209
ragg::agg_jpeg(
210-
filename = FilePath_Plot, width = 25, height = 25, res = 600,
210+
filename = FilePath_Plot, width = 25, height = 25, res = 600,
211211
quality = 100, units = "cm")
212212
print(SpPlot)
213213
grDevices::dev.off()

R/DWF_efforts_download.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ efforts_download <- function(n_cores = 6L, env_file = ".env") {
6060
## Prepare working on parallel -----
6161

6262
IASDT.R::cat_time(
63-
paste0("Prepare working on parallel using ", n_cores, " cores."),
63+
paste0("Prepare working on parallel using ", n_cores, " cores"),
6464
level = 1)
6565

6666
if (n_cores == 1) {

R/DWF_efforts_request.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ efforts_request <- function(
6666
# GBIF allows only 3 parallel requests. Here I wait until previous request
6767
# is finished.
6868
IASDT.R::cat_time(
69-
paste0("Prepare working on parallel using ", min(n_cores, 3), " cores."),
69+
paste0("Prepare working on parallel using ", min(n_cores, 3), " cores"),
7070
level = 1)
7171

7272
if (n_cores == 1) {

R/DWF_railway_intensity.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ railway_intensity <- function(
249249

250250
## Prepare working on parallel ----
251251
IASDT.R::cat_time(
252-
paste0("Prepare working on parallel using ", n_cores, " cores."),
252+
paste0("Prepare working on parallel using ", n_cores, " cores"),
253253
level = 1)
254254

255255
if (n_cores == 1) {

R/general_cat_diff.R

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
cat_diff <- function(
4848
init_time, chunk_text = "Session summary", prefix = "Completed in ",
49-
cat_info = FALSE, level = 0, time = FALSE, ...) {
49+
cat_info = FALSE, level = 0L, time = FALSE, ...) {
5050

5151
if (is.null(init_time)) {
5252
stop("`init_time` cannot be NULL", call. = FALSE)
@@ -57,15 +57,17 @@ cat_diff <- function(
5757
prefix <- paste0("\n", prefix)
5858
}
5959

60-
lubridate::time_length(lubridate::now(tzone = "CET") - init_time) %>%
61-
lubridate::seconds_to_period() %>%
62-
{
63-
paste0(
64-
stringr::str_pad(
65-
(lubridate::hour(.) + 24 * lubridate::day(.)), width = 2, pad = "0"),
66-
":", stringr::str_pad(lubridate::minute(.), width = 2, pad = "0"), ":",
67-
stringr::str_pad(round(lubridate::second(.)), width = 2, pad = "0"))
68-
} %>%
60+
Period <- lubridate::time_length(lubridate::now(tzone = "CET") - init_time) %>%
61+
lubridate::seconds_to_period()
62+
Period_hours <- stringr::str_pad(
63+
(lubridate::hour(Period) + 24 * lubridate::day(Period)),
64+
width = 2, pad = "0")
65+
Period_minutes <- stringr::str_pad(
66+
lubridate::minute(Period), width = 2, pad = "0")
67+
Period_seconds <- stringr::str_pad(
68+
round(lubridate::second(Period)), width = 2, pad = "0")
69+
70+
paste0(Period_hours, ":", Period_minutes, ":", Period_seconds) %>%
6971
paste0(prefix, .) %>%
7072
IASDT.R::cat_time(level = level, time = time, ...)
7173

R/general_package_remote_sha.R

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,22 @@
2727

2828
package_remote_sha <- function(...) {
2929

30+
package <- NULL
31+
3032
# Capture package names as symbols and convert to character strings
31-
Pk <- rlang::ensyms(...) %>%
32-
purrr::map_chr(.f = rlang::as_string)
33+
Pk <- rlang::ensyms(...)
34+
35+
# ensure at least one package is provided
36+
if (length(Pk) == 0) {
37+
stop("At least one package name must be provided", call. = FALSE)
38+
}
39+
40+
Pk <- purrr::map_chr(Pk, .f = rlang::as_string)
3341

3442
# Retrieve library status once for efficiency and map over packages
3543
lib_status <- IASDT.R::add_missing_columns(
36-
pak::lib_status(), NA_character_, "remotesha")
44+
pak::lib_status(), NA_character_, "remotesha") %>%
45+
dplyr::filter(package %in% Pk)
3746

3847
Out <- purrr::map_chr(
3948
.x = Pk,

R/mod_SLURM_refit.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ mod_SLURM_refit <- function(
157157
f <- file(IASDT.R::path(model_dir, OutCommandFile), open = "wb")
158158
on.exit(invisible(try(close(f), silent = TRUE)), add = TRUE)
159159
cat(Commands2Refit[CurrIDs], sep = "\n", append = FALSE, file = f)
160-
close(f)
160+
on.exit(close(f))
161161
})
162162

163163
IASDT.R::mod_SLURM(

R/mod_convergence_plot_all.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ convergence_plot_all <- function(
234234
IASDT.R::cat_time("Processing convergence data", level = 1)
235235

236236
IASDT.R::cat_time(
237-
paste0("Prepare working on parallel using ", n_cores, " cores."),
237+
paste0("Prepare working on parallel using ", n_cores, " cores"),
238238
level = 2)
239239

240240
if (n_cores == 1) {

R/mod_prepare_HPC.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ mod_prepare_HPC <- function(
572572
ragg::agg_jpeg(
573573
filename = IASDT.R::path(path_model, "NSpPerGrid_Sub.jpeg"),
574574
width = 25, height = plot_height, res = 600, quality = 100, units = "cm")
575-
575+
576576
print(NSpPerGrid_Sub)
577577
grDevices::dev.off()
578578

@@ -757,7 +757,7 @@ mod_prepare_HPC <- function(
757757
if (NCores_GPP > 1) {
758758

759759
IASDT.R::cat_time(
760-
paste0("Prepare working on parallel using ", NCores_GPP, " cores."),
760+
paste0("Prepare working on parallel using ", NCores_GPP, " cores"),
761761
level = 2, time = FALSE)
762762

763763
withr::local_options(
@@ -792,8 +792,8 @@ mod_prepare_HPC <- function(
792792
GPP_Knots <- purrr::map(
793793
.x = GPP_dists * 1000,
794794
.f = ~IASDT.R::prepare_knots(
795-
Coords = DT_xy, min_distance = .x, min_LF = min_LF, max_LF = max_LF,
796-
alphapw = alphapw)) %>%
795+
coordinates = DT_xy, min_distance = .x, min_LF = min_LF,
796+
max_LF = max_LF, alphapw = alphapw)) %>%
797797
stats::setNames(paste0("GPP_", GPP_dists))
798798
}
799799

@@ -1001,9 +1001,9 @@ mod_prepare_HPC <- function(
10011001
if (overwrite_rds) {
10021002
IASDT.R::cat_time("Processing all model variants", level = 1)
10031003
} else {
1004-
NMod2Export <- Model_Info %>%
1005-
dplyr::filter(!file.exists(M4HPC_Path)) %>%
1006-
nrow()
1004+
1005+
NMod2Export <- sum(!file.exists(Model_Info$M4HPC_Path))
1006+
10071007
if (NMod2Export == 0) {
10081008
IASDT.R::cat_time(
10091009
"All model variants were already available as RDS files", level = 1)
@@ -1269,7 +1269,7 @@ mod_prepare_HPC <- function(
12691269
f <- file(CommandFile, open = "wb")
12701270
on.exit(invisible(try(close(f), silent = TRUE)), add = TRUE)
12711271
cat(Models2Fit_HPC[IDs[[x]]], sep = "\n", append = FALSE, file = f)
1272-
close(f)
1272+
on.exit(close(f))
12731273
})
12741274

12751275
## # ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

R/mod_variance_partitioning_plot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ variance_partitioning_plot <- function(
461461
ragg::agg_jpeg(
462462
filename = IASDT.R::path(Path_VarPar, "VarPar_Raw_ByTaxonomy.jpeg"),
463463
width = width, height = height, res = 600, quality = 100, units = "cm")
464-
464+
465465
plot(Plot_Raw)
466466
grDevices::dev.off()
467467

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ If you use the `IASDT.R` package, please cite it as:
7474
> <a href="https://biodt.eu" target="_blank">https://biodt.eu</a>.
7575
7676
<span style=" color: grey !important;">Last update:
77-
2025-04-08</span>
77+
2025-04-09</span>

man/IAS_data.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)