Skip to content

Commit

Permalink
Format files and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
adanmauri committed Jun 21, 2023
1 parent db26f18 commit ceb239e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 99 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![][documentation-main-img]][documentation-main-url] [![][build-main-img]][test-main-url] [![][test-main-img]][test-main-url] [![][codecov-img]][codecov-url]

The ModelSelectionGUI is a web server package designed to provide a user-friendly interface for utilizing the ModelSelection package. It consists of a backend and an optional frontend that offers a graphical user interface (GUI) for seamless interaction with the underlying ModelSelection functionality.
The ModelSelectionGUI is a web server package designed to provide a user-friendly interface for utilizing the ModelSelection package. It consists of a backend and an optional frontend that offers a graphical user interface (GUI) for seamless interaction with the underlying [ModelSelection](https://github.com/ParallelGSReg/ModelSelectionGUI.jl) functionality.

## Features

Expand Down Expand Up @@ -34,8 +34,8 @@ If the web client is enabled open your web browser and enter the following URL:

For more detailed information about this package, its functionalities, and usage instructions, please refer to our [documentation page](https://parallelgsreg.github.io/ModelSelectionGUI.jl).

## ModelSelection.jl package
ModelSelectionGUI.jl package functions as an interface with ModelSelection.jl. For more details about the functionalities and features provided by ModelSelection.jl, please visit the [package repository](https://github.com/ParallelGSReg/ModelSelection.jl).
## ModelSelection package
ModelSelectionGUI package functions as an interface with ModelSelection.jl. For more details about the functionalities and features provided by ModelSelection, please visit the [package repository](https://github.com/ParallelGSReg/ModelSelection.jl).

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion src/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function reset_envvars()
global OPEN_BROWSER
global OPEN_CLIENT
global SERVER_URL

SERVER_PORT = SERVER_PORT_DEFAULT
CLIENT_PORT = SERVER_PORT + 1
OPEN_BROWSER = OPEN_BROWSER_DEFAULT
Expand Down
70 changes: 25 additions & 45 deletions test/integration/test_jobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,10 @@ const DATA_FILENAME = "data.csv"
equation = "y x1 x2 x3"
estimator = :ols
ModelSelectionGUI.add_job_file(filehash, tempfile, filename)
body = Dict(
:estimator => estimator,
:equation => equation,
:ttest => ttest,
)
body = Dict(:estimator => estimator, :equation => equation, :ttest => ttest)
reset_envvars()
start(dotenv = DOTENV)
response = HTTP.post(
url,
["Content-Type" => "application/json"],
JSON.json(body)
)
response = HTTP.post(url, ["Content-Type" => "application/json"], JSON.json(body))
msg = String(response.body)
body = JSON.parse(msg)

Expand All @@ -43,7 +35,7 @@ const DATA_FILENAME = "data.csv"
@test response.status == 200
@test haskey(body, ID)
@test body[ID] isa String

@test response.status == 200
@test haskey(body, FILENAME)
@test body[FILENAME] isa String
Expand Down Expand Up @@ -77,7 +69,7 @@ const DATA_FILENAME = "data.csv"
@test haskey(body, MSG)
stop()
end

@testset "GET /job/:id" begin
using HTTP, JSON, Dates
id = "83ecac9e-678d-4c80-9314-0ae4a67d5ace"
Expand All @@ -87,7 +79,7 @@ const DATA_FILENAME = "data.csv"
tempfile = DATA_FILENAME
estimator = :ols
equation = "y x1 x2 x3"
ttest = true
ttest = true
payload = Dict(
ModelSelectionGUI.ESTIMATOR => estimator,
ModelSelectionGUI.EQUATION => equation,
Expand Down Expand Up @@ -151,14 +143,17 @@ const DATA_FILENAME = "data.csv"
@test body[STATUS] == String(status)
@test haskey(body, TIME_ENQUEUED)
@test body[TIME_ENQUEUED] isa String
@test Dates.format(DateTime(body[TIME_ENQUEUED]), "yyyy-mm-ddTHH:MM:SS") == time_equeued

@test Dates.format(DateTime(body[TIME_ENQUEUED]), "yyyy-mm-ddTHH:MM:SS") ==
time_equeued

@test haskey(body, TIME_STARTED)
@test body[TIME_STARTED] isa String
@test Dates.format(DateTime(body[TIME_STARTED]), "yyyy-mm-ddTHH:MM:SS") == time_started
@test Dates.format(DateTime(body[TIME_STARTED]), "yyyy-mm-ddTHH:MM:SS") ==
time_started
@test haskey(body, TIME_FINISHED)
@test body[TIME_FINISHED] isa String
@test Dates.format(DateTime(body[TIME_FINISHED]), "yyyy-mm-ddTHH:MM:SS") == time_finished
@test Dates.format(DateTime(body[TIME_FINISHED]), "yyyy-mm-ddTHH:MM:SS") ==
time_finished

@test haskey(body, ESTIMATOR)
@test body[ESTIMATOR] isa String
Expand All @@ -171,7 +166,7 @@ const DATA_FILENAME = "data.csv"
@test haskey(body, MSG)
@test body[MSG] isa String
@test body[MSG] == msg

ModelSelectionGUI.clear_jobs_queue()
ModelSelectionGUI.clear_current_job()
ModelSelectionGUI.clear_jobs_finished()
Expand All @@ -186,7 +181,7 @@ const DATA_FILENAME = "data.csv"
tempfile = DATA_FILENAME
estimator = :ols
equation = "y x1 x2 x3"
ttest = true
ttest = true
payload = Dict(
ModelSelectionGUI.ESTIMATOR => estimator,
ModelSelectionGUI.EQUATION => equation,
Expand All @@ -200,17 +195,12 @@ const DATA_FILENAME = "data.csv"
job.time_started = DateTime(time)
job.time_finished = DateTime(time)
job.modelselection_data = nothing

data = CSV.read(job.tempfile, DataFrame)
job.modelselection_data = gsr(
job.estimator,
job.equation,
data;
job.parameters...,
)
job.modelselection_data = gsr(job.estimator, job.equation, data; job.parameters...)

push!(ModelSelectionGUI.jobs_finished, job)

start(dotenv = DOTENV)
response = HTTP.get(url)

Expand All @@ -231,7 +221,7 @@ const DATA_FILENAME = "data.csv"
tempfile = DATA_FILENAME
estimator = :ols
equation = "y x1 x2 x3"
ttest = true
ttest = true
payload = Dict(
ModelSelectionGUI.ESTIMATOR => estimator,
ModelSelectionGUI.EQUATION => equation,
Expand All @@ -245,17 +235,12 @@ const DATA_FILENAME = "data.csv"
job.time_started = DateTime(time)
job.time_finished = DateTime(time)
job.modelselection_data = nothing

data = CSV.read(job.tempfile, DataFrame)
job.modelselection_data = gsr(
job.estimator,
job.equation,
data;
job.parameters...,
)
job.modelselection_data = gsr(job.estimator, job.equation, data; job.parameters...)

push!(ModelSelectionGUI.jobs_finished, job)

start(dotenv = DOTENV)
response = HTTP.get(url)

Expand All @@ -276,7 +261,7 @@ const DATA_FILENAME = "data.csv"
tempfile = DATA_FILENAME
estimator = :ols
equation = "y x1 x2 x3"
ttest = true
ttest = true
payload = Dict(
ModelSelectionGUI.ESTIMATOR => estimator,
ModelSelectionGUI.EQUATION => equation,
Expand All @@ -291,17 +276,12 @@ const DATA_FILENAME = "data.csv"
job.time_started = DateTime(time)
job.time_finished = DateTime(time)
job.modelselection_data = nothing

data = CSV.read(job.tempfile, DataFrame)
job.modelselection_data = gsr(
job.estimator,
job.equation,
data;
job.parameters...,
)
job.modelselection_data = gsr(job.estimator, job.equation, data; job.parameters...)

push!(ModelSelectionGUI.jobs_finished, job)

start(dotenv = DOTENV)
response = HTTP.get(url)

Expand Down
66 changes: 27 additions & 39 deletions test/unit/test_responses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const DATA_FILENAME = "data.csv"
using JSON
version = v"1.3.0" # TODO: Update this version when the package is updated.
pkg_version = ModelSelectionGUI.get_pkg_version("ModelSelection")

ncores = 2
nworkers = 1
model_selection_version = "1.3.0"
Expand All @@ -17,18 +17,18 @@ const DATA_FILENAME = "data.csv"
response = ModelSelectionGUI.server_info_response(
ncores,
nworkers,
model_selection_version,
model_selection_version,
julia_version,
jobs_queue_size,
)

headers = split(Dict(response.headers)["Content-Type"])
headers[1] = replace(headers[1], ";"=>"")
headers[2] = replace(headers[2], "charset="=>"")
headers[1] = replace(headers[1], ";" => "")
headers[2] = replace(headers[2], "charset=" => "")
msg = String(response.body)
body = JSON.parse(msg)


@test response.status == 200
@test headers[1] == content_type
@test headers[2] == charset
Expand Down Expand Up @@ -64,19 +64,14 @@ const DATA_FILENAME = "data.csv"
nobs = 2
content_type = "application/json"
charset = "utf-8"
response = ModelSelectionGUI.upload_response(
filename,
filehash,
datanames,
nobs,
)
response = ModelSelectionGUI.upload_response(filename, filehash, datanames, nobs)

headers = split(Dict(response.headers)["Content-Type"])
headers[1] = replace(headers[1], ";"=>"")
headers[2] = replace(headers[2], "charset="=>"")
headers[1] = replace(headers[1], ";" => "")
headers[2] = replace(headers[2], "charset=" => "")
msg = String(response.body)
body = JSON.parse(msg)

@test response.status == 200
@test headers[1] == content_type
@test headers[2] == charset
Expand All @@ -94,7 +89,7 @@ const DATA_FILENAME = "data.csv"
@test body[FILEHASH] == filehash
@test haskey(body, DATANAMES)
@test body[DATANAMES] isa Vector
for i in 1:lastindex(datanames)
for i = 1:lastindex(datanames)
@test body[DATANAMES][i] == datanames[i]
end
@test haskey(body, NOBS)
Expand All @@ -112,7 +107,7 @@ const DATA_FILENAME = "data.csv"
tempfile = DATA_FILENAME
estimator = :ols
equation = "y x1 x2 x3"
ttest = true
ttest = true
payload = Dict(
ModelSelectionGUI.ESTIMATOR => estimator,
ModelSelectionGUI.EQUATION => equation,
Expand All @@ -131,19 +126,14 @@ const DATA_FILENAME = "data.csv"
job.time_started = DateTime(time_started)
job.time_finished = DateTime(time_finished)
job.msg = "msg"

data = CSV.read(job.tempfile, DataFrame)
job.modelselection_data = gsr(
job.estimator,
job.equation,
data;
job.parameters...,
)
job.modelselection_data = gsr(job.estimator, job.equation, data; job.parameters...)

response = ModelSelectionGUI.job_info_response(job)
headers = split(Dict(response.headers)["Content-Type"])
headers[1] = replace(headers[1], ";"=>"")
headers[2] = replace(headers[2], "charset="=>"")
headers[1] = replace(headers[1], ";" => "")
headers[2] = replace(headers[2], "charset=" => "")
body = String(response.body)
body = JSON.parse(body)

Expand Down Expand Up @@ -184,14 +174,17 @@ const DATA_FILENAME = "data.csv"
@test body[STATUS] == String(status)
@test haskey(body, TIME_ENQUEUED)
@test body[TIME_ENQUEUED] isa String
@test Dates.format(DateTime(body[TIME_ENQUEUED]), "yyyy-mm-ddTHH:MM:SS") == time_equeued

@test Dates.format(DateTime(body[TIME_ENQUEUED]), "yyyy-mm-ddTHH:MM:SS") ==
time_equeued

@test haskey(body, TIME_STARTED)
@test body[TIME_STARTED] isa String
@test Dates.format(DateTime(body[TIME_STARTED]), "yyyy-mm-ddTHH:MM:SS") == time_started
@test Dates.format(DateTime(body[TIME_STARTED]), "yyyy-mm-ddTHH:MM:SS") ==
time_started
@test haskey(body, TIME_FINISHED)
@test body[TIME_FINISHED] isa String
@test Dates.format(DateTime(body[TIME_FINISHED]), "yyyy-mm-ddTHH:MM:SS") == time_finished
@test Dates.format(DateTime(body[TIME_FINISHED]), "yyyy-mm-ddTHH:MM:SS") ==
time_finished

@test haskey(body, ESTIMATOR)
@test body[ESTIMATOR] isa String
Expand All @@ -214,7 +207,7 @@ const DATA_FILENAME = "data.csv"
tempfile = DATA_FILENAME
estimator = :ols
equation = "y x1 x2 x3"
ttest = true
ttest = true
payload = Dict(
ModelSelectionGUI.ESTIMATOR => estimator,
ModelSelectionGUI.EQUATION => equation,
Expand All @@ -229,14 +222,9 @@ const DATA_FILENAME = "data.csv"
job.time_started = DateTime(time)
job.time_finished = DateTime(time)
job.modelselection_data = nothing

data = CSV.read(job.tempfile, DataFrame)
job.modelselection_data = gsr(
job.estimator,
job.equation,
data;
job.parameters...,
)
job.modelselection_data = gsr(job.estimator, job.equation, data; job.parameters...)

response = ModelSelectionGUI.job_results_response(job, :summary)
@test response.status == 200
Expand Down
19 changes: 9 additions & 10 deletions test/unit/test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ const DATA_FILENAME = "data.csv"
data = DataFrame([1 2 3; 4 5 6], ["a", "b", "c"])
ModelSelectionGUI.save_tempfile(name, data)
new_data = CSV.read(name, DataFrame)

old_names = names(data)
new_names = names(new_data)
for i in 1:3
for i = 1:3
@test old_names[i] == new_names[i]
end
for i in 1:2
for j in 1:3
for i = 1:2
for j = 1:3
@test data[i, j] == new_data[i, j]
end
end
Expand Down Expand Up @@ -63,12 +63,11 @@ const DATA_FILENAME = "data.csv"
using CSV, DataFrames, ModelSelection
csv_filename = "data_allsubsetregression.csv"
data = CSV.read(DATA_FILENAME, DataFrame)
modelselection_data = gsr(
:ols,
"y x1 x2 x3",
data,
modelselection_data = gsr(:ols, "y x1 x2 x3", data)
result = ModelSelectionGUI.get_csv_from_result(
DATA_FILENAME,
modelselection_data.results[1],
)
result = ModelSelectionGUI.get_csv_from_result(DATA_FILENAME, modelselection_data.results[1])
@test result isa Dict
@test result[ModelSelectionGUI.FILENAME] == csv_filename
@test result[ModelSelectionGUI.DATA] isa String
Expand All @@ -87,7 +86,7 @@ const DATA_FILENAME = "data.csv"
@test parameters[:b] == b
@test haskey(parameters, :c)
@test parameters[:c] == c

@test haskey(parameters, :fixedvariables)
@test parameters[:fixedvariables][1] == Symbol(fixedvariables[1])
@test parameters[:fixedvariables][2] == Symbol(fixedvariables[2])
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
@test ModelSelectionGUI.CLIENT_PORT == ModelSelectionGUI.SERVER_PORT_DEFAULT + 1
@test ModelSelectionGUI.OPEN_BROWSER == ModelSelectionGUI.OPEN_BROWSER_DEFAULT
@test ModelSelectionGUI.OPEN_CLIENT == ModelSelectionGUI.OPEN_CLIENT_DEFAULT
@test ModelSelectionGUI.SERVER_URL == ModelSelectionGUI.SERVER_URL_DEFAULT
@test ModelSelectionGUI.SERVER_URL == ModelSelectionGUI.SERVER_URL_DEFAULT
end
end

0 comments on commit ceb239e

Please sign in to comment.