You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Since a run can use another run’s output artifact as input, artifacts and runs together form a directed graph. You don’t need to define pipelines ahead of time. Just use and log artifacts, and we’ll stitch everything together."
46
+
]
47
+
},
48
+
{
49
+
"cell_type": "markdown",
50
+
"metadata": {
51
+
"id": "G03d9HSHuKF9"
52
+
},
53
+
"source": [
54
+
"## 1. Install Weights & Biases"
55
+
]
56
+
},
57
+
{
58
+
"cell_type": "code",
59
+
"metadata": {
60
+
"id": "Ny-d-pHrnrui"
61
+
},
62
+
"source": [
63
+
"# Install Weights & Biases\n",
64
+
"!pip install wandb -qqq\n",
65
+
"\n",
66
+
"import os\n",
67
+
"import random\n",
68
+
"import wandb"
69
+
],
70
+
"execution_count": null,
71
+
"outputs": []
72
+
},
73
+
{
74
+
"cell_type": "markdown",
75
+
"metadata": {
76
+
"id": "4PE2_FgKodSi"
77
+
},
78
+
"source": [
79
+
"## 2. Create an Artifact\n",
80
+
"\n",
81
+
"Call `wandb.init` to initialize a new run. Use a run to track any script in your pipeline— anything from training and evaluation to scraping and preprocessing data. Specify what type of run it is in the **job_type**, and you'll be able to filter and group based on **job_type** in the web interface.\n",
82
+
"\n",
83
+
"`wandb.Artifact()`\n",
84
+
"- **name**: The name of this dataset, model, or other set of files. The files inside can change, but the name stays the same across versions.\n",
85
+
"- **type**: This helps you group together top-level artifacts, like \"dataset\" and \"model\".\n",
86
+
"- **metadata**: This dictionary lets you track class distributions, UUIDs, and any important details you want to save and search over later."
87
+
]
88
+
},
89
+
{
90
+
"cell_type": "code",
91
+
"metadata": {
92
+
"id": "tHvfBXS0oig1"
93
+
},
94
+
"source": [
95
+
"# This will create a new run in the W&B database.\n",
96
+
"# Init starts tracking stdout/stderr and system metrics automatically.\n",
"# This time we'll use artifact.add_file, to add a file that already exists.\n",
173
+
"f = open('mymodel.txt', 'w')\n",
174
+
"f.write('This is a really awesome trained model: %s' % random.random())\n",
175
+
"f.close()\n",
176
+
"\n",
177
+
"artifact.add_file('mymodel.txt')\n",
178
+
"run.log_artifact(artifact)\n",
179
+
"\n",
180
+
"# end the current run\n",
181
+
"run.finish()"
182
+
],
183
+
"execution_count": null,
184
+
"outputs": []
185
+
},
186
+
{
187
+
"cell_type": "markdown",
188
+
"metadata": {
189
+
"id": "Z9lxlSqnsY8I"
190
+
},
191
+
"source": [
192
+
"Now you can navigate to your project page (linked above), and then click on the artifacts tab, to dig into all the artifacts you've created so far.\n",
193
+
"\n",
194
+
"If you click through to an artifact, and then click on the \"Graph\" tab, you'll see a visualization that shows how your artifacts and runs are related to each other."
195
+
]
196
+
},
197
+
{
198
+
"cell_type": "markdown",
199
+
"metadata": {
200
+
"id": "J3JeRwj_2oG-"
201
+
},
202
+
"source": [
203
+
"## Documentation\n",
204
+
"\n",
205
+
"For more details, [see the docs →](https://docs.wandb.com/artifacts)\n",
206
+
"- Storing directories in artifacts\n",
207
+
"- Referring to external data using references\n",
208
+
"- Automatic file and artifact deduplication\n",
209
+
"- Best practices for dataset versioning and model management"
0 commit comments