Skip to content

Artificact upload for remote instances #45

Open
@freemin7

Description

@freemin7

As per https://github.com/JuliaAI/MLFlowClient.jl/blob/a31b41a91dc32107fa7dcd6ad5a581c116a4ff9c/src/loggers.jl#L69-72 we currently can't upload artifacts to remote servers

    Assumes that artifact_uri is mapped to a local directory.
    At the moment, this only works if both MLFlow and the client are running on the same host or they map a directory that leads to the same location over NFS, for example.

Some (untested) code along the lines of:

function logartifact(mlf::GitLabMLFlow, run_id::AbstractString, basefilename::AbstractString, data)
    mlflowrun = getrun(mlf, run_id)
    artifact_uri = mlflowrun.info.artifact_uri
    filepath = joinpath(artifact_uri, basefilename)
    try
        HTTP.post(url, push!(copy(mlf.headers), "Content-Type" => "multipart/form-data" ),
            HTTP.Form(Dict(:file => data)))
    catch e
        error("Unable to upload $(filepath): $e")
    end
    filepath
end

Would probably work for this purpose and not introduce new dependencies.
The question remains how to differentiate between local and remote file access, as they happen through different interfaces (the headers are irrelevant for file access for example).

I see three options to approach this and would be interested in making a pull request implementing one of these and testing them against a local mlflow instance and the gitlab end points to confirm they are working (for me).

  1. Use a different subtype of AbstractMLFlow to denote remote instances. (Probably not preferred)
  2. Keep using a String and just have an if checking for prefixes of "https://" and use HTTP then.
  3. Switch to using URIs and use file:// to denote file access and check the prefix in an if statement.

This is simply a question of taste i would leave to (some of) the maintainers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions