biobricks-ai / biobricks-issues

A repo for consolidating issues
1 stars 2 forks source link

run bricktools on all current bricks #8

Closed jborden closed 2 years ago

achatrath commented 2 years ago

Here are the instructions for running bricktools:

  1. Install the package as follows:

devtools::install_github("biobricks-ai/bricktools")

  1. The function can be called using:

bricktools::check_brick(dir)

where dir is the path of the directory for the brick. The function will print out whether or not dir meets each of the requirements for a brick based on our typical format.

For example:

`bricktools::check_brick("clinvar")

`[1] "The directory clinvar exists: TRUE." [1] "The file clinvar/dvc.yaml exists: TRUE." [1] "The file clinvar/dvc.yaml is not empty: TRUE." [1] "The file clinvar/dvc.lock exists: TRUE." [1] "The file clinvar/dvc.lock is not empty: TRUE." [1] "The file clinvar/.dvc/config exists: TRUE." [1] "The file clinvar/.dvc/config is not empty: TRUE." [1] "The file clinvar/README.md exists: TRUE." [1] "The file clinvar/README.md is not empty: TRUE." [1] TRUE

A functioning brick should pass all of the checks above. The function will return TRUE if all checks are passed for a given directory. It should be relatively easy to put into a loop to check all of the bricks in biobricks.

achatrath commented 2 years ago

You can try running something simple like this:

# devtools::install_github("biobricks-ai/bricktools")
bricks <- list.files()
brick_check = lapply(bricks, FUN=bricktools::check_brick)
result = as.data.frame(cbind(directories, brick_check), stringsAsFactors=FALSE)
print(result)
image
jborden commented 2 years ago

thanks!

jborden commented 2 years ago
library(bricktools)
library(fs)
library(purrr)

context="orgs"
org="biobricks-ai"
page=1
# Clone all Repos
stringr::str_interp('curl "https://api.github.com/${context}/${org}/repos?page=${page}&per_page=100" |
    grep -e \"clone_url\" |
    cut -d \\" -f 4 | xargs -L1 git clone') |> 
    system()

bricks <- fs::dir_ls(type = "directory") |>
    purrr::discard(~ .x %in% c("biobricks-r", "biobricks-issues", "bricktools"))
brick_check <- lapply(bricks, FUN = bricktools::valid)

result <- as.data.frame(cbind(bricks, brick_check), stringsAsFactors = FALSE)
print(result)

errors <- bricks |>
    map(bricktools::errors) |>
    purrr::discard(~ .x |>
        names() |>
        length() == 0)

errors |>
    names() |>
    walk(~ {
        sprintf("Brick %s errors:", .x) |> cat()
        cat("\n")
        errors[[.x]] |>
            stringr::str_flatten(collapse = "\n") |>
            cat()
        cat("\n\n")
    })

you can run this in an empty dir (for example, /tmp/biobricks-ai) to see which repos are passing and what each repos errors are