Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remotes cleanup refactoring, code cleanup & bug fixing #28

Merged
merged 59 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a80dbc2
chore: add reusable function to determine package version from descri…
averissimo Jul 24, 2023
f1adec1
chore: cleanup and documentation improvement
averissimo Jul 25, 2023
b6c8ddd
fix: test compatibility with current strategies
averissimo Jul 17, 2023
3ab80f7
tests: Adds encapsulation tests for min_isolated strategy
averissimo Jul 17, 2023
78352d9
chore: reverts suppress messages and correct CHECK problems with subset
averissimo Jul 17, 2023
793f21d
chore: lint corrections
averissimo Jul 18, 2023
7a2e65d
chore: simplifies code
averissimo Jul 25, 2023
11c267b
chore: remove browser() call and update logic to use already implemen…
averissimo Jul 25, 2023
6cc7222
use numeric package versioning to be more permissible
averissimo Jul 25, 2023
5c27947
feat: add functions that test the install of multiple versions of a p…
averissimo Jul 25, 2023
776134f
fix: cohort problem with Bioc pkgs not having a published date
averissimo Jul 26, 2023
c93644b
fix: adds httr dep and uses official metadata from bioc
averissimo Jul 26, 2023
6453e8a
fix: replace bioc general release by last modified date from source
averissimo Jul 26, 2023
b0ec8d8
chore: refactor desc_field cleanup so it depends only on desc
averissimo Aug 1, 2023
ecce629
chore: adds tests for local_description and documentation
averissimo Aug 1, 2023
bb91882
chore: added 1 more test
averissimo Aug 1, 2023
2a63d94
ci: test check ci, to be reverted
averissimo Aug 1, 2023
535b7b0
Revert "ci: test check ci, to be reverted"
averissimo Aug 1, 2023
0bd24ee
fix: corrects a bunch of problems with R CMD check
averissimo Aug 1, 2023
38c06cb
ci: test check ci, to be reverted
averissimo Aug 1, 2023
ecde252
Merge 38c06cb1e44a54cddda898bccc961df9ad53257c into ad404d1ed6495f556…
averissimo Aug 1, 2023
999714e
[skip actions] Restyle files
github-actions[bot] Aug 1, 2023
1bbd883
chore: correct spelling and replace rlang call
averissimo Aug 1, 2023
70f6869
cleanup: remove feature from branch
averissimo Aug 1, 2023
1c957af
chore: cleanup
averissimo Aug 2, 2023
03bc473
[skip actions] Roxygen Man Pages Auto Update
github-actions[bot] Aug 2, 2023
e3a18d4
clean: cleanup of function that is only called once
averissimo Aug 8, 2023
5b71394
Apply suggestions from code review
averissimo Aug 8, 2023
7a094f2
[skip actions] Roxygen Man Pages Auto Update
github-actions[bot] Aug 8, 2023
a5be19b
chore: update examples to use dplyr/rlang
averissimo Aug 8, 2023
e3ffda0
dplyr in examples; pre-commit
pawelru Aug 8, 2023
fc94e3d
chore: remove bioc download method in favor of fallback to latest CRAN
averissimo Aug 12, 2023
157b6ad
fix: defaults to latest snapshot for Bioc packages
averissimo Aug 16, 2023
b3f7de2
fix: fix naming convention of function
averissimo Aug 16, 2023
bc0730b
tests: adds test suites and fixes a hardcoded string
averissimo Aug 16, 2023
16929bf
Merge bc0730be249aa70389125ac64373d9b1870ffc87 into ad404d1ed6495f556…
averissimo Aug 16, 2023
eec97b1
[skip actions] Restyle files
github-actions[bot] Aug 16, 2023
a9926e3
fix: corrects bugs found during tests
averissimo Aug 16, 2023
0819cbd
chore: document
averissimo Aug 17, 2023
49e4e8b
chore: remove httr dependency
averissimo Aug 17, 2023
783d755
fix: corrects typo on test
averissimo Aug 17, 2023
bd256b8
alphabetical order in pre-commit config
pawelru Aug 17, 2023
4a3236c
remove duplicates prior solving min_isolated
pawelru Aug 17, 2023
0719bdd
fix: issue in test_common and code cleanup
averissimo Aug 18, 2023
28b2dca
fix: bunch of corrections on cohort and code
averissimo Aug 18, 2023
74332e0
clean-up importFrom; add withr to pkg imports
pawelru Aug 21, 2023
6d22e75
add stats::na.omit to namespace
pawelru Aug 21, 2023
2074a76
fix: failure to resolve package should raise error later in the process
averissimo Aug 21, 2023
7ce8e09
chore: remove unnecessary parameter
averissimo Aug 21, 2023
99b0dc2
Apply suggestions from code review
averissimo Aug 21, 2023
95f7989
chore: change order of arguments and tests update
averissimo Aug 21, 2023
d72747d
chore: change order of arguments and tests update
averissimo Aug 21, 2023
fce38e3
chore: remove unnecessary NA as argument can be of length 0 or a date
averissimo Aug 21, 2023
d11385b
fix: small improvement on dealing with NA dates
averissimo Aug 21, 2023
9190f74
fix: enforce class on get_release_date methods output
averissimo Aug 22, 2023
826ddf5
add withr to pre-commit
pawelru Aug 24, 2023
68cb7eb
use map_key_character in other places
pawelru Aug 24, 2023
a0b01a5
add Andre to authors; Roche cph and fnd; LICENSE
pawelru Aug 24, 2023
ecbdc98
fix DESCRIPTION file
pawelru Aug 24, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- ready_for_review
branches:
- main
- training
push:
branches:
- main
Expand Down
18 changes: 10 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ repos:
args: [--style_pkg=styler, --style_fun=tidyverse_style]
- id: roxygenize
additional_dependencies:
- r-lib/cli@*release
- r-lib/desc@*release
- r-lib/gh@*release
- r-lib/pkgcache@*release
- r-lib/pkgdepends@*release
- r-lib/rcmdcheck@*release
- r-lib/remotes@*release
- cli
- desc
- gh
- httr
pawelru marked this conversation as resolved.
Show resolved Hide resolved
- knitr
- pkgcache
- pkgdepends
- rcmdcheck
- remotes
- stats
- utils
- r-lib/zip@*release
# codemeta must be above use-tidy-description when both are used
# - id: codemeta-description-updated
- id: use-tidy-description
Expand Down
150 changes: 0 additions & 150 deletions R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,156 +97,6 @@ execute_ip <- function(ip, path, build_args, check_args, ...) {
return(invisible(list(ip = ip, check = check_res)))
}


#' Try to solve using standard method. If error - use [resolve_ignoring_release_remote].
#'
#' @inheritParams check_ip
#'
#' @returns `pkg_installation_plan` object invisibly
#'
#' @export
solve_ip <- function(ip) {
UseMethod("solve_ip", ip)
}
#' @exportS3Method solve_ip deps_installation_proposal
solve_ip.deps_installation_proposal <- function(ip) {
ip$solve()
resolve_ignoring_release_remote(ip)
}

#' For each direct dependency, resolve that package using PPM snapshot as of release date + 1.
#' Finally, combine resolutions and run solve.
#' @keywords internal
#' @exportS3Method solve_ip min_isolated_deps_installation_proposal
solve_ip.min_isolated_deps_installation_proposal <- function(ip) { # nolint
ip$resolve()
res <- ip$get_resolution()

deps <- res[1, "deps"][[1]]
## copy op and version to Config\Needs\verdepcheck rows
deps <- split(deps, as.factor(deps$package))
deps <- lapply(deps, function(x) {
x$op <- x$op[1]
x$version <- x$version[1]
x
})
deps <- do.call(rbind, deps)
deps <- deps[tolower(deps$type) %in% tolower(res[1, "dep_types"][[1]]), ]

# Avoid repeating calls to resolve_ppm_snapshot
deps <- deps[!duplicated(deps[, c("ref", "op", "version")]), ]

cli_pb_init("min_isolated", total = nrow(deps))

deps_res <- lapply(seq_len(nrow(deps)), function(i) {
i_pkg <- deps[i, "package"]

cli_pb_update(package = i_pkg, n = 4L)

if (i_pkg %in% base_pkgs()) {
return(NULL)
}

resolve_ppm_snapshot(deps[i, "ref"], deps[i, "op"], deps[i, "version"])
})

new_res <- do.call(rbind, deps_res)

# Keep only top versions in calculated resolution (new_res).
# Very large resolution tables can become problematic and taking a long in reaching
# a solution. If
new_res <- new_res[order(new_res$ref, package_version(new_res$version), decreasing = TRUE), ]
new_res <- new_res[!duplicated(new_res[, c("ref")]), ]

# Keep res at top
new_res <- rbind(res[1:2, ], new_res)

ip$.__enclos_env__$private$plan$.__enclos_env__$private$resolution$result <- new_res
ip$solve()

resolve_ignoring_release_remote(ip)

return(invisible(ip))
}

#' If solution errors finishes with "dependency conflict" error then
#' re-try again ignoring "@*release" remote refs for detected conflicts.
#'
#' @inheritParams check_ip
#'
#' @inherit solve_ip return
#'
#' @keywords internal
resolve_ignoring_release_remote <- function(ip) { # nolint
tryCatch(
ip$stop_for_solution_error(),
error = function(e) {
if (!grepl("*.dependency conflict$", e$message)) stop(e)
cat("Solve using alternative method ignoring `@*release` for conflicting refs.\n")
solve_ip_ignore_remotes_release(ip)
ip$stop_for_solution_error()
}
)
return(invisible(ip))
}

#' Solve installation plan ignoring entries with "@*release" remote refs for detected conflicts.
#'
#' @inheritParams check_ip
#'
#' @inherit solve_ip return
#'
#' @keywords internal
solve_ip_ignore_remotes_release <- function(ip) { # nolint
# replace "@*release" GH refs to the "@<ref for min ver>" for all direct dependent pkgs to avoid conflicts
# use case:
# foo -imports-> bar (>= 1.2.3) & baz (>= 1.2.3) (and has bar@*release and baz@*release in its Remotes)
# bar -imports-> baz (and has baz@*release in its Remotes)
# when doing min_deps we identify min version of baz to be 1.2.3
# there is a conflict between baz@1.2.3 and baz@*release

if (is.null(ip$.__enclos_env__$private$plan$.__enclos_env__$private$resolution$result)) ip$resolve()

conflicting_pkgs <- resolution <- ip$get_resolution()

conflicting_pkgs <- split(resolution, as.factor(conflicting_pkgs$package))
conflicting_pkgs <- Filter(function(x) any(grepl("\\@\\*release", x$ref)), conflicting_pkgs)
conflicting_pkgs <- Filter(function(x) length(unique(x$ref)) > 1, conflicting_pkgs)

conflicting_pkgs_refs <- lapply(
conflicting_pkgs,
function(x) {
c(
package = x$package[1],
old_ref = grep("\\@\\*release", x$ref, value = TRUE)[1],
new_ref = grep("\\@\\*release", x$ref, value = TRUE, invert = TRUE)[1]
)
}
)
conflicting_pkgs_refs <- data.frame(do.call(rbind, conflicting_pkgs_refs), row.names = NULL)

replace_using_df <- function(x, df) {
for (i in seq_len(nrow(df))) {
x <- replace(x, x == df[i, 1], df[i, 2])
}
x
}
for (i in seq_len(nrow(resolution))) {
i_deps <- resolution[i, "deps"][[1]]
if (any(i_deps$package %in% conflicting_pkgs_refs$package)) {
i_deps$ref <- replace_using_df(i_deps$ref, conflicting_pkgs_refs[, c("old_ref", "new_ref")])
}
resolution[i, "deps"] <- list(list(i_deps))
}

ip$.__enclos_env__$private$plan$.__enclos_env__$private$resolution$result <- resolution

ip$solve()

return(invisible(ip))
}


averissimo marked this conversation as resolved.
Show resolved Hide resolved
#' Solve installation plan ignoring entries with "@*release" remote refs for detected conflicts.
#'
#' @inheritParams check_ip
Expand Down
Loading
Loading