question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Q] Is there any `direct_url` to existing artifact files?

See original GitHub issue

As of the File System, we can easily retrieve the direct_url of a file uploaded to a wandb run, pointing to the Google Storage URL as follows:

import wandb
api = wandb.Api()
file = api.run(f"{entity}/{project}/{run_id}").file(name=file_path)
file.direct_url

Is there any way to actually retrieve the URL to the Google Storage for the Artifact Store files? If not, can it be implemented?

import wandb
api = wandb.Api()
artifact = api.artifact(name=f"{entity}/{project}/{artifact_name}:{artifact_version}", type=artifact_type)
file = artifact.get_path(name=file_path)
file.direct_url

Thanks in advance! 😄

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
thanos-wandbcommented, Sep 13, 2022

Excellent! Thanks for posting this solution @alvarobartt. I also post an alternative option for future reference. Please let me know if that wouldn’t work for you.

import wandb
import base64

api = wandb.Api()
artifact = api.artifact(
  name="wandb/yolo-chess/run_1dnrszzr_model:v8",
  type="model",
)
id = artifact.id
hid = wandb.util.b64_to_hex_id(artifact._load_manifest().entries["last.pt"].digest)
print(f"https://api.wandb.ai/artifactsV2/gcp-us/{artifact.entity}/{id}/{hid}")
0reactions
thanos-wandbcommented, Sep 20, 2022

Hi @alvarobartt thanks for the additional context. Since you’re interested only to specific filename you could then replace your last two lines with something like the following:

f = list(artifact.files(names=['last.pt'], per_page=1000))
print(f[0].url)

You can have multiple filenames in there and access their attributes from the created list. The artifact.files is an iterator of File objects (which are the ones with the url method).

Regarding the issue with artifact._files this should be fixed if you upgrade to the most recent version according to this commit. Hope this helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Job artifacts - GitLab Docs
Jobs can output an archive of files and directories. This output is known as a job artifact. You can download job artifacts by...
Read more >
How can I download a specific Maven artifact in one command ...
Use the command mvn dependency:get to download the specific artifact and use the command mvn dependency:copy to copy the downloaded artifact to the...
Read more >
Upstream sources overview - Azure Artifacts - Microsoft Learn
Upstream sources enable you to use a single feed to store packages from different sources: the ones you publish and the ones you...
Read more >
[RTFACT-26432] URL to File no longer a direct link to file - Jira
Navigate to Artifact in UI. Click link provided next to "URL to file". Artifactory redirects to an index page for the file before...
Read more >
Creating links to artifacts | E-Portfolio_Mechanics
Select Web address on the left and paste the copied URL into the space marked: Link to this URL. If you want the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found