Skip to content

Commit

Permalink
New Artifact version section.
Browse files Browse the repository at this point in the history
  • Loading branch information
katjacksonWB committed May 31, 2024
1 parent 69d71d1 commit 57ad97c
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions colabs/artifact_basics/Artifact_Basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
"outputs": [],
"source": [
"run = wandb.init(project=\"artifact-basics\")\n",
"artifact = run.use_artifact(artifact_or_name=\"my_first_artifact:latest\") # selects the artifact you're adding the file to\n",
"artifact = run.use_artifact(\"my_first_artifact:latest\") # selects the artifact you're adding the file to\n",
"artifact.add_file(local_path=\"/content/sample_data/california_housing_test.csv\", name=\"new_file\")\n",
"run.log_artifact(artifact)\n",
"run.finish()"
Expand All @@ -205,7 +205,7 @@
"source": [
"This adds a new .csv file called `new_file` to the `my_first_artifact` Artifact. \n",
"\n",
"Optionally, you can choose to add an entire directory to an Artifact:"
"If you edit a file, you'll need to go through a similar process:"
]
},
{
Expand All @@ -214,20 +214,28 @@
"metadata": {},
"outputs": [],
"source": [
"# sorts the .csv file\n",
"import pandas\n",
"csvData = pandas.read_csv(\"/content/sample_data/california_housing_test.csv\") \n",
"csvData.sort_values(csvData.columns[6], \n",
" axis=0, \n",
" inplace=True)\n",
"csvData.to_csv(\"/content/sample_data/california_housing_test.csv\") # overwrites file with the sorted data\n",
"# adds the new file to the artifact\n",
"run = wandb.init(project=\"artifact-basics\")\n",
"artifact = run.use_artifact(\"my_first_artifact:latest\") # selects the artifact you're adding the file to, and makes a new artifact version\n",
"artifact.add_dir(local_path=\"/content/sample_data\", name=\"new_directory\")\n",
"run.log_artifact(artifact, aliases= [\"sorted\",\"cleaned\"])\n",
"run.finish()"
"artifact = run.use_artifact(\"my_first_artifact:latest\")\n",
"artifact.add_file(local_path=\"/content/sample_data/california_housing_test.csv\", name=\"sorted_file\")\n",
"run.log_artifact(artifact, aliases= [\"sorted\"]) # logs the new artifact version, overwriting the old one.\n",
"run.finish()\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This adds a new version of `my_first_artifact` with an entire folder with several .csv files. To save your changes, you'll need to [`log`](https://docs.wandb.ai/ref/python/log) or [`save`](https://docs.wandb.ai/ref/python/artifact#save) them. The new version will overwrite the contents of the previous version of the Artifact.\n",
"Now the sorted file will be logged in `my_first_artifact`. Any changes you log to an artifact will overwrite any older version. \n",
"\n",
"The Artifact has also been given a custom `aliases`, a label for this Artifact version. While the `alias` is currently `staging`, the default aliases is `vN`, where `N` is the number of versions the Artifact has. This increments automatically."
"The Artifact has also been given a custom `alias`, a label for this Artifact version. While the `alias` is currently `sorted`, the default aliases is `vN`, where `N` is the number of versions the Artifact has. This increments automatically."
]
},
{
Expand Down Expand Up @@ -343,7 +351,7 @@
"2. [Lineage](https://docs.wandb.ai/guides/artifacts/explore-and-traverse-an-artifact-graph): View lineage graphs, which are automatically built when using W&B artifact system, providing an auditable visual overview of the relationships between specific artifact versions, datasets models and runs.\n",
"3. [Model Registry](https://docs.wandb.ai/guides/model_registry): Learn how to centralize your best artifact versions in a shared registry.\n",
"4. [Artifact Automations](https://docs.wandb.ai/guides/artifacts/project-scoped-automations): Automatically run specific Weights & Biases jobs based on changes to your artifacts, such as automatically training a new model each time a new version of the training data is logged.\n",
"5. [Artifacts FAQ](https://docs.wandb.ai/guides/artifacts/artifacts-faqs): Frequently asked questions on Artifact security, workflows, and retention policy."
"5. [Reference Artifacts](https://docs.wandb.ai/guides/artifacts/track-external-files#download-a-reference-artifact): Track files saved outside the W&B server, like Amazon S3 buckets, GCS buckets, Azure blobs, and more. "
]
}
],
Expand Down

0 comments on commit 57ad97c

Please sign in to comment.