Skip to content

Commit

Permalink
feat(artifacts): add save() method on ArtifactCollection to allow per…
Browse files Browse the repository at this point in the history
…sisting changes (#7528)
  • Loading branch information
amusipatla-wandb committed May 20, 2024
1 parent 0383350 commit 15f4422
Show file tree
Hide file tree
Showing 10 changed files with 405 additions and 82 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ 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()` to allow persisting changes by @amusipatla-wandb in https://github.com/wandb/wandb/pull/7555

### Fixed

Expand All @@ -24,6 +25,10 @@ Please add to the relevant subsections under Unreleased below on every PR where

- Require `unsafe=True` in `use_model` calls that could potentially load and deserialize unsafe pickle files by @anandwandb https://github.com/wandb/wandb/pull/7663

### 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

### Added
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
Loading

0 comments on commit 15f4422

Please sign in to comment.