Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
Damonamajor committed Aug 8, 2024
1 parent 67fcb5d commit 7bf6541
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
26 changes: 19 additions & 7 deletions analyses/Analysis_helpers.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
model_fetch_run_subset <- function(run_id, year, analyses_paths, append_run_id = FALSE) {
model_fetch_run_subset <- function(run_id, year,

Check warning on line 1 in analyses/Analysis_helpers.R

View workflow job for this annotation

GitHub Actions / pre-commit

file=/home/runner/work/model-res-avm/model-res-avm/analyses/Analysis_helpers.R,line=1,col=1,[cyclocomp_linter] Functions should have cyclomatic complexity of less than 15, this has 18.
analyses_paths, append_run_id = FALSE) {
tictoc::tic(paste0("Fetched run: ", run_id))

s3_objs <- grep("s3://", unlist(analyses_paths$output), value = TRUE)
Expand All @@ -9,11 +10,15 @@ model_fetch_run_subset <- function(run_id, year, analyses_paths, append_run_id =
for (analyses_path in analyses_paths$output) {
is_directory <- endsWith(analyses_path$s3, "/")
if (is_directory) {
partitioned_by_run <- endsWith(analyses_path$s3, paste0("run_id=", run_id, "/"))
partitioned_by_run <- endsWith(
analyses_path$s3, paste0("run_id=", run_id, "/")
)
if (partitioned_by_run) {
dir_path <- analyses_path$s3
} else {
dir_path <- paste0(analyses_path$s3, "year=", year, "/run_id=", run_id, "/")
dir_path <- paste0(
analyses_path$s3, "year=", year, "/run_id=", run_id, "/"
)
}

message("Now fetching: ", dir_path)
Expand Down Expand Up @@ -47,10 +52,18 @@ model_fetch_run_subset <- function(run_id, year, analyses_paths, append_run_id =
} else {
message("Now fetching: ", analyses_path$s3)
if (aws.s3::object_exists(analyses_path$s3, bucket = bucket)) {
local_temp_path <- file.path(tempdir(), basename(analyses_path$s3))
aws.s3::save_object(analyses_path$s3, bucket = bucket, file = local_temp_path)
local_temp_path <- file.path(
tempdir(),
basename(analyses_path$s3)
)
aws.s3::save_object(analyses_path$s3,
bucket = bucket, file = local_temp_path
)
if (append_run_id) {
data_list[[paste0(analyses_path$key, "_", run_id)]] <- arrow::read_parquet(local_temp_path)
data_list[[paste0(
analyses_path$key, "_",
run_id
)]] <- arrow::read_parquet(local_temp_path)
} else {
data_list[[analyses_path$key]] <- arrow::read_parquet(local_temp_path)
}
Expand All @@ -64,7 +77,6 @@ model_fetch_run_subset <- function(run_id, year, analyses_paths, append_run_id =
return(data_list)
}


rename_var <- function(var_name, suffix, new_suffix) {
if (exists(var_name) && is.data.frame(get(var_name))) {
if (grepl(paste0("_", suffix, "$"), var_name)) {
Expand Down
2 changes: 1 addition & 1 deletion analyses/new-feature-template.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ create_summary_table(pin_individual, target_feature = {{ target_feature_value }}
::: {.panel-tabset}


```{r. histogram_function}
```{r, histogram_function}
create_histogram_with_statistics <- function(data, target_feature, x_label, y_label = "Frequency", filter_outliers = FALSE, filter_column = NULL) {
# Conditionally filter outliers if requested
if (filter_outliers && !is.null(filter_column)) {
Expand Down

0 comments on commit 7bf6541

Please sign in to comment.