Responses
This section of the package is responsible for response-generating. These functions ensure the proper structure for each endpoint response.
Index
ModelSelectionGUI.estimators_responseModelSelectionGUI.job_info_responseModelSelectionGUI.job_results_responseModelSelectionGUI.server_info_responseModelSelectionGUI.upload_response
Contents
ModelSelectionGUI.server_info_response — Methodserver_info_response(ncores::Int64, nworkers::Int64, model_selection_version::String, julia_version::String, jobs_queue_size::Int64)Creates a JSON object with server information.
Parameters
ncores::Int64: The number of cores on the server.nworkers::Int64: The number of worker threads on the server.model_selection_version::String: The version number of the ModelSelection package.julia_version::String: The version number of Julia being used.jobs_queue_size::Int64: The size of the job queue.
Returns
Object: A JSON object containing the server information.
Example
server_info_response(4, 8, "1.0.0", "1.6.1", 10)ModelSelectionGUI.upload_response — Methodupload_response(filename::String, filehash::String, datanames::Array{String,1}, nobs::Int64)Creates a JSON object to provide a response for a file upload operation.
Parameters
filename::String: The name of the uploaded file.filehash::String: The hash value of the uploaded file.datanames::Array{String,1}: An array of data names from the uploaded file.nobs::Int64: The number of observations in the uploaded file.
Returns
Object: A JSON object with details about the uploaded file.
Example
upload_response("data.csv", "abc123", ["col1", "col2"], 100)ModelSelectionGUI.job_info_response — Methodjob_info_response(job::ModelSelectionJob)Creates a JSON object that provides information about a ModelSelectionJob.
Parameters
job::ModelSelectionJob: TheModelSelectionJobinstance to extract information from.
Returns
Object: A JSON object with the details of theModelSelectionJob.
Example
job = ModelSelectionJob(...) # job is an instance of ModelSelectionJob
job_info_response(job)ModelSelectionGUI.job_results_response — Methodjob_results_response(job::ModelSelectionJob, resulttype::Symbol)Generates an HTTP response with information about the results of a ModelSelectionJob depending on the specified result type.
Parameters
job::ModelSelectionJob: TheModelSelectionJobinstance from which to extract results.resulttype::Symbol: The type of result to extract. This can be one of::summary,
:allsubsetregression, :crossvalidation.
Returns
HTTP.Response: A HTTP response object.- If
resulttypeis:summary, the response body is a text string
- If
resulttypeis:allsubsetregressionor
:crossvalidation, the response body is a CSV-formatted string of the corresponding results.- If there are no results of the requested type, a 400 (Bad Request) HTTP response is returned.
- If
Example
job = ModelSelectionJob(...) # job is an instance of ModelSelectionJob
job_results_response(job, :summary)ModelSelectionGUI.estimators_response — Methodestimators_response(estimators::Dict{Symbol, Dict{Symbol, Any}})Create a response dictionary containing estimators. This function takes a dictionary estimators as input, where the keys are symbols representing the names of estimators, and the values are dictionaries containing information about each estimator.
Parameters
estimators::Dict{Symbol, Dict{Symbol, Any}}: A dictionary of estimators.
Returns
HTTP.Response: A HTTP response object.
Example
estimators = const ESTIMATORS = Dict(
"OLS" => Dict("name" => "Ordinary Least Squares"),
"Logit" => Dict("name" => "Logistic Regression"),
)
estimators_response(estimators)