Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to log model? #24

Closed
mashu opened this issue Nov 15, 2022 · 4 comments
Closed

How to log model? #24

mashu opened this issue Nov 15, 2022 · 4 comments

Comments

@mashu
Copy link

mashu commented Nov 15, 2022

Hi,

It would be great if there was an example showing how to log model architecture
Is that possible currently ?

@john-waczak
Copy link

^ I was just looking for the same. Is the only way to log the models via saving them as artifacts? If so, what would it take to set up model logging? I'd be happy to take a crack at it!

@mcamp-ata
Copy link

I dont know how much ehlp this is but this is what I have crafted to be able to do this kind of...

using AWSS3
using AWS: global_aws_config, AWSConfig
using Minio


function logImgArtifact(mlf,exprun,img;
  artifactName="$(Dates.datetime2unix(now())).png",
  s3cfg=MinioConfig("https://s3-api.lan.example.com", s3creds; region="us-east-1")
)
  save(artifactName, img)
  bucket = logartifact(mlf,exprun,artifactName)
  object_name = basename(bucket)
  open(artifactName, "r") do file
      file_data = read(file)
      Minio.s3_put(s3cfg, dirname(bucket)[6:end], object_name, file_data)
  end
  rm(artifactName)
  bucket
end


function logModelArtifact(mlf,exprun,model_state;
  artifactName="$(Dates.datetime2unix(now())).jld2",
  s3cfg=MinioConfig("https://s3-api.lan.example.com", s3creds; region="us-east-1")
)
  model_state = model_state |> cpu
  jldsave(artifactName, model_state=model_state)
  bucket = logartifact(mlf,exprun,artifactName)
  object_name = basename(bucket)
  open(artifactName, "r") do file
      file_data = read(file)
      Minio.s3_put(s3cfg, dirname(bucket)[6:end], object_name, file_data)
  end
  rm(artifactName)
  bucket
end

It just saves the model as an artifact that is in an s3 bucket. I'm currently exploring what needs to be done to make show up as an actual model in MLFlow.

@mashu
Copy link
Author

mashu commented Dec 19, 2023

Tieing to one commercial solution such as AWS might not be very generic. Artifacts can already be logged.

@mcamp-ata
Copy link

mcamp-ata commented Dec 19, 2023

when I used the log function it just returns me a path, it doesn't save the files to the artifact location defined in the experiment (S3 bucket in my mlflow case). I wrote those two functions to make my life a little easier for pushing the artifacts to S3. And this doesn't tie you to AWS. I am actually using a self hosted Minio S3 instance.

@pebeto pebeto closed this as completed May 17, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants