How to extract artifact names from api.runs() output?

Hi,

It is a very simple question. But I don’t know why the answer is not very easy to find. Here I use wandb.Api().runs() to get the runs for a project. How can I get the model for a run? I need the artifact name but I cannot get it from the run (I do not want to go the overview page of the run to copy the path).

The code:

api = wandb.Api()
runs = api.runs("<entity>/<project-name>")
artifact0 = runs[0].used_artifacts()
artifact0[0].download()

This does not return the model but the job.

Is there a way to get the model or the artifact name from the run?

Hello @haraghi !

You can do this with the following:

api = wandb.Api()
runs = api.runs("<entity>/<project-name>")
artifact0 = runs[0].used_artifacts()
print(artifact0[0].name)

This will print the artifact’s name. If you then want to download the artifact, then you can run.

artifact = api.artifact("<entity>/<project-name>/" + str(artifact0[0].name))
artifact_dir = artifact.download()

Hi Hesam, since we have not heard back from you we are going to close this request. If you would like to re-open the conversation, please let us know!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.