Skip to content

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
FBerding committed Jan 22, 2024
1 parent 59c3e6a commit 31d1a95
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
16 changes: 10 additions & 6 deletions R/aif_gui.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,22 @@ start_aifeducation_studio<-function(){

message("Setting the correct conda environment.")
if(reticulate::py_available(FALSE)==FALSE){
message("Python is not initalized.")
if(reticulate::condaenv_exists("aifeducation")==FALSE){
stop("Aifeducation studio requires a conda environment 'aifeducation' with
specific python libraries. Please install this. Please refer to the corresponding
vignette for more details.")
} else {
message("Setting conda environment to 'aifeducation'.")
reticulate::use_condaenv("aifeducation")
message("Initializing python.")
if(reticulate::py_available(TRUE)==FALSE){
stop("Python cannot be initalized. Please check your installation of python.")
}
}
}

message("Initializing python.")
if(reticulate::py_available(TRUE)==FALSE){
stop("Python cannot be initalized. Please check your installation of python.")
} else {
message("Python is initalized. Try to start Aifeducation Studio with
the current environment.")
}

message("Checking machine learning frameworks.")
Expand Down Expand Up @@ -185,7 +189,7 @@ start_aifeducation_studio<-function(){
textInput(inputId = "dp_text_output_filename",
label = tags$p(icon("file"),"File Name"))
),
box(title = "Start process",
box(title = "Start Process",
solidHeader = TRUE,
status = "success",
width = 12,
Expand Down
10 changes: 6 additions & 4 deletions tests/testthat/test-04_transformer_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ example_data<-data.frame(
label=quanteda::docvars(quanteda.textmodels::data_corpus_moviereviews)$sentiment)
example_data$text<-as.character(quanteda.textmodels::data_corpus_moviereviews)

print(check_aif_py_modules())

for(framework in ml_frameworks){

for(ai_method in ai_methods){
Expand Down Expand Up @@ -731,9 +733,9 @@ for(ai_method in ai_methods){
save_format = "safetensors")
)
if(reticulate::py_module_available("safetensors")){
expect_true(file.exists(testthat::test_path(paste0(path_03,"/",framework,"/",model_name,"/model.safetensors"))))
expect_true(file.exists(testthat::test_path(paste0(path_03,"/",framework,"/",model_name,"/model_data/model.safetensors"))))
} else {
expect_true(file.exists(testthat::test_path(paste0(path_03,"/",framework,"/",model_name,"/pytorch_model.bin"))))
expect_true(file.exists(testthat::test_path(paste0(path_03,"/",framework,"/",model_name,"/model_data/pytorch_model.bin"))))
}
})

Expand All @@ -758,9 +760,9 @@ for(ai_method in ai_methods){
)
if(framework=="pytorch"){
if(reticulate::py_module_available("safetensors")){
expect_true(file.exists(testthat::test_path(paste0(path_03,"/",framework,"/",model_name,"/model.safetensors"))))
expect_true(file.exists(testthat::test_path(paste0(path_03,"/",framework,"/",model_name,"/model_data/model.safetensors"))))
} else {
expect_true(file.exists(testthat::test_path(paste0(path_03,"/",framework,"/",model_name,"/pytorch_model.bin"))))
expect_true(file.exists(testthat::test_path(paste0(path_03,"/",framework,"/",model_name,"/model_data/pytorch_model.bin"))))
}
}

Expand Down

0 comments on commit 31d1a95

Please sign in to comment.