Skip to content

Commit

Permalink
Added support for setting default URI via ENV["MLFLOW_TRACKING_URI"]
Browse files Browse the repository at this point in the history
  • Loading branch information
stemann committed Apr 15, 2024
1 parent a31b41a commit 6a85bf6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
env:
MLFLOW_TRACKING_URI: "http://localhost:5000"
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v2
with:
Expand Down
11 changes: 9 additions & 2 deletions src/types/mlflow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Base type which defines location and version for MLFlow API service.
# Constructors
- `MLFlow(baseuri; apiversion=2.0,headers=Dict())`
- `MLFlow()` - defaults to `MLFlow("http://localhost:5000")`
- `MLFlow()` - defaults to `MLFlow(ENV["MLFLOW_TRACKING_URI"])` or `MLFlow("http://localhost:5000")`
# Examples
Expand All @@ -31,5 +31,12 @@ struct MLFlow
headers::Dict
end
MLFlow(baseuri; apiversion=2.0,headers=Dict()) = MLFlow(baseuri, apiversion,headers)
MLFlow() = MLFlow("http://localhost:5000", 2.0, Dict())
function MLFlow()
baseuri = "http://localhost:5000"
if haskey(ENV, "MLFLOW_TRACKING_URI")
baseuri = ENV["MLFLOW_TRACKING_URI"]
end
return MLFlow(baseuri)
end

Base.show(io::IO, t::MLFlow) = show(io, ShowCase(t, [:baseuri,:apiversion], new_lines=true))
2 changes: 1 addition & 1 deletion test/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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, http://localhost:5000
# skips test if mlflow is not available on default location, ENV["MLFLOW_TRACKING_URI"]
macro ensuremlf()
e = quote
mlf = MLFlow()
Expand Down
2 changes: 1 addition & 1 deletion test/test_functional.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@testset "MLFlow" begin
mlf = MLFlow()
@test mlf.baseuri == "http://localhost:5000"
@test mlf.baseuri == ENV["MLFLOW_TRACKING_URI"]
@test mlf.apiversion == 2.0
@test mlf.headers == Dict()
mlf = MLFlow("https://localhost:5001", apiversion=3.0)
Expand Down

0 comments on commit 6a85bf6

Please sign in to comment.