diff --git a/src/utils.jl b/src/utils.jl index 8874c04..8d96d7b 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -1,3 +1,19 @@ +""" + healthcheck(mlf::MLFlow) + +Checks if MLFlow server is up and running. Returns `true` if it is, `false` +otherwise. +""" +function healthcheck(mlf) + uri = "$(mlf.baseuri)/health" + try + response = HTTP.get(uri) + return String(response.body) == "OK" + catch e + return false + end +end + """ uri(mlf::MLFlow, endpoint="", query=missing) diff --git a/test/test_functional.jl b/test/test_functional.jl index 6eff632..60880b0 100644 --- a/test/test_functional.jl +++ b/test/test_functional.jl @@ -34,6 +34,9 @@ end @testset "utils" begin using MLFlowClient: uri, headers using URIs: URI + + @test healthcheck(MLFlow()) == true + let baseuri = "http://localhost:5001", apiversion = "2.0", endpoint = "experiments/get" mlf = MLFlow(baseuri; apiversion) apiuri = uri(mlf, endpoint)