Integrate with DagsHub's MLflow API
According with this part dagshub mlflow integrations
how to fill params of headers
mlf = MLFlow("https://dagshub.com/math4mad/mlj-test.mlflow";headers=Dict("MLFLOW_TRACKING_USERNAME"=>"******","MLFLOW_TRACKING_PASSWORD"=>"********" ))
# Initiate new experiment
experiment_id = createexperiment(mlf; name="price-paths")
# Create a run in the new experiment
exprun = createrun(mlf, experiment_id)
follow Set-up your credentials setting name and token , now it not working
Hello @math4mad.
That's not the way to authenticate into an mlflow instance. To achieve this, we need to have our base64-encoded credentials and pass it through the authorization header.
# "credentials" is a base64-encoded string
credentials = "<your_username>:<your_password>"
MLFlow(<your_base_uri>; headers=Dict("Authorization" => "Basic $credentials"))
This is an ugly way to send authorizations. I'm going to make it pretty.
However, you can't use this package because it is supporting the modern /api endpoint instead of /ajax-api (the one Dagshub is using). I just reviewed that the last mentioned is used in almost every scenario, so I will adapt that to ensure the compatibility.
This last change is using the generic /ajax-api prefix on each endpoint to allow compatibility with different platforms.
Notes:
- Original MLFlow instances use base64 to encode authorization headers (based on the Basic Authorization defined here)
- During my testing, Dagshub is allowing both raw and base64-encoded
usernameandpassword.
I'm thinking about improving the way we are defining credentials:
usernameandpasswordcan be passed in a NamedTuple directly by anauthparameter inMLFlowtype constructor. The same case if we are using atoken(it becomes a Bearer Auth). In the headers function, we are going to do checks and logic to add that info to the request.
## Old way
using Base64
using MLFlowClient
credentials = base64encode("missy:gala")
MLFlow("http://localhost:5000"; headers=Dict("Authorization"=>"Basic $credentials"))
## New way
using MLFlowClient
MLFlow("http://localhost:5000"; auth=("username"=>"missy", "password"=>"gala"))
@ablaom @deyandyankov
Thanks @pebeto for taking the lead here.
Your suggestion sounds reasonable to me, but would be good to get @deyandyankov's view. Are you adding auth as a new keyword but keeping headers for passing other stuff? Or removing headers altogether?
Instead of auth, I suggest authorisation - abbreviations are hindrance to non-English speakers and sometimes difficult to remember
@deyandyankov Can you please comment on @pebeto's proposal?
I think having both authorisation and headers makes sense. Probably need to consider the case when both authorisation and headers=Dict("Authorization"=>"Basic $credentials")) have been supplied, but that would be a user error anyway.
@pebeto
at now still can't work with remote url of dagshub. could give me a hint? using python api it is ok