diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 234915b..aee1bea 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -50,7 +50,7 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 env: - MLFLOW_TRACKING_URI: "http://localhost:5000" + MLFLOW_API_URI: "http://localhost:5000/api" - uses: julia-actions/julia-processcoverage@v1 - uses: codecov/codecov-action@v2 with: diff --git a/docs/src/reference.md b/docs/src/reference.md index 656754f..7f79daf 100644 --- a/docs/src/reference.md +++ b/docs/src/reference.md @@ -56,5 +56,4 @@ uri generatefilterfromentity_type generatefilterfromparams generatefilterfromattributes -healthcheck ``` diff --git a/src/types/mlflow.jl b/src/types/mlflow.jl index 9ba467b..640f8c2 100644 --- a/src/types/mlflow.jl +++ b/src/types/mlflow.jl @@ -4,14 +4,15 @@ Base type which defines location and version for MLFlow API service. # Fields -- `baseuri::String`: base MLFlow tracking URI, e.g. `http://localhost:5000` -- `apiversion`: used API version, e.g. `2.0` -- `headers`: HTTP headers to be provided with the REST API requests (useful for authetication tokens) +- `apiroot::String`: API root URL, e.g. `http://localhost:5000/api` +- `apiversion::Union{Integer, AbstractFloat}`: used API version, e.g. `2.0` +- `headers::Dict`: HTTP headers to be provided with the REST API requests (useful for authetication tokens) +Default is `false`, using the REST API endpoint. # Constructors -- `MLFlow(baseuri; apiversion=2.0,headers=Dict())` -- `MLFlow()` - defaults to `MLFlow(ENV["MLFLOW_TRACKING_URI"])` or `MLFlow("http://localhost:5000")` +- `MLFlow(apiroot; apiversion=2.0,headers=Dict())` +- `MLFlow()` - defaults to `MLFlow(ENV["MLFLOW_API_URI"])` or `MLFlow("http://localhost:5000")` # Examples @@ -26,17 +27,16 @@ mlf = MLFlow(remote_url, headers=Dict("Authorization" => "Bearer 10)) ``` """ function uri(mlf::MLFlow, endpoint="", query=missing) - u = URI("$(mlf.baseuri)/ajax-api/$(mlf.apiversion)/mlflow/$(endpoint)") + u = URI("$(mlf.apiroot)/$(mlf.apiversion)/mlflow/$(endpoint)") !ismissing(query) && return URI(u; query=query) u end diff --git a/test/base.jl b/test/base.jl index 2561ed0..3fdf83a 100644 --- a/test/base.jl +++ b/test/base.jl @@ -13,7 +13,7 @@ function mlflow_server_is_running(mlf::MLFlow) end # creates an instance of mlf -# skips test if mlflow is not available on default location, ENV["MLFLOW_TRACKING_URI"] +# skips test if mlflow is not available on default location, ENV["MLFLOW_API_URI"] macro ensuremlf() e = quote mlf = MLFlow() diff --git a/test/runtests.jl b/test/runtests.jl index e478e47..401ac17 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,10 @@ +if ~haskey(ENV, "MLFLOW_API_URI") + error("WARNING: MLFLOW_API_URI is not set. To run this tests, you need to set the URI of your MLFlow server API") +end + include("base.jl") +include("test_functional.jl") include("test_experiments.jl") include("test_runs.jl") include("test_loggers.jl") diff --git a/test/test_functional.jl b/test/test_functional.jl index 5534fc1..0e64fa0 100644 --- a/test/test_functional.jl +++ b/test/test_functional.jl @@ -1,15 +1,15 @@ @testset "MLFlow" begin mlf = MLFlow() - @test mlf.baseuri == ENV["MLFLOW_TRACKING_URI"] + @test mlf.apiroot == ENV["MLFLOW_API_URI"] @test mlf.apiversion == 2.0 @test mlf.headers == Dict() - mlf = MLFlow("https://localhost:5001", apiversion=3.0) - @test mlf.baseuri == "https://localhost:5001" + mlf = MLFlow("https://localhost:5001/api", apiversion=3.0) + @test mlf.apiroot == "https://localhost:5001/api" @test mlf.apiversion == 3.0 @test mlf.headers == Dict() let custom_headers = Dict("Authorization" => "Bearer EMPTY") - mlf = MLFlow("https://localhost:5001", apiversion=3.0, headers=custom_headers) - @test mlf.baseuri == "https://localhost:5001" + mlf = MLFlow("https://localhost:5001/api", apiversion=3.0, headers=custom_headers) + @test mlf.apiroot == "https://localhost:5001/api" @test mlf.apiversion == 3.0 @test mlf.headers == custom_headers end @@ -21,8 +21,8 @@ end secret_token = "SECRET" custom_headers = Dict("Authorization" => "Bearer $secret_token") - mlf = MLFlow("https://localhost:5001", apiversion=3.0, headers=custom_headers) - @test mlf.baseuri == "https://localhost:5001" + mlf = MLFlow("https://localhost:5001/api", apiversion=3.0, headers=custom_headers) + @test mlf.apiroot == "https://localhost:5001/api" @test mlf.apiversion == 3.0 @test mlf.headers == custom_headers show(io, mlf) @@ -35,17 +35,15 @@ end 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) + let apiroot = "http://localhost:5001/api", apiversion = 2.0, endpoint = "experiments/get" + mlf = MLFlow(apiroot; apiversion=apiversion) apiuri = uri(mlf, endpoint) - @test apiuri == URI("$baseuri/ajax-api/$apiversion/mlflow/$endpoint") + @test apiuri == URI("$apiroot/$apiversion/mlflow/$endpoint") end - let baseuri = "http://localhost:5001", auth_headers = Dict("Authorization" => "Bearer 123456"), + let apiroot = "http://localhost:5001/api", auth_headers = Dict("Authorization" => "Bearer 123456"), custom_headers = Dict("Content-Type" => "application/json") - mlf = MLFlow(baseuri; headers=auth_headers) + mlf = MLFlow(apiroot; headers=auth_headers) apiheaders = headers(mlf, custom_headers) @test apiheaders == Dict("Authorization" => "Bearer 123456", "Content-Type" => "application/json") end