MCPcopy Create free account
hub / github.com/OpenRL-Lab/Wandb_Tutorial / test_download_artifact

Function test_download_artifact

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

Source from the content-addressed store, hash-verified

52 run.log_artifact(raw_data)
53
54def test_download_artifact(run):
55
56 # 对数据进行预处理后,再进行保存
57 steps = {"normalize": True,
58 "expand_dims": True}
59 processed_data = wandb.Artifact(
60 "mnist-preprocess", type="dataset",
61 description="Preprocessed MNIST dataset",
62 metadata=steps)
63
64 # ✔️ declare which artifact we'll be using
65 raw_data_artifact = run.use_artifact('mnist-origin:latest')
66
67 # 📥 if need be, download the artifact
68 raw_dataset = raw_data_artifact.download()
69
70 for split in ["training"]:
71 raw_split = read(raw_dataset, split)
72 processed_dataset = preprocess(raw_split, **steps)
73
74 with processed_data.new_file(split + ".pt", mode="wb") as file:
75 x, y = processed_dataset.tensors
76 torch.save((x, y), file)
77
78 run.log_artifact(processed_data)
79
80def count_down(duration:int):
81 for remaining in range(duration, 0, -1):

Callers 1

test_artifactFunction · 0.85

Calls 3

readFunction · 0.90
preprocessFunction · 0.90
downloadMethod · 0.80

Tested by

no test coverage detected