Skip to content

Commit

Permalink
Fix global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
FBerding committed Jan 19, 2024
1 parent 62d6d04 commit e9ab854
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 28 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Imports:
Rcpp (>= 1.0.10),
reshape2,
reticulate (>= 1.34.0),
rlang,
smotefamily,
stringr,
stringi,
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ importFrom(readxl,read_xlsx)
importFrom(reticulate,conda_create)
importFrom(reticulate,py_install)
importFrom(reticulate,py_module_available)
importFrom(rlang,.data)
importFrom(shinyjs,html)
importFrom(shinyjs,useShinyjs)
importFrom(stats,na.omit)
Expand All @@ -66,6 +67,9 @@ importFrom(stringr,str_length)
importFrom(stringr,str_remove_all)
importFrom(stringr,str_replace_all)
importFrom(utils,compareVersion)
importFrom(utils,packageVersion)
importFrom(utils,read.csv)
importFrom(utils,read.csv2)
importFrom(utils,write.csv)
importFrom(utils,write.csv2)
useDynLib(aifeducation, .registration = TRUE)
57 changes: 31 additions & 26 deletions R/aif_gui.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
#'@importFrom stringi stri_split_regex
#'@importFrom stringi stri_trans_tolower
#'@importFrom stringr str_extract_all
#'@importFrom utils packageVersion
#'@importFrom utils read.csv2
#'@importFrom utils write.csv2
#'@importFrom rlang .data
#'
#'
#'@export
start_aifeducation_studio<-function(){
Expand Down Expand Up @@ -841,7 +846,7 @@ start_aifeducation_studio<-function(){

for(i in 1:nrow(r_packages_table)){
r_packages_table[i,1]<-r_packages_names[[i]]
r_packages_table[i,2]<-as.character(packageVersion(r_packages_names[[i]]))
r_packages_table[i,2]<-as.character(utils::packageVersion(r_packages_names[[i]]))
}
colnames(r_packages_table)=c("Package","Version")

Expand Down Expand Up @@ -2313,7 +2318,7 @@ start_aifeducation_studio<-function(){
model=try(load_ai_model(model_dir = model_path,
ml_framework=input$config_ml_framework),
silent = TRUE)
if(("try-error"%in%class(model))==FALSE){
if(is(model,class2 = "try-error")==FALSE){
if("TextEmbeddingModel"%in%class(model)){
if(utils::compareVersion(as.character(model$get_package_versions()$aifeducation),"0.3.1")>=0){
closeSweetAlert()
Expand Down Expand Up @@ -2544,7 +2549,7 @@ start_aifeducation_studio<-function(){
n_solutions=input$lm_n_fillments_for_fill_mask),
silent = TRUE)

if(class(solutions)!="try-error"){
if(is(solutions,class2 = "try-error")==FALSE){
updateNumericInput(inputId = "lm_select_mask_for_fill_mask",
max=length(solutions))

Expand Down Expand Up @@ -2812,7 +2817,7 @@ start_aifeducation_studio<-function(){
type="info")
model=try(load_ai_model(model_dir = lm_interface_for_documentation_path(),
ml_framework=input$config_ml_framework),silent = TRUE)
if(("try-error"%in%class(model))==FALSE){
if(is(model,class2 = "try-error")==FALSE){
if("TextEmbeddingModel"%in%class(model)){
if(utils::compareVersion(as.character(model$get_package_versions()$aifeducation),"0.3.1")>=0){
closeSweetAlert()
Expand Down Expand Up @@ -3187,7 +3192,7 @@ start_aifeducation_studio<-function(){
type="info")
if(extension=="csv"|extension=="txt"){
target_data=try(as.data.frame(
read.csv2(file = file_path,
utils::read.csv2(file = file_path,
header = TRUE)),silent = TRUE)
} else if(extension=="xlsx"){
target_data=try(
Expand Down Expand Up @@ -3524,7 +3529,7 @@ start_aifeducation_studio<-function(){
classifier<-try(load_ai_model(model_dir = model_path,
ml_framework=input$config_ml_framework),
silent = TRUE)
if(("try-error"%in%class(classifier))==FALSE){
if(is(classifier,class2 = "try-error")==FALSE){
if("TextEmbeddingClassifierNeuralNet"%in%class(classifier)){
if(utils::compareVersion(as.character(classifier$get_package_versions()$r_package_versions$aifeducation),"0.3.1")>=0){
closeSweetAlert()
Expand Down Expand Up @@ -4105,37 +4110,37 @@ start_aifeducation_studio<-function(){
}

plot<-ggplot2::ggplot(data=plot_data)+
ggplot2::geom_line(ggplot2::aes(x=epoch,y=train_mean,color="train"))+
ggplot2::geom_line(ggplot2::aes(x=epoch,y=validation_mean,color="validation"))
ggplot2::geom_line(ggplot2::aes(x=epoch,y=.data$train_mean,color="train"))+
ggplot2::geom_line(ggplot2::aes(x=epoch,y=.data$validation_mean,color="validation"))

if(input$tec_performance_training_min_max==TRUE){
plot<-plot+
ggplot2::geom_line(ggplot2::aes(x=epoch,y=train_min,color="train"))+
ggplot2::geom_line(ggplot2::aes(x=epoch,y=train_max,color="train"))+
ggplot2::geom_ribbon(ggplot2::aes(x=epoch,
ymin=train_min,
ymax=train_max),
ggplot2::geom_line(ggplot2::aes(x=epoch,y=.data$train_min,color="train"))+
ggplot2::geom_line(ggplot2::aes(x=epoch,y=.data$train_max,color="train"))+
ggplot2::geom_ribbon(ggplot2::aes(x=.data$epoch,
ymin=.data$train_min,
ymax=.data$train_max),
alpha=0.25,
fill="red")+
ggplot2::geom_line(ggplot2::aes(x=epoch,y=validation_min,color="validation"))+
ggplot2::geom_line(ggplot2::aes(x=epoch,y=validation_max,color="validation"))+
ggplot2::geom_ribbon(ggplot2::aes(x=epoch,
ymin=validation_min,
ymax=validation_max),
ggplot2::geom_line(ggplot2::aes(x=epoch,y=.data$validation_min,color="validation"))+
ggplot2::geom_line(ggplot2::aes(x=epoch,y=.data$validation_max,color="validation"))+
ggplot2::geom_ribbon(ggplot2::aes(x=.data$epoch,
ymin=.data$validation_min,
ymax=.data$validation_max),
alpha=0.25,
fill="blue")
}
if("test_mean"%in%colnames(plot_data)){
plot=plot+
ggplot2::geom_line(ggplot2::aes(x=epoch,y=test_mean,color="test"))
ggplot2::geom_line(ggplot2::aes(x=.data$epoch,y=.data$test_mean,color="test"))
if(input$tec_performance_training_min_max==TRUE){
plot=plot+
ggplot2::geom_line(ggplot2::aes(x=epoch,y=test_min,color="test"))+
ggplot2::geom_line(ggplot2::aes(x=.data$epoch,y=.data$test_min,color="test"))+

ggplot2::geom_line(ggplot2::aes(x=epoch,y=test_max,color="test"))+
ggplot2::geom_ribbon(ggplot2::aes(x=epoch,
ymin=test_min,
ymax=test_max),
ggplot2::geom_line(ggplot2::aes(x=.data$epoch,y=.data$test_max,color="test"))+
ggplot2::geom_ribbon(ggplot2::aes(x=.data$epoch,
ymin=.data$test_min,
ymax=.data$test_max),
alpha=0.25,
fill="darkgreen")
}
Expand Down Expand Up @@ -4314,7 +4319,7 @@ start_aifeducation_studio<-function(){
file = paste0(save_path_root,".rda"))
}
if(input$tec_pred_save_as_csv==TRUE){
write.csv2(predictions,
utils::write.csv2(predictions,
file = paste0(save_path_root,".csv"))
}
removeModal()
Expand All @@ -4340,7 +4345,7 @@ start_aifeducation_studio<-function(){
classifier=try(load_ai_model(model_dir = tec_interface_for_documentation_path(),
ml_framework=input$config_ml_framework),
silent = TRUE)
if(("try-error"%in%class(classifier))==FALSE){
if(is(classifier,class2 = "try-error")==FALSE){
if("TextEmbeddingClassifierNeuralNet"%in%class(classifier)){
if(utils::compareVersion(as.character(classifier$get_package_versions()$r_package_versions$aifeducation),"0.3.1")>=0){
closeSweetAlert()
Expand Down
3 changes: 1 addition & 2 deletions R/install_and_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ install_py_modules<-function(envname="aifeducation",
#'In all other cases it returns \code{FALSE}
#'@family Installation and Configuration
#'@export
check_aif_py_modules<-function(trace=TRUE,
check="all"){
check_aif_py_modules<-function(trace=TRUE, check="all"){
if(!(check%in%c("all","pytorch","tensorflow"))){
stop("check must be all, pytorch or tensorflow.")
}
Expand Down
2 changes: 2 additions & 0 deletions R/onLoad.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ os<-NULL
keras<-NULL
accelerate<-NULL
safetensors<-NULL
py_update_aifeducation_progress_bar_epochs<-NULL
py_update_aifeducation_progress_bar_steps<-NULL

aifeducation_config<-NULL

Expand Down

0 comments on commit e9ab854

Please sign in to comment.