Swap RMySQL for RMariaDB

pull/103/head
JulioV 2020-12-04 14:57:13 -05:00
parent 5baaa94092
commit 9a02e93b25
7 changed files with 52 additions and 24 deletions

View File

@ -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
```

View File

@ -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",

View File

@ -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"

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)