MLFlowClient.jl icon indicating copy to clipboard operation
MLFlowClient.jl copied to clipboard

Integrate with DagsHub's MLflow API

Open math4mad opened this issue 1 year ago • 6 comments

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

math4mad avatar Jan 07 '24 07:01 math4mad

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.

pebeto avatar Jan 07 '24 20:01 pebeto

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 username and password.

I'm thinking about improving the way we are defining credentials:

  • username and password can be passed in a NamedTuple directly by an auth parameter in MLFlow type constructor. The same case if we are using a token (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

pebeto avatar Jan 07 '24 23:01 pebeto

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

ablaom avatar Jan 09 '24 02:01 ablaom

@deyandyankov Can you please comment on @pebeto's proposal?

ablaom avatar Jan 16 '24 22:01 ablaom

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.

deyandyankov avatar Jan 17 '24 10:01 deyandyankov

@pebeto

at now still can't work with remote url of dagshub. could give me a hint? using python api it is ok

math4mad avatar Jan 18 '24 08:01 math4mad