Skip to content

Integrate CLI with unit tests #196

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

Open
wants to merge 74 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
1aff592
Read config data from CLI output
soniamitchell Nov 25, 2021
6240df2
delete file
soniamitchell Nov 25, 2021
c529db4
Set up fair CLI
soniamitchell Nov 25, 2021
037a02f
Update documentation
soniamitchell Nov 25, 2021
190e0c7
Start updating test
soniamitchell Nov 25, 2021
b7d66bc
Move files
soniamitchell Nov 25, 2021
0bbee40
Move files
soniamitchell Nov 25, 2021
1815558
Have to keep pushing to keep the registry clean whilst trying to inte…
soniamitchell Nov 25, 2021
e548361
Update tests
soniamitchell Nov 25, 2021
9c3b63e
Fix path
soniamitchell Nov 25, 2021
81f1efa
save path
soniamitchell Nov 25, 2021
51cba3f
Update workflow [skip ci]
soniamitchell Nov 25, 2021
171abe0
Update tests [skip ci]
soniamitchell Nov 25, 2021
ce2a72c
return config file path [skip ci]
soniamitchell Nov 25, 2021
bcc09b6
update tests [skip ci]
soniamitchell Nov 25, 2021
eb4f29f
return config file path [skip ci]
soniamitchell Nov 25, 2021
9f54e6c
update tests [skip ci]
soniamitchell Nov 25, 2021
dad5802
update tests [skip ci]
soniamitchell Nov 25, 2021
8b6738b
update tests [skip ci]
soniamitchell Nov 25, 2021
a7b0448
fix read writes [skip ci]
soniamitchell Nov 25, 2021
4a713da
update tests [skip ci]
soniamitchell Nov 25, 2021
1e33c53
take namespace from config [skip ci]
soniamitchell Nov 25, 2021
8f87a19
update tests [skip ci]
soniamitchell Nov 25, 2021
f6f1603
update tests [skip ci]
soniamitchell Nov 25, 2021
b9b62cc
update tests [skip ci]
soniamitchell Nov 25, 2021
f61a2d7
update tests [skip ci]
soniamitchell Nov 25, 2021
1492d92
update tests [skip ci]
soniamitchell Nov 25, 2021
b2f27dc
remove tests until CLI is fixed [skip ci]
soniamitchell Nov 25, 2021
a5726d9
update tests [skip ci]
soniamitchell Nov 25, 2021
ee7f95f
update tests [skip ci]
soniamitchell Nov 25, 2021
da17fcc
get namespace from config [skip ci]
soniamitchell Nov 25, 2021
8b22e12
update tests [skip ci]
soniamitchell Nov 25, 2021
ac423e8
update tests [skip ci]
soniamitchell Nov 25, 2021
2c3f0e8
edit tests [skip ci]
soniamitchell Nov 25, 2021
442a31f
typo
soniamitchell Nov 25, 2021
e666f66
edit test [skip ci]
soniamitchell Nov 25, 2021
712fd41
edit test [skip ci]
soniamitchell Nov 25, 2021
f9f0f33
edit tests
soniamitchell Nov 25, 2021
e189ebb
edit test [skip ci]
soniamitchell Nov 25, 2021
27296f6
typo
soniamitchell Nov 25, 2021
521258c
edit test [skip ci]
soniamitchell Nov 25, 2021
2f9687d
update tests [skip ci]
soniamitchell Nov 25, 2021
ba8924b
Comment out tests until CLI is fixed [skip ci]
soniamitchell Nov 25, 2021
b4015bf
update tests [skip ci]
soniamitchell Nov 25, 2021
31a21b3
update tests [skip ci]
soniamitchell Nov 25, 2021
f92bec5
comment out tests until CLI is fixed
soniamitchell Nov 25, 2021
234c5cb
fix namespace
soniamitchell Nov 25, 2021
e5a8510
clean repo to test locally [skip ci]
soniamitchell Nov 25, 2021
1b9270f
clean repo to test locally [skip ci]
soniamitchell Nov 25, 2021
3f0e06b
remove file
soniamitchell Nov 28, 2021
a67b6c3
closes #166
soniamitchell Nov 28, 2021
f68750d
update documentation [skip ci]
soniamitchell Nov 28, 2021
d819c41
update documentation [skip ci]
soniamitchell Nov 28, 2021
df97c61
remove examples [skip ci]
soniamitchell Nov 28, 2021
cfdd4a5
edit documentation [skip ci]
soniamitchell Nov 28, 2021
ba4f1b0
Only run `fair init --ci` if `.fair` directory doesn't exist [skip ci]
soniamitchell Nov 28, 2021
3b377d8
Shouldn't need global variable once CLI is updated -- reference `.fai…
soniamitchell Nov 28, 2021
d403115
refactor [skip ci]
soniamitchell Nov 28, 2021
2238042
adding new test -- clean repo to test [skip ci]
soniamitchell Nov 28, 2021
0883ce5
clean repo to test [skip ci]
soniamitchell Nov 28, 2021
33d668e
add comment [skip ci]
soniamitchell Nov 28, 2021
1add109
remove test -- not sure whether the CLI should do this [skip ci]
soniamitchell Nov 28, 2021
a537a9e
Remove dependency
soniamitchell Nov 28, 2021
ccef365
update `print(handle)` [skip ci]
soniamitchell Nov 28, 2021
71aa909
edit messages [skip ci]
soniamitchell Nov 28, 2021
7e67639
update messages [skip ci]
soniamitchell Nov 28, 2021
7f885af
update message [skip ci]
soniamitchell Nov 28, 2021
b52efd6
fix badge
soniamitchell Dec 2, 2022
81a2aeb
Fix CI - can't find master
soniamitchell Dec 2, 2022
4110ed2
Fix CI - update R version
soniamitchell Dec 2, 2022
e7ff347
Fix CI - update R dependencies version
soniamitchell Dec 2, 2022
8e440dd
Fix CI - update versions
soniamitchell Dec 2, 2022
149cb3d
Fix CI - install R API
soniamitchell Dec 2, 2022
8a7ca41
Fix CI - install remotes
soniamitchell Dec 2, 2022
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
4 changes: 2 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2

- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-pandoc@v2

- name: Query dependencies
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-pandoc@master
- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
rcmdcheck
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,31 @@ name: test-coverage

jobs:
test-coverage:
# If the commit message isn't [skip ci]
if: "!contains(github.event.commits[0].message, '[skip ci]')"
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: covr
extra-packages: |
covr
remotes

- name: Install local registry
run: /bin/bash -c "$(curl -fsSL https://data.scrc.uk/static/localregistry.sh)"
- name: Start registry
run: $HOME/.fair/registry/scripts/start_fair_registry

- name: Install R API
run: Rscript -e 'remotes::install_local(upgrade = "never")'

- name: init
run: |
rDataPipeline::fair_init(
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ docs
/config_files
/test
/tests/testthat/test
sonia.yaml
/data_store
sandbox.R
2 changes: 0 additions & 2 deletions CRAN-RELEASE

This file was deleted.

5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Description: R implementation of the 'FAIR Data Pipeline API'. The 'FAIR Data
License: GPL (>= 3)
Imports:
assertthat,
cli,
configr,
dplyr,
git2r,
Expand All @@ -27,7 +26,9 @@ Imports:
yaml
Suggests:
units,
testthat
here,
testthat,
reticulate
biocViews:
rhdf5
Encoding: UTF-8
Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export(find_write_match)
export(findme)
export(get_components)
export(get_dataproduct)
export(get_entry)
export(initialise)
export(link_read)
export(link_write)
Expand All @@ -31,7 +30,6 @@ export(write_estimate)
export(write_table)
import(R6)
import(assertthat, except = has_name)
import(cli)
import(configr)
import(dplyr)
import(httr)
Expand Down
35 changes: 10 additions & 25 deletions R/add_read.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,17 @@
#' Add data product to `read` block of user-written config file. Used in
#' combination with \code{create_config()} for unit testing.
#'
#' @param path config file path
#' @param data_product data_product field
#' @param component component field
#' @param version (optional) version field
#' @param use_data_product (optional) use_data_product field
#' @param use_component (optional) use_component field
#' @param use_version (optional) use_version field
#' @param use_namespace (optional) use_namespace field
#' @param path user-written config.yaml file path
#' @param data_product `data_product:` field
#' @param component `component:` field
#' @param version (optional) `version:` field
#' @param use_data_product (optional) `use: data_product:` field
#' @param use_component (optional) `use: component:` field
#' @param use_version (optional) `use: version:` field
#' @param use_namespace (optional) `use: namespace:` field
#'
#' @export
#'
#' @examples
#' \dontrun{
#' path <- "test_config/config.yaml"
#'
#' # Write run_metadata block
#' create_config(path = path,
#' description = "test",
#' input_namespace = "test_user",
#' output_namespace = "test_user")
#'
#' # Write read block
#' add_read(path = path,
#' data_product = "test/array",
#' component = "level/a/s/d/f/s",
#' version = "0.2.0")
#' }
#' @keywords internal
#'
add_read <- function(path,
data_product,
Expand Down Expand Up @@ -76,4 +60,5 @@ add_read <- function(path,
file = path)
}

invisible(path)
}
42 changes: 15 additions & 27 deletions R/add_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,19 @@
#' Add data product to `read` block of user-written config file. Used in
#' combination with \code{create_config()} for unit testing.
#'
#' @param path config file path
#' @param data_product data_product field
#' @param description component field
#' @param version (optional) version field
#' @param file_type (optional) file type field
#' @param use_data_product (optional) use_data_product field
#' @param use_component (optional) use_component field
#' @param use_version (optional) use_version field
#' @param use_namespace (optional) use_namespace field
#' @param path user-written config.yaml file path
#' @param data_product `data_product:` field
#' @param description `component:` field
#' @param version (optional) `version:` field
#' @param file_type (optional) `file_type:` field
#' @param use_data_product (optional) `use: data_product:` field
#' @param use_component (optional) `use: component:` field
#' @param use_version (optional) `use: version:` field
#' @param use_namespace (optional) `use: namespace:` field
#' @param use_public (optional) `use: public:` field
#'
#' @export
#'
#' @examples
#' \dontrun{
#' path <- "test_config/config.yaml"
#'
#' # Write run_metadata block
#' create_config(path = path,
#' description = "test",
#' input_namespace = "test_user",
#' output_namespace = "test_user")
#'
#' # Write read block
#' add_write(path = path,
#' data_product = "test/array",
#' description = "data product description",
#' version = "0.2.0")
#' }
#' @keywords internal
#'
add_write <- function(path,
data_product,
Expand All @@ -40,7 +25,8 @@ add_write <- function(path,
use_data_product,
use_component,
use_version,
use_namespace) {
use_namespace,
use_public) {

# Generate write block
new_write <- list()
Expand All @@ -53,6 +39,7 @@ add_write <- function(path,
if (!missing(use_component)) new_write$use$component <- use_component
if (!missing(use_version)) new_write$use$version <- use_version
if (!missing(use_namespace)) new_write$use$namespace <- use_namespace
if (!missing(use_public)) new_write$use$public <- use_public

# Read file contents
contents <- configr::read.config(file = path)
Expand All @@ -79,4 +66,5 @@ add_write <- function(path,
file = path)
}

invisible(path)
}
2 changes: 2 additions & 0 deletions R/check_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#' @param data_product data_product
#' @param what what
#'
#' @noRd
#'
check_config <- function(handle, data_product, what) {

error <- paste(usethis::ui_field(data_product), "missing from config file")
Expand Down
2 changes: 2 additions & 0 deletions R/check_dataproduct_exists.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#' @param write_namespace_id write_namespace_id
#' @param endpoint endpoint
#'
#' @noRd
#'
check_dataproduct_exists <- function(write_dataproduct,
write_version,
write_namespace_id,
Expand Down
2 changes: 2 additions & 0 deletions R/check_datetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#' @param query_class a \code{string} specifying the class of the field
#' @param this_query a \code{string} specifying the contents of the field
#'
#' @noRd
#'
check_datetime <- function(table,
this_field,
query_class,
Expand Down
1 change: 1 addition & 0 deletions R/check_exists.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#'
#' @return Returns \code{TRUE} if the entry exists and \code{FALSE} if it
#' doesn't
#' @noRd
#'
check_exists <- function(table,
query) {
Expand Down
2 changes: 2 additions & 0 deletions R/check_field.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#' @param method a \code{string} specifying the method, c("GET", "POST")
#' @param endpoint endpoint
#'
#' @noRd
#'
check_field <- function(table,
this_field,
query_class,
Expand Down
2 changes: 2 additions & 0 deletions R/check_fields.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#' @param method a \code{string} specifying the method, c("GET", "POST")
#' @param endpoint endpoint
#'
#' @noRd
#'
check_fields <- function(table, query, method, endpoint) {

fields <- names(query)
Expand Down
2 changes: 2 additions & 0 deletions R/check_handle.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#' @param what element in handle -- one of c("inputs", "outputs")
#' @param component a \code{string} specifying the name of the component
#'
#' @noRd
#'
check_handle <- function(handle, data_product, what, component) {

# link_read() / link_write() functions
Expand Down
2 changes: 2 additions & 0 deletions R/check_integer.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#' @param query_class a \code{string} specifying the class of the field
#' @param this_query a \code{string} specifying the contents of the field
#'
#' @noRd
#'
check_integer <- function(table,
this_field,
query_class,
Expand Down
2 changes: 2 additions & 0 deletions R/check_local_repo.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#' check_local_repo
#'
#' @param path Local repository file path
#'
#' @return \code{boolean}, if local repository is clean (TRUE, else FALSE)
#' @noRd
#'
check_local_repo <- function(path) {
if (grepl("^~", path)) path <- gsub("^~", "", path)
Expand Down
2 changes: 2 additions & 0 deletions R/check_string.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#' @param this_field a \code{string} specifying the name of the field
#' @param this_query a \code{string} specifying the contents of the field
#'
#' @noRd
#'
check_string <- function(table,
this_field,
this_query) {
Expand Down
1 change: 1 addition & 0 deletions R/check_table_exists.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' @param table a \code{string} specifying the name of the table
#'
#' @return Returns \code{TRUE} if a table exists, \code{FALSE} if it doesn't
#' @noRd
#'
check_table_exists <- function(table) {
if (!is.character(table))
Expand Down
2 changes: 2 additions & 0 deletions R/check_yaml_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#' @param handle \code{fdp} object
#' @param data_product a \code{string} specifying the name of the data product
#'
#' @noRd
#'
check_yaml_write <- function(handle, data_product) {

endpoint <- handle$yaml$run_metadata$local_data_registry_url
Expand Down
42 changes: 21 additions & 21 deletions R/class-fdp.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#'
#' @name fdp-class
#' @rdname fdp-class
#' @keywords internal
#'
fdp <- R6::R6Class("fdp", list(
#' @field yaml a \code{list} containing the contents of the working
Expand Down Expand Up @@ -85,32 +86,31 @@ fdp <- R6::R6Class("fdp", list(
#'
print = function(...) {

contains_yaml <- !is.null(self$yaml)
contains_dir <- !is.null(self$fdp_config_dir)
contains_config <- !is.null(self$model_config)
contains_script <- !is.null(self$submission_script)
contains_coderun <- !is.null(self$code_run)

cat("Contains:\n")
if (contains_yaml) cat("- Config file\n")
if (contains_dir) cat("- Config dir\n")
if (contains_config) cat("- Config file URL\n")
if (contains_script) cat("- Submission script URL\n")
if (contains_coderun) cat("- Code run URL\n")

if (!is.null(self$inputs)) {
cat("\n\n", "Inputs:", "\n")
if (!is.null(self$yaml)) {
msg <- "Code run: {ui_value(self$yaml$run_metadata$description)}"
usethis::ui_info(msg)
}

if (is.null(self$inputs)) {
msg <- "None"
usethis::ui_info("Inputs: {ui_value(msg)}")

} else {
usethis::ui_info("Inputs:")
self$inputs %>%
dplyr::select(data_product) %>%
print()
}

if (!is.null(self$outputs)) {
cat("\n\n", "outputs:", "\n")
tmp <- self$outputs %>%
dplyr::select(use_component, use_data_product, use_version)
names(tmp) <- gsub("use_", "", names(tmp))
print(tmp)
if (is.null(self$outputs)) {
msg <- "None"
usethis::ui_info("Outputs: {ui_value(msg)}")

} else {
usethis::ui_info("Outputs:")
self$outputs %>%
dplyr::select(use_data_product, use_component, use_version) %>%
print()
}

invisible(self)
Expand Down
Loading