From 6a85bf69f1c57189507ca804b23b3245a19ab0b0 Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Mon, 29 Jan 2024 18:09:50 +0100 Subject: [PATCH 1/2] Added support for setting default URI via ENV["MLFLOW_TRACKING_URI"] --- .github/workflows/CI.yml | 2 ++ src/types/mlflow.jl | 11 +++++++++-- test/base.jl | 2 +- test/test_functional.jl | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ad25da9..234915b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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: diff --git a/src/types/mlflow.jl b/src/types/mlflow.jl index b11b6ab..9ba467b 100644 --- a/src/types/mlflow.jl +++ b/src/types/mlflow.jl @@ -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 @@ -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)) diff --git a/test/base.jl b/test/base.jl index 1a580dd..2561ed0 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, http://localhost:5000 +# skips test if mlflow is not available on default location, ENV["MLFLOW_TRACKING_URI"] macro ensuremlf() e = quote mlf = MLFlow() diff --git a/test/test_functional.jl b/test/test_functional.jl index ffbea69..5534fc1 100644 --- a/test/test_functional.jl +++ b/test/test_functional.jl @@ -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) From 56479a50382a3188f6e98a733285c3e8e04c3875 Mon Sep 17 00:00:00 2001 From: Jesper Stemann Andersen Date: Mon, 29 Jan 2024 18:10:04 +0100 Subject: [PATCH 2/2] Added dev. container set-up --- .devcontainer/compose.yaml | 14 ++++++++++++++ .devcontainer/devcontainer.json | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 .devcontainer/compose.yaml create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/compose.yaml b/.devcontainer/compose.yaml new file mode 100644 index 0000000..ae4c6bf --- /dev/null +++ b/.devcontainer/compose.yaml @@ -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" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..c33fe33 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -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", + } +}