| 32 | return run_dir |
| 33 | |
| 34 | def 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 | |
| 54 | def test_download_artifact(run): |
| 55 | |