Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(artifacts): add save() method on ArtifactCollection to allow persisting changes #7555

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Please add to the relevant subsections under Unreleased below on every PR where
### Added

* Display warning when Kubernetes pod fails to schedule by @TimH98 in https://github.com/wandb/wandb/pull/7576
* Added `ArtifactCollection.save()` by @amusipatla-wandb in https://github.com/wandb/wandb/pull/7555

### Deprecated

* Deprecated `ArtifactCollection.change_type()` in favor of `ArtifactCollection.save()` by @amusipatla-wandb in https://github.com/wandb/wandb/pull/7555

## [0.17.0] - 2024-05-07

Expand Down
70 changes: 41 additions & 29 deletions core/pkg/service/wandb_telemetry.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,65 @@ def test_change_artifact_collection_type(monkeypatch, wandb_init):
assert artifact.type == "lucas_type"


def test_save_artifact_sequence(monkeypatch, wandb_init):
with wandb_init() as run:
artifact = wandb.Artifact("sequence_name", "data")
run.log_artifact(artifact)
artifact.wait()

artifact = run.use_artifact("sequence_name:latest")
collection = wandb.Api().artifact_collection("data", "sequence_name")
collection.description = "new description"
collection.name = "new_name"
collection.type = "new_type"
collection.tags = ["tag"]
collection.save()

artifact = run.use_artifact("new_name:latest")
assert artifact.type == "new_type"
collection = artifact.collection
assert collection.type == "new_type"
assert collection.name == "new_name"
assert collection.description == "new description"
assert len(collection.tags) == 1 and collection.tags[0] == "tag"

collection.tags = ["new_tag"]
collection.save()

artifact = run.use_artifact("new_name:latest")
collection = artifact.collection
assert len(collection.tags) == 1 and collection.tags[0] == "new_tag"


def test_save_artifact_portfolio(monkeypatch, wandb_init):
with wandb_init() as run:
artifact = wandb.Artifact("image_data", "data")
run.log_artifact(artifact)
artifact.link("portfolio_name")
artifact.wait()

portfolio = wandb.Api().artifact_collection("data", "portfolio_name")
portfolio.description = "new description"
portfolio.name = "new_name"
with pytest.raises(ValueError):
portfolio.type = "new_type"
portfolio.tags = ["tag"]
portfolio.save()

port_artifact = run.use_artifact("new_name:v0")
portfolio = port_artifact.collection
assert portfolio.name == "new_name"
assert portfolio.description == "new description"
assert len(portfolio.tags) == 1 and portfolio.tags[0] == "tag"

portfolio.tags = ["new_tag"]
portfolio.save()

artifact = run.use_artifact("new_name:latest")
portfolio = artifact.collection
assert len(portfolio.tags) == 1 and portfolio.tags[0] == "new_tag"


def test_s3_storage_handler_load_path_missing_reference_allowed(
monkeypatch, wandb_init, capsys
):
Expand Down