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.

Is it possible to force upload of a newly created artifact without finishing the run?

See original GitHub issue

wandb version: 10.0.9 Python: 3.6.12 OS: Win 10

The workflow of my work with artifacts looks like this: I’m uploading multiple versions of an artifact during DL training, and then at the end of the script, I want to get a version of this artifact with a certain label.

Like this:

import torch
import wandb

wandb.init(project='Test')
run = wandb.run

artifact_name = 'Test-checkpoint'

# Do something 0...
# v0
artifact = wandb.Artifact(artifact_name, type='checkpoint')
artifact.add_file('./wandb/artifacts/42wsedgy/checkpoint_0.pth')
run.log_artifact(artifact)

# Do something 1...
# v1
artifact = wandb.Artifact(artifact_name, type='checkpoint')
artifact.add_file('./wandb/artifacts/42wsedgy/checkpoint_1.pth')
run.log_artifact(artifact)

# Do something 2...
# v2
artifact = wandb.Artifact(artifact_name, type='checkpoint')
artifact.add_file('./wandb/artifacts/42wsedgy/checkpoint_3.pth')
run.log_artifact(artifact)

# run.finish() #### QUESTION is about this line -- any other way to force artifacts upload? 

# Sometime later.. in another part of the system
# Now try to get the latest of that artifact
api = wandb.Api({'project': 'Test'})
artifact = api.artifact(name=artifact_name + ':latest', type='checkpoint')
# OR
# artifact = run.use_artifact(artifact_name + ':latest', type='checkpoint') 
# OR
# artifact = run.use_artifact(artifact)
filepath = artifact.download()
print(filepath)

When I use run.finish(), the artifact that gets downloaded is the one expected: Test-checkpoint-v2 If I don’t want to finish the run and remove the line with run.finish(), I get different erroneous outcomes:

  • the error ValueError: Project maria_korosteleva/Test does not contain artifact: "Test-checkpoint:latest" (I guess when none of the versions got a chance to be uploaded)
  • If use run.use_artifact(artifact) instead of api.artifact() to get artifact object, the error is ValueError: Cannot call download on an artifact before it has been saved
  • Sometimes I just get the wrong version: e.g. Test-checkpoint-v1 instead of Test-checkpoint-v2

So, is it possible to force upload artifacts versions so that I won’t have to finish the run to get the correct files?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
maria-korostelevacommented, Dec 8, 2020

@ariG23498 oh, right, the suggested solutions helps in most cases, thanks!

0reactions
ariG23498commented, Dec 8, 2020

Hey @maria-korosteleva Would you like to close the issue if the suggested solution helps you? 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to force upload of a newly created artifact without ...
When run.finish is called we block your process while all artifacts finish downloading. We will eventually add a method for you to call...
Read more >
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 >
Gitlab pipeline test stage to fail AND create artifacts anyway
I had the same question, but it's easily solved: You can use artifacts:when to upload artifacts on job failure or despite the failure....
Read more >
Pipeline run sequence - Azure - Microsoft Learn
Logs can be downloaded once the pipeline has finished. Other items that the agent can upload include artifacts and test results.
Read more >
7 Github Actions Tricks I Wish I Knew Before I Started
Not only that, it will also trigger for any push to the branch that is initiating the pull request. This is a good...
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