MCPcopy Index your code
hub / github.com/OpenRL-Lab/Wandb_Tutorial / test_upload_artifact

Function test_upload_artifact

artifact/test_artifact.py:34–52  ·  view source on GitHub ↗
(run)

Source from the content-addressed store, hash-verified

32 return run_dir
33
34def test_upload_artifact(run):
35 datasets = load() # separate code for loading the datasets
36 names = ["training"]
37
38 # 🏺 create our Artifact
39 raw_data = wandb.Artifact(
40 "mnist-origin", type="dataset",
41 description="Raw MNIST dataset, split into train/val/test",
42 metadata={"source": "torchvision.datasets.MNIST",
43 "sizes": [len(dataset) for dataset in datasets]})
44
45 for name, data in zip(names, datasets):
46 # 🐣 Store a new file in the artifact, and write something into its contents.
47 with raw_data.new_file(name + ".pt", mode="wb") as file:
48 x, y = data.tensors
49 torch.save((x, y), file)
50
51 # ✍️ Save the artifact to W&B.
52 run.log_artifact(raw_data)
53
54def test_download_artifact(run):
55

Callers 1

test_artifactFunction · 0.85

Calls 1

loadFunction · 0.90

Tested by

no test coverage detected