Skip to content

Commit 399f526

Browse files
authored
Merge pull request #44 from JuliaAI/43-support-gitlabs-mlflow-backend
2 parents c843be3 + 839a29c commit 399f526

File tree

7 files changed

+33
-47
lines changed

7 files changed

+33
-47
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- uses: julia-actions/julia-buildpkg@v1
5151
- uses: julia-actions/julia-runtest@v1
5252
env:
53-
MLFLOW_TRACKING_URI: "http://localhost:5000"
53+
MLFLOW_API_URI: "http://localhost:5000/api"
5454
- uses: julia-actions/julia-processcoverage@v1
5555
- uses: codecov/codecov-action@v2
5656
with:

docs/src/reference.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,4 @@ uri
5656
generatefilterfromentity_type
5757
generatefilterfromparams
5858
generatefilterfromattributes
59-
healthcheck
6059
```

src/types/mlflow.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
Base type which defines location and version for MLFlow API service.
55
66
# Fields
7-
- `baseuri::String`: base MLFlow tracking URI, e.g. `http://localhost:5000`
8-
- `apiversion`: used API version, e.g. `2.0`
9-
- `headers`: HTTP headers to be provided with the REST API requests (useful for authetication tokens)
7+
- `apiroot::String`: API root URL, e.g. `http://localhost:5000/api`
8+
- `apiversion::Union{Integer, AbstractFloat}`: used API version, e.g. `2.0`
9+
- `headers::Dict`: HTTP headers to be provided with the REST API requests (useful for authetication tokens)
10+
Default is `false`, using the REST API endpoint.
1011
1112
# Constructors
1213
13-
- `MLFlow(baseuri; apiversion=2.0,headers=Dict())`
14-
- `MLFlow()` - defaults to `MLFlow(ENV["MLFLOW_TRACKING_URI"])` or `MLFlow("http://localhost:5000")`
14+
- `MLFlow(apiroot; apiversion=2.0,headers=Dict())`
15+
- `MLFlow()` - defaults to `MLFlow(ENV["MLFLOW_API_URI"])` or `MLFlow("http://localhost:5000")`
1516
1617
# Examples
1718
@@ -26,17 +27,16 @@ mlf = MLFlow(remote_url, headers=Dict("Authorization" => "Bearer <your-secret-to
2627
2728
"""
2829
struct MLFlow
29-
baseuri::String
30+
apiroot::String
3031
apiversion::Union{Integer, AbstractFloat}
3132
headers::Dict
3233
end
33-
MLFlow(baseuri; apiversion=2.0,headers=Dict()) = MLFlow(baseuri, apiversion,headers)
34+
MLFlow(apiroot; apiversion=2.0, headers=Dict()) = MLFlow(apiroot, apiversion, headers)
3435
function MLFlow()
35-
baseuri = "http://localhost:5000"
36-
if haskey(ENV, "MLFLOW_TRACKING_URI")
37-
baseuri = ENV["MLFLOW_TRACKING_URI"]
36+
apiroot = "http://localhost:5000/api"
37+
if haskey(ENV, "MLFLOW_API_URI")
38+
apiroot = ENV["MLFLOW_API_URI"]
3839
end
39-
return MLFlow(baseuri)
40+
return MLFlow(apiroot)
4041
end
41-
42-
Base.show(io::IO, t::MLFlow) = show(io, ShowCase(t, [:baseuri,:apiversion], new_lines=true))
42+
Base.show(io::IO, t::MLFlow) = show(io, ShowCase(t, [:apiroot,:apiversion], new_lines=true))

src/utils.jl

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
"""
2-
healthcheck(mlf::MLFlow)
3-
4-
Checks if MLFlow server is up and running. Returns `true` if it is, `false`
5-
otherwise.
6-
"""
7-
function healthcheck(mlf)
8-
uri = "$(mlf.baseuri)/health"
9-
try
10-
response = HTTP.get(uri)
11-
return String(response.body) == "OK"
12-
catch e
13-
return false
14-
end
15-
end
16-
171
"""
182
uri(mlf::MLFlow, endpoint="", query=missing)
193
@@ -25,7 +9,7 @@ MLFlowClient.uri(mlf, "experiments/get", Dict(:experiment_id=>10))
259
```
2610
"""
2711
function uri(mlf::MLFlow, endpoint="", query=missing)
28-
u = URI("$(mlf.baseuri)/ajax-api/$(mlf.apiversion)/mlflow/$(endpoint)")
12+
u = URI("$(mlf.apiroot)/$(mlf.apiversion)/mlflow/$(endpoint)")
2913
!ismissing(query) && return URI(u; query=query)
3014
u
3115
end

test/base.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function mlflow_server_is_running(mlf::MLFlow)
1313
end
1414

1515
# creates an instance of mlf
16-
# skips test if mlflow is not available on default location, ENV["MLFLOW_TRACKING_URI"]
16+
# skips test if mlflow is not available on default location, ENV["MLFLOW_API_URI"]
1717
macro ensuremlf()
1818
e = quote
1919
mlf = MLFlow()

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
if ~haskey(ENV, "MLFLOW_API_URI")
2+
error("WARNING: MLFLOW_API_URI is not set. To run this tests, you need to set the URI of your MLFlow server API")
3+
end
4+
15
include("base.jl")
26

7+
include("test_functional.jl")
38
include("test_experiments.jl")
49
include("test_runs.jl")
510
include("test_loggers.jl")

test/test_functional.jl

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
@testset "MLFlow" begin
22
mlf = MLFlow()
3-
@test mlf.baseuri == ENV["MLFLOW_TRACKING_URI"]
3+
@test mlf.apiroot == ENV["MLFLOW_API_URI"]
44
@test mlf.apiversion == 2.0
55
@test mlf.headers == Dict()
6-
mlf = MLFlow("https://localhost:5001", apiversion=3.0)
7-
@test mlf.baseuri == "https://localhost:5001"
6+
mlf = MLFlow("https://localhost:5001/api", apiversion=3.0)
7+
@test mlf.apiroot == "https://localhost:5001/api"
88
@test mlf.apiversion == 3.0
99
@test mlf.headers == Dict()
1010
let custom_headers = Dict("Authorization" => "Bearer EMPTY")
11-
mlf = MLFlow("https://localhost:5001", apiversion=3.0, headers=custom_headers)
12-
@test mlf.baseuri == "https://localhost:5001"
11+
mlf = MLFlow("https://localhost:5001/api", apiversion=3.0, headers=custom_headers)
12+
@test mlf.apiroot == "https://localhost:5001/api"
1313
@test mlf.apiversion == 3.0
1414
@test mlf.headers == custom_headers
1515
end
@@ -21,8 +21,8 @@ end
2121
secret_token = "SECRET"
2222

2323
custom_headers = Dict("Authorization" => "Bearer $secret_token")
24-
mlf = MLFlow("https://localhost:5001", apiversion=3.0, headers=custom_headers)
25-
@test mlf.baseuri == "https://localhost:5001"
24+
mlf = MLFlow("https://localhost:5001/api", apiversion=3.0, headers=custom_headers)
25+
@test mlf.apiroot == "https://localhost:5001/api"
2626
@test mlf.apiversion == 3.0
2727
@test mlf.headers == custom_headers
2828
show(io, mlf)
@@ -35,17 +35,15 @@ end
3535
using MLFlowClient: uri, headers
3636
using URIs: URI
3737

38-
@test healthcheck(MLFlow()) == true
39-
40-
let baseuri = "http://localhost:5001", apiversion = "2.0", endpoint = "experiments/get"
41-
mlf = MLFlow(baseuri; apiversion)
38+
let apiroot = "http://localhost:5001/api", apiversion = 2.0, endpoint = "experiments/get"
39+
mlf = MLFlow(apiroot; apiversion=apiversion)
4240
apiuri = uri(mlf, endpoint)
43-
@test apiuri == URI("$baseuri/ajax-api/$apiversion/mlflow/$endpoint")
41+
@test apiuri == URI("$apiroot/$apiversion/mlflow/$endpoint")
4442
end
45-
let baseuri = "http://localhost:5001", auth_headers = Dict("Authorization" => "Bearer 123456"),
43+
let apiroot = "http://localhost:5001/api", auth_headers = Dict("Authorization" => "Bearer 123456"),
4644
custom_headers = Dict("Content-Type" => "application/json")
4745

48-
mlf = MLFlow(baseuri; headers=auth_headers)
46+
mlf = MLFlow(apiroot; headers=auth_headers)
4947
apiheaders = headers(mlf, custom_headers)
5048
@test apiheaders == Dict("Authorization" => "Bearer 123456", "Content-Type" => "application/json")
5149
end

0 commit comments

Comments
 (0)