From 7d04cdf01bd22b171289999487cce3d5e9b70a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ad=C3=A1n=20Mauri=20Ungaro?= Date: Sun, 2 Jul 2023 23:43:37 -0300 Subject: [PATCH] A --- .github/workflows/docker.yaml | 6 +-- src/types.jl | 82 ++++++++++++++++++++++++++++- src/types/modelselection_job.jl | 81 ---------------------------- test/test_unit_const.jl | 93 +++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 87 deletions(-) delete mode 100644 src/types/modelselection_job.jl create mode 100644 test/test_unit_const.jl diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 9379690..d3cfccb 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -44,12 +44,8 @@ jobs: - name: Build and push env: - DATE: ${{ steps.current-time.outputs.formattedTime }} + VERSION: ${{ VERSION }} uses: docker/build-push-action@v4 with: push: true tags: user/app:${{ VERSION }} - build-args: | - VERSION=${{ VERSION }} - BUILD_NUMBER=${{ BUILD_NUMBER }} - BUILD_DATE=${{ DATE }} diff --git a/src/types.jl b/src/types.jl index d2c4e87..10d9044 100644 --- a/src/types.jl +++ b/src/types.jl @@ -1 +1,81 @@ -include("types/modelselection_job.jl") +using Dates +using ModelSelection: + Preprocessing, AllSubsetRegression, CrossValidation, ModelSelectionData + +""" + ModelSelectionJob + +A mutable struct that represents a job for performing model selection. + +# Fields +- `id::String`: The unique identifier (UUID) of the model selection job. +- `filename::String`: The name of the file used for model selection. +- `tempfile::String`: The name of a temporary file used during the job's processing. +- `filehash::String`: The unique identifier (UUID) of the file used for model selection. +- `estimator::Symbol`: The estimator used for model selection. +- `equation::String`: The equation or formula used for model selection. +- `parameters::Dict{Symbol,Any}`: The parameters used for model selection, including any additional parameters specified in the request. +- `status::Symbol`: The status of the model selection job (`"pending"`, `"running"`, `"finished"`, or `"failed"`). +- `time_enqueued::DateTime`: The timestamp when the model selection job was enqueued. +- `time_started::Union{DateTime, Nothing}`: The timestamp when the model selection job started, if applicable. +- `time_finished::Union{DateTime, Nothing}`: The timestamp when the model selection job finished, if applicable. +- `modelselection_data::Union{ModelSelectionData, Nothing}`: The data used for model selection. This is `Nothing` if the data is not available. +- `msg::Union{String, Nothing}`: A message associated with the job. This is typically used for reporting errors or other important information. + +# Example +```julia +result = ModelSelectionJob( + filename = "data.csv", + tempfile = "/tmp/12413947-1597-4b1b-a798-efcb2293e808.csv", + filehash = "12413947-95bc-4573-a804-efcb2293e808", + payload = { + :estimator: :ols, + :equation: "y x1 x2 x3", + "ttest": true, + }, +) +``` +""" +mutable struct ModelSelectionJob + id::String + filename::String + tempfile::String + filehash::String + estimator::Symbol + equation::String + parameters::Dict{Symbol,Any} + status::Symbol + time_enqueued::DateTime + time_started::Union{DateTime,Nothing} + time_finished::Union{DateTime,Nothing} + modelselection_data::Union{ModelSelectionData,Nothing} + msg::Union{String,Nothing} + + function ModelSelectionJob( + filename::String, + tempfile::String, + filehash::String, + estimator::Symbol, + equation::String, + parameters::Dict, + ) + id = string(uuid4()) + time_enqueued = now() + parameters = Dict{Symbol,Any}(parameters) + new( + id, + filename, + tempfile, + filehash, + estimator, + equation, + parameters, + PENDING, + time_enqueued, + nothing, + nothing, + nothing, + nothing, + ) + end +end diff --git a/src/types/modelselection_job.jl b/src/types/modelselection_job.jl deleted file mode 100644 index 10d9044..0000000 --- a/src/types/modelselection_job.jl +++ /dev/null @@ -1,81 +0,0 @@ -using Dates -using ModelSelection: - Preprocessing, AllSubsetRegression, CrossValidation, ModelSelectionData - -""" - ModelSelectionJob - -A mutable struct that represents a job for performing model selection. - -# Fields -- `id::String`: The unique identifier (UUID) of the model selection job. -- `filename::String`: The name of the file used for model selection. -- `tempfile::String`: The name of a temporary file used during the job's processing. -- `filehash::String`: The unique identifier (UUID) of the file used for model selection. -- `estimator::Symbol`: The estimator used for model selection. -- `equation::String`: The equation or formula used for model selection. -- `parameters::Dict{Symbol,Any}`: The parameters used for model selection, including any additional parameters specified in the request. -- `status::Symbol`: The status of the model selection job (`"pending"`, `"running"`, `"finished"`, or `"failed"`). -- `time_enqueued::DateTime`: The timestamp when the model selection job was enqueued. -- `time_started::Union{DateTime, Nothing}`: The timestamp when the model selection job started, if applicable. -- `time_finished::Union{DateTime, Nothing}`: The timestamp when the model selection job finished, if applicable. -- `modelselection_data::Union{ModelSelectionData, Nothing}`: The data used for model selection. This is `Nothing` if the data is not available. -- `msg::Union{String, Nothing}`: A message associated with the job. This is typically used for reporting errors or other important information. - -# Example -```julia -result = ModelSelectionJob( - filename = "data.csv", - tempfile = "/tmp/12413947-1597-4b1b-a798-efcb2293e808.csv", - filehash = "12413947-95bc-4573-a804-efcb2293e808", - payload = { - :estimator: :ols, - :equation: "y x1 x2 x3", - "ttest": true, - }, -) -``` -""" -mutable struct ModelSelectionJob - id::String - filename::String - tempfile::String - filehash::String - estimator::Symbol - equation::String - parameters::Dict{Symbol,Any} - status::Symbol - time_enqueued::DateTime - time_started::Union{DateTime,Nothing} - time_finished::Union{DateTime,Nothing} - modelselection_data::Union{ModelSelectionData,Nothing} - msg::Union{String,Nothing} - - function ModelSelectionJob( - filename::String, - tempfile::String, - filehash::String, - estimator::Symbol, - equation::String, - parameters::Dict, - ) - id = string(uuid4()) - time_enqueued = now() - parameters = Dict{Symbol,Any}(parameters) - new( - id, - filename, - tempfile, - filehash, - estimator, - equation, - parameters, - PENDING, - time_enqueued, - nothing, - nothing, - nothing, - nothing, - ) - end -end diff --git a/test/test_unit_const.jl b/test/test_unit_const.jl new file mode 100644 index 0000000..ece07c2 --- /dev/null +++ b/test/test_unit_const.jl @@ -0,0 +1,93 @@ +@safetestset "Test const" begin + using ModelSelectionGUI + + MODEL_SELECTION_NAME = "ModelSelection" + MODEL_SELECTION_VER = get_pkg_version(MODEL_SELECTION_NAME) + ENV_FILE_DEFAULT = ".env" + SERVER_HOST_DEFAULT = "127.0.0.1" + SERVER_PORT_DEFAULT = 8000 + SSL_ENABLED_DEFAULT = false + OPEN_DOCUMENTATION_DEFAULT = false + OPEN_CLIENT_DEFAULT = false + DATA = :data + FILEHASH = :filehash + FILENAME = :filename + ID = :id + MESSAGE = :message + PARAMETERS = :parameters + TEMP_FILENAME = :temp_filename + NCORES = :ncores + NWORKERS = :nworkers + MODEL_SELECTION_VERSION = :model_selection_version + JULIA_VERSION = :julia_version + JOBS_QUEUE_SIZE = :jobs_queue_size + STATUS = :status + JOB_ID = :job_id + ENQUEUED = :enqueued + RUNNING = :running + FINISHED = :finished + FAILED = :failed + PENDING = :pending + ESTIMATOR = :estimator + EQUATION = :equation + DATANAMES = :datanames + NOBS = :nobs + TIME_ENQUEUED = :time_enqueued + TIME_STARTED = :time_started + TIME_FINISHED = :time_finished + MSG = :msg + ALLSUBSETREGRESSION = :allsubsetregression + CROSSVALIDATION = :crossvalidation + SUMMARY = :summary + AVAILABLE_RESULTS_TYPES = [ALLSUBSETREGRESSION, CROSSVALIDATION, SUMMARY] + DEFAULT_WS_CHANNEL = :sync + RESULTS = :results + CSV_MIME = "text/csv" + PLAIN_MIME = "text/plain" + + @test ModelSelectionGUI.MODEL_SELECTION_NAME == MODEL_SELECTION_NAME + @test ModelSelectionGUI.MODEL_SELECTION_VER == MODEL_SELECTION_VER + @test ModelSelectionGUI.ENV_FILE_DEFAULT == ENV_FILE_DEFAULT + @test ModelSelectionGUI.SERVER_HOST_DEFAULT == SERVER_HOST_DEFAULT + @test ModelSelectionGUI.SERVER_PORT_DEFAULT == SERVER_PORT_DEFAULT + @test ModelSelectionGUI.SSL_ENABLED_DEFAULT == SSL_ENABLED_DEFAULT + @test ModelSelectionGUI.OPEN_DOCUMENTATION_DEFAULT == OPEN_DOCUMENTATION_DEFAULT + @test ModelSelectionGUI.OPEN_CLIENT_DEFAULT == OPEN_CLIENT_DEFAULT + @test ModelSelectionGUI.DATA == DATA + @test ModelSelectionGUI.FILEHASH == FILEHASH + @test ModelSelectionGUI.FILENAME == FILENAME + @test ModelSelectionGUI.ID == ID + @test ModelSelectionGUI.MESSAGE == MESSAGE + @test ModelSelectionGUI.PARAMETERS == PARAMETERS + @test ModelSelectionGUI.TEMP_FILENAME == TEMP_FILENAME + @test ModelSelectionGUI.NCORES == NCORES + @test ModelSelectionGUI.NWORKERS == NWORKERS + @test ModelSelectionGUI.MODEL_SELECTION_VERSION == MODEL_SELECTION_VERSION + @test ModelSelectionGUI.JULIA_VERSION == JULIA_VERSION + @test ModelSelectionGUI.JOBS_QUEUE_SIZE == JOBS_QUEUE_SIZE + @test ModelSelectionGUI.STATUS == STATUS + @test ModelSelectionGUI.JOB_ID == JOB_ID + @test ModelSelectionGUI.ENQUEUED == ENQUEUED + @test ModelSelectionGUI.RUNNING == RUNNING + @test ModelSelectionGUI.FINISHED == FINISHED + @test ModelSelectionGUI.FAILED == FAILED + @test ModelSelectionGUI.PENDING == PENDING + @test ModelSelectionGUI.ESTIMATOR == ESTIMATOR + @test ModelSelectionGUI.EQUATION == EQUATION + @test ModelSelectionGUI.DATANAMES == DATANAMES + @test ModelSelectionGUI.NOBS == NOBS + @test ModelSelectionGUI.TIME_ENQUEUED == TIME_ENQUEUED + @test ModelSelectionGUI.TIME_STARTED == TIME_STARTED + @test ModelSelectionGUI.TIME_FINISHED == TIME_FINISHED + @test ModelSelectionGUI.MSG == MSG + @test ModelSelectionGUI.ALLSUBSETREGRESSION == ALLSUBSETREGRESSION + @test ModelSelectionGUI.CROSSVALIDATION == CROSSVALIDATION + @test ModelSelectionGUI.SUMMARY == SUMMARY + @test for i in 1:length(ModelSelectionGUI.AVAILABLE_RESULTS_TYPES) + ModelSelectionGUI.AVAILABLE_RESULTS_TYPES[i] == AVAILABLE_RESULTS_TYPES[i] + end + @test ModelSelectionGUI.DEFAULT_WS_CHANNEL == DEFAULT_WS_CHANNEL + @test ModelSelectionGUI.RESULTS == RESULTS + @test ModelSelectionGUI.CSV_MIME == CSV_MIME + @test ModelSelectionGUI.PLAIN_MIME == PLAIN_MIME +end