Skip to content

Commit

Permalink
Merge pull request #38 from stemann/feature/devcontainer
Browse files Browse the repository at this point in the history
- Added dev. container
- Using `MLFLOW_TRACKING_URI` env variable to define the default URI
  • Loading branch information
pebeto committed Apr 15, 2024
2 parents a31b41a + 56479a5 commit 46b521d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 4 deletions.
14 changes: 14 additions & 0 deletions .devcontainer/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3'

services:
project:
image: mcr.microsoft.com/devcontainers/base:debian
volumes:
- ../..:/workspaces:cached
command: sleep infinity # Overrides default command so things don't shut down after the process ends.

mlflow:
image: ghcr.io/mlflow/mlflow:v2.10.0
entrypoint: ["mlflow", "server", "--host", "0.0.0.0"]
ports:
- "5000"
14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dockerComposeFile": "compose.yaml",
"service": "project",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"features": {
"ghcr.io/julialang/devcontainer-features/julia:1": {
"channel": "release"
}
},
"containerEnv": {
"JULIA_PROJECT": "/workspaces/${localWorkspaceFolderBasename}",
"MLFLOW_TRACKING_URI": "http://mlflow:5000",
}
}
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 46b521d

Please sign in to comment.