Skip to content

Commit

Permalink
Adds new section.
Browse files Browse the repository at this point in the history
  • Loading branch information
katjacksonWB committed May 20, 2024
1 parent e2f825c commit 4d9573f
Showing 1 changed file with 80 additions and 24 deletions.
104 changes: 80 additions & 24 deletions colabs/artifact_basics/Artifact_Basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -166,53 +166,64 @@
{
"cell_type": "markdown",
"metadata": {
"id": "o-rcMsZYh0Ig"
"id": "u60Orwg5sYuI"
},
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Download an Artifact"
"# Change an Artifact"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "u60Orwg5sYuI"
},
"source": []
"metadata": {},
"source": [
"When you need add a new file, you can use the `artifact.add_file` method."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"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.add_file(local_path=\"/content/sample_data/california_housing_test.csv\", name=\"new_file\")\n",
"run.finish()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "B2ssTI7LrHS8"
},
"metadata": {},
"source": [
"To retrieve the path of an Artifact for external use, use the `artifact.download()` method. This will retrieve the directory of an Artifact you select."
"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:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "18-7Kd9Oh8cl"
},
"metadata": {},
"outputs": [],
"source": [
"run = wandb.init(project=\"artifact-basics\")\n",
"artifact = run.use_artifact(artifact_or_name=\"my_first_artifact:latest\")\n",
"# downloads the artifact to a directory on the W&B platform.\n",
"datadir = artifact.download()\n",
"run.finish()\n",
"# prints the current artifact directory\n",
"print(u'\\u2500' * 10)\n",
"print(\"Data directory located at:\" + datadir)"
"artifact = run.use_artifact(artifact_or_name=\"my_first_artifact:latest\") # selects the artifact you're adding the file to\n",
"artifact.add_dir(local_path=\"/content/sample_data\", name=\"new_directory\")\n",
"run.finish()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "sxox0H9grrcx"
},
"metadata": {},
"source": [
"For more information on ways to customize your Artifact download, see the [Download and Usage guide](https://docs.wandb.ai/guides/artifacts/download-and-use-an-artifact)."
"This adds an entire folder with several .csv files to your Artifact.\n",
"\n",
"To save your changes, you'll need to `log` them, which is covered in the next section."
]
},
{
Expand Down Expand Up @@ -251,6 +262,51 @@
"run.finish()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "o-rcMsZYh0Ig"
},
"source": [
"# Download an Artifact"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "B2ssTI7LrHS8"
},
"source": [
"To retrieve the path of an Artifact for external use, use the `artifact.download()` method. This will retrieve the directory of an Artifact you select."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "18-7Kd9Oh8cl"
},
"outputs": [],
"source": [
"run = wandb.init(project=\"artifact-basics\")\n",
"artifact = run.use_artifact(artifact_or_name=\"my_first_artifact:latest\")\n",
"# downloads the artifact to a directory on the W&B platform.\n",
"datadir = artifact.download()\n",
"run.finish()\n",
"# prints the current artifact directory\n",
"print(u'\\u2500' * 10)\n",
"print(\"Data directory located at:\" + datadir)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "sxox0H9grrcx"
},
"source": [
"For more information on ways to customize your Artifact download, see the [Download and Usage guide](https://docs.wandb.ai/guides/artifacts/download-and-use-an-artifact)."
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down

0 comments on commit 4d9573f

Please sign in to comment.