From 9a02e93b25190c8d88d77312b3509122e034e7b7 Mon Sep 17 00:00:00 2001 From: JulioV Date: Fri, 4 Dec 2020 14:57:13 -0500 Subject: [PATCH] Swap RMySQL for RMariaDB --- docs/developers/virtual-environments.md | 34 +++++++++++++------ renv.lock | 22 +++++++++--- src/data/create_participants_files.R | 4 +-- src/data/download_fitbit_data.R | 4 +-- src/data/download_phone_data.R | 4 +-- .../download_demographic_data.R | 4 +-- .../workflow_example/download_target_data.R | 4 +-- 7 files changed, 52 insertions(+), 24 deletions(-) diff --git a/docs/developers/virtual-environments.md b/docs/developers/virtual-environments.md index 89ab96d1..f0b5eb02 100644 --- a/docs/developers/virtual-environments.md +++ b/docs/developers/virtual-environments.md @@ -1,21 +1,35 @@ -# Virtual Environments +## Python Virtual Environment -## Add new packages +### Add new packages -Try to install any new package using `conda`. If a package is not available in one of `conda`'s channels you can install it with `pip` but make sure your virtual environment is active. +Try to install any new package using `conda install -c CHANNEL PACKAGE_NAME` (you can use `pip` if the package is only available there). Make sure your Python virtual environment is active (`conda activate YOUR_ENV`). -## Update your conda `environment.yaml` +### Remove packages +Uninstall packages using the same manager you used to install them `conda remove PACKAGE_NAME` or `pip uninstall PACKAGE_NAME` -After installing a new package you can use the following command in your terminal to update your `environment.yaml` before publishing your pipeline. Note that we ignore the package version for `libfortran` to keep compatibility with Linux: +### Update your conda `environment.yaml` +After installing or removing a package you can use the following command in your terminal to update your `environment.yaml` before publishing your pipeline. Note that we ignore the package version for `libfortran` to keep compatibility with Linux: ```bash conda env export --no-builds | sed 's/^.*libgfortran.*$/ - libgfortran/' > environment.yml ``` -## Update and prune your conda environment from a `environment.yaml` file +## R Virtual Environment -Execute the following command in your terminal, see these docs for more [information](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#updating-an-environment) +### Add new packages +1. Open your terminal and navigate to RAPIDS' root folder +2. Run `R` to open an R interactive session +3. Run `renv::install("PACKAGE_NAME")` + +### Remove packages +1. Open your terminal and navigate to RAPIDS' root folder +2. Run `R` to open an R interactive session +3. Run `renv::remove("PACKAGE_NAME")` + +### Update your R `renv.lock` +After installing or removing a package you can use the following command in your terminal to update your `renv.lock` before publishing your pipeline. + +1. Open your terminal and navigate to RAPIDS' root folder +2. Run `R` to open an R interactive session +3. Run `renv::snapshot()` (renv will ask you to confirm any updates to this file) -```bash -conda env update --prefix ./env --file environment.yml --prune -``` diff --git a/renv.lock b/renv.lock index 61cc6db0..e20ff9f0 100644 --- a/renv.lock +++ b/renv.lock @@ -86,12 +86,12 @@ "Repository": "CRAN", "Hash": "e031418365a7f7a766181ab5a41a5716" }, - "RMySQL": { - "Package": "RMySQL", - "Version": "0.10.20", + "RMariaDB": { + "Package": "RMariaDB", + "Version": "1.0.10", "Source": "Repository", "Repository": "CRAN", - "Hash": "022066398851453f187950137e21daad" + "Hash": "d149479ea03e5cbb1e788449ef5e04b4" }, "Rcpp": { "Package": "Rcpp", @@ -156,6 +156,20 @@ "Repository": "CRAN", "Hash": "543776ae6848fde2f48ff3816d0628bc" }, + "bit": { + "Package": "bit", + "Version": "4.0.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f36715f14d94678eea9933af927bc15d" + }, + "bit64": { + "Package": "bit64", + "Version": "4.0.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "9fe98599ca456d6552421db0d6772d8f" + }, "boot": { "Package": "boot", "Version": "1.3-24", diff --git a/src/data/create_participants_files.R b/src/data/create_participants_files.R index c1f3f8d8..0aba554f 100644 --- a/src/data/create_participants_files.R +++ b/src/data/create_participants_files.R @@ -1,6 +1,6 @@ source("renv/activate.R") -library(RMySQL) +library(RMariaDB) library(stringr) library(purrr) library(readr) @@ -19,7 +19,7 @@ fitbit_ignored = config$FITBIT_SECTION$IGNORED_DEVICE_IDS rmysql.settingsfile <- "./.env" if(config$SOURCE$TYPE == "AWARE_DEVICE_TABLE"){ - database <- dbConnect(MySQL(), default.file = rmysql.settingsfile, group = group) + database <- dbConnect(MariaDB(), default.file = rmysql.settingsfile, group = group) if(config$FITBIT_SECTION$ADD == TRUE){ query <- paste("SELECT",phone_device_id_column, ",",fitbit_device_id_column," as _temp_fitbit_id, brand, label, timestamp FROM aware_device order by timestamp asc") fitbit_device_id_column <- "_temp_fitbit_id" diff --git a/src/data/download_fitbit_data.R b/src/data/download_fitbit_data.R index e42b8b55..54ac4346 100644 --- a/src/data/download_fitbit_data.R +++ b/src/data/download_fitbit_data.R @@ -1,5 +1,5 @@ source("renv/activate.R") -library(RMySQL) +library(RMariaDB) library("dplyr", warn.conflicts = F) library(readr) library(stringr) @@ -23,7 +23,7 @@ unified_device_id <- tail(device_ids, 1) # As opposed to phone data, we dont' filter by date here because data can still be in JSON format, we need to parse it first if(source$TYPE == "DATABASE"){ - dbEngine <- dbConnect(MySQL(), default.file = "./.env", group = source$DATABASE_GROUP) + dbEngine <- dbConnect(MariaDB(), default.file = "./.env", group = source$DATABASE_GROUP) query <- paste0("SELECT * FROM ", table, " WHERE ",source$DEVICE_ID_COLUMN," IN ('", paste0(device_ids, collapse = "','"), "')") sensor_data <- dbGetQuery(dbEngine, query) dbDisconnect(dbEngine) diff --git a/src/data/download_phone_data.R b/src/data/download_phone_data.R index 29ee8d09..0b749a8b 100644 --- a/src/data/download_phone_data.R +++ b/src/data/download_phone_data.R @@ -1,6 +1,6 @@ source("renv/activate.R") source("src/data/unify_utils.R") -library(RMySQL) +library(RMariaDB) library(stringr) library("dplyr", warn.conflicts = F) library(readr) @@ -80,7 +80,7 @@ platforms <- participant$PHONE$PLATFORMS validate_deviceid_platforms(device_ids, platforms) timestamp_filter <- get_timestamp_filter(device_ids, participant, timezone) -dbEngine <- dbConnect(MySQL(), default.file = "./.env", group = group) +dbEngine <- dbConnect(MariaDB(), default.file = "./.env", group = group) if(is_multiplaform_participant(dbEngine, device_ids, platforms)){ sensor_data <- unify_raw_data(dbEngine, table, sensor, timestamp_filter, aware_multiplatform_tables, device_ids, platforms) diff --git a/src/data/workflow_example/download_demographic_data.R b/src/data/workflow_example/download_demographic_data.R index ecfa2d40..0adb1086 100644 --- a/src/data/workflow_example/download_demographic_data.R +++ b/src/data/workflow_example/download_demographic_data.R @@ -1,5 +1,5 @@ source("renv/activate.R") -library(RMySQL) +library(RMariaDB) library("dplyr", warn.conflicts = F) library(readr) library(stringr) @@ -14,7 +14,7 @@ sensor_file <- snakemake@output[[1]] participant <- read_yaml(participant_file) record_id <- participant$PHONE$LABEL -dbEngine <- dbConnect(MySQL(), default.file = "./.env", group = source$DATABASE_GROUP) +dbEngine <- dbConnect(MariaDB(), default.file = "./.env", group = source$DATABASE_GROUP) query <- paste0("SELECT * FROM ", table, " WHERE record_id = '", record_id, "'") sensor_data <- dbGetQuery(dbEngine, query) dbDisconnect(dbEngine) diff --git a/src/data/workflow_example/download_target_data.R b/src/data/workflow_example/download_target_data.R index 22e6d892..19ffa8d9 100644 --- a/src/data/workflow_example/download_target_data.R +++ b/src/data/workflow_example/download_target_data.R @@ -1,5 +1,5 @@ source("renv/activate.R") -library(RMySQL) +library(RMariaDB) library("dplyr", warn.conflicts = F) library(readr) library(stringr) @@ -15,7 +15,7 @@ sensor_file <- snakemake@output[[1]] participant <- read_yaml(participant_file) record_id <- participant$PHONE$LABEL -dbEngine <- dbConnect(MySQL(), default.file = "./.env", group = source$DATABASE_GROUP) +dbEngine <- dbConnect(MariaDB(), default.file = "./.env", group = source$DATABASE_GROUP) query <- paste0("SELECT * FROM ", table, " WHERE record_id = '", record_id, "'") sensor_data <- dbGetQuery(dbEngine, query) dbDisconnect(dbEngine)