From 865f2002d07bc38f1d734ef0479131e4ac807bba Mon Sep 17 00:00:00 2001 From: characat0 <36453977+characat0@users.noreply.github.com> Date: Sat, 28 Sep 2024 00:10:37 -0500 Subject: [PATCH 1/4] add user and password auth --- src/MLFlowClient.jl | 1 + src/types/mlflow.jl | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/MLFlowClient.jl b/src/MLFlowClient.jl index b9a179a..e4c8627 100644 --- a/src/MLFlowClient.jl +++ b/src/MLFlowClient.jl @@ -15,6 +15,7 @@ module MLFlowClient using Dates using UUIDs using HTTP +using HTTP.Base64 using URIs using JSON using ShowCases diff --git a/src/types/mlflow.jl b/src/types/mlflow.jl index 326a0ff..8b1bb47 100644 --- a/src/types/mlflow.jl +++ b/src/types/mlflow.jl @@ -31,7 +31,21 @@ struct MLFlow apiversion::Union{Integer, AbstractFloat} headers::Dict end -MLFlow(apiroot; apiversion=2.0, headers=Dict()) = MLFlow(apiroot, apiversion, headers) + +function MLFlow( + apiroot; + user=get(ENV, "MLFLOW_TRACKING_USERNAME", missing), + password=get(ENV, "MLFLOW_TRACKING_PASSWORD", missing), + apiversion=2.0, + headers=Dict() + ) + if !ismissing(user) && !ismissing(password) + token = base64encode("$(user):$(password)") + headers["Authorization"] = "Basic $(token)" + end + return MLFlow(apiroot, apiversion, headers) +end + function MLFlow() apiroot = "http://localhost:5000/api" if haskey(ENV, "MLFLOW_TRACKING_URI") From 063651217ec4318903536b7d5b1909de7931cba2 Mon Sep 17 00:00:00 2001 From: characat0 <36453977+characat0@users.noreply.github.com> Date: Sat, 28 Sep 2024 00:13:50 -0500 Subject: [PATCH 2/4] change docstring --- src/types/mlflow.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/types/mlflow.jl b/src/types/mlflow.jl index 8b1bb47..a251497 100644 --- a/src/types/mlflow.jl +++ b/src/types/mlflow.jl @@ -11,7 +11,8 @@ Default is `false`, using the REST API endpoint. # Constructors -- `MLFlow(apiroot; apiversion=2.0,headers=Dict())` +- `MLFlow(apiroot; user, password, apiversion=2.0, headers=Dict())` - this constructor will check env +variables `MLFLOW_TRACKING_USERNAME` and `MLFLOW_TRACKING_PASSWORD` for credentials. - `MLFlow()` - defaults to `MLFlow(ENV["MLFLOW_TRACKING_URI"])` or `MLFlow("http://localhost:5000/api")` # Examples From 118c7da3c6152df5f7cc8eb2b2f8e03e06c37a04 Mon Sep 17 00:00:00 2001 From: characat0 <36453977+characat0@users.noreply.github.com> Date: Sat, 28 Sep 2024 00:16:18 -0500 Subject: [PATCH 3/4] install Base64 independently from HTTP --- Project.toml | 2 +- src/MLFlowClient.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 59d3b69..c7c8b5e 100644 --- a/Project.toml +++ b/Project.toml @@ -4,6 +4,7 @@ authors = ["@deyandyankov, @pebeto, and contributors"] version = "0.5.1" [deps] +Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f" HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" @@ -25,4 +26,3 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] test = ["Test"] - diff --git a/src/MLFlowClient.jl b/src/MLFlowClient.jl index e4c8627..44091ed 100644 --- a/src/MLFlowClient.jl +++ b/src/MLFlowClient.jl @@ -15,7 +15,7 @@ module MLFlowClient using Dates using UUIDs using HTTP -using HTTP.Base64 +using Base64 using URIs using JSON using ShowCases From 0a92b04f5244bdd458ff3e6b03d1e6f2caaffec8 Mon Sep 17 00:00:00 2001 From: Jose Esparza Date: Wed, 12 Feb 2025 02:58:18 -0500 Subject: [PATCH 4/4] Removing version restriction from `Base64` dependency by generalizing it to `1.0` --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 2d033b3..a27b71b 100644 --- a/Project.toml +++ b/Project.toml @@ -13,7 +13,7 @@ URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [compat] -Base64 = "1.11.0" +Base64 = "1.0" HTTP = "1.0" JSON = "0.21" ShowCases = "0.1"