Skip to content

Commit

Permalink
Replaced hardcoded entities
Browse files Browse the repository at this point in the history
  • Loading branch information
ngrayluna committed Sep 9, 2024
1 parent 4d98b37 commit c8ebac8
Showing 1 changed file with 47 additions and 16 deletions.
63 changes: 47 additions & 16 deletions colabs/wandb_registry/zoo_wandb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "822e8bc6",
"metadata": {},
"source": [
"<a href=\"https://colab.research.google.com/github/wandb/examples/blob/master/colabs/wandb_registry/zoo_wandb.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
Expand Down Expand Up @@ -33,7 +34,7 @@
"source": [
"The goal of this notebook is to demonstrate how you and other members of your organization can use W&B Registry to track, share, and use dataset and model artifacts in your machine learning workflows. By the end of this notebook, you will know how to use W&B to:\n",
"\n",
"1. Create [collections](https://docs.wandb.ai/guides/registry/create_collection) within the [W&B Registry](https://docs.wandb.ai/guides/registry)\n",
"1. Create [collections](https://docs.wandb.ai/guides/registry/create_collection) within [W&B Registry](https://docs.wandb.ai/guides/registry)\n",
"2. Make dataset and model artifacts available to other members of your organization, and\n",
"3. Download your trained model and dataset artifacts from the registry for inference\n",
"\n",
Expand Down Expand Up @@ -194,7 +195,7 @@
"#### Define target path of the collection\n",
"\n",
"The target path of a collection consists of three parts:\n",
"* The name of the organization\n",
"* The name of your W&B Organization\n",
"* The name of the registry\n",
"* The name of the collection within the registry\n",
"\n",
Expand All @@ -217,7 +218,9 @@
"1. Initialize a run\n",
"1. Create an Artifact object\n",
"2. Add each split dataset as individual files to the artifact object\n",
"3. Link the artifact object to the collection with `run.link_artifact()`. Here we specify the target path and the artifact we want to link."
"3. Link the artifact object to the collection with `run.link_artifact()`. Here we specify the target path and the artifact we want to link.\n",
"\n",
"First, let's create the target path. In the following code cell, replace the values specified in `<>` with the name of your organization:"
]
},
{
Expand All @@ -227,23 +230,31 @@
"metadata": {},
"outputs": [],
"source": [
"ORG_NAME = \"smle-registries-bug-bash\"\n",
"ORG_NAME = \"<INSERT-YOUR-ORG-NAME>\"\n",
"REGISTRY_NAME = \"Dataset\"\n",
"COLLECTION_NAME = \"zoo-dataset-tensors\"\n",
"\n",
"# Path to link the artifact to a collection\n",
"dataset_target_path = f\"{ORG_NAME}/wandb-registry-{REGISTRY_NAME}/{COLLECTION_NAME}\""
]
},
{
"cell_type": "markdown",
"id": "66d03210-1de4-44a4-9773-67b4f5d71dfc",
"metadata": {},
"source": [
"Now that we have the target path, let's publish the dataset to the \"Dataset\" registry. In the following code cell, ensure to replace the values enclosed in `<>` with your team's entity:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "742c237c-1e8d-4c2e-8ac4-8221146d876e",
"metadata": {},
"outputs": [],
"source": [
"TEAM_ENTITY = \"<TEAM_A>\"\n",
"PROJECT = \"zoo_experiment\"\n",
"TEAM_ENTITY = \"smle-reg-team-2\"\n",
"\n",
"run = wandb.init(\n",
" entity=TEAM_ENTITY,\n",
Expand All @@ -253,7 +264,7 @@
"\n",
"artifact = wandb.Artifact(\n",
" name=\"zoo_dataset\",\n",
" type=\"dataset\", \n",
" type=\"dataset\", \n",
" description=\"Processed dataset and labels.\"\n",
")\n",
"\n",
Expand Down Expand Up @@ -615,7 +626,6 @@
"metadata": {},
"outputs": [],
"source": [
"ORG_NAME = \"smle-registries-bug-bash\"\n",
"REGISTRY_NAME = \"Model\"\n",
"COLLECTION_NAME = \"Zoo_Classifier_Models\"\n",
"\n",
Expand Down Expand Up @@ -686,12 +696,11 @@
"---\n",
"## Download artifacts from registry for inference\n",
"\n",
"For this last section, suppose you are in a different user on a different team (within the same organiztion) than the user who uploaded the artifact. You want to retrieve the model and dataset artifact pushed to the registry and make predictions with a new test set. Your team is called \"smle-reg-team-1\" (previously the team was \"smle-reg-team-2\") and your team is working on analyzing zoo models in a project called \"Compare_Zoo_Models\".\n",
"For this last section, suppose you are a different user in a different team within the same organization. You and your team want to download the model and test dataset that was published to your organization's registry by a different team. You and your team will use the model and test dataset for inference and store those findings in a project called \"Check_Zoo_Model\".\n",
"\n",
"Note: The team member that wants do use and download published artifacts has [member role permissions](https://docs.wandb.ai/guides/registry/configure_registry#registry-roles-permissions). This means they can view and download artifacts from the registry.\n",
"\n",
"Also suppose that this user has [member role permissions](https://docs.wandb.ai/guides/registry/configure_registry#registry-roles-permissions) which means they can view and download artifacts from our registry.\n",
"\n",
"How can you retrieve the artifacts version that were published by another user in another team? Simple:\n",
"How can you retrieve the artifacts version that were published by another team? Simple:\n",
"\n",
"1. Get the full name of the artifact version programmatically or interactively with the W&B App UI\n",
"2. Use the W&B Python SDK to download the artifacts\n",
Expand Down Expand Up @@ -723,7 +732,6 @@
"outputs": [],
"source": [
"# Create model artifact name\n",
"ORG_NAME = \"smle-registries-bug-bash\"\n",
"REGISTRY_NAME = \"model\"\n",
"COLLECTION_NAME = \"Zoo_Classifier_Models\"\n",
"VERSION = 0\n",
Expand All @@ -732,6 +740,16 @@
"print(f\"Model artifact name: {model_artifact_name}\")"
]
},
{
"cell_type": "markdown",
"id": "c6953db2-aad2-484f-8dfa-f88180288682",
"metadata": {},
"source": [
"In the following code cell, ensure to replace the values enclosed in `<>` with the entity of a different team in your organization than the one you specified earlier in this notebook.\n",
"\n",
"Note: If you do not have another team entity, you can re-use the entity you specified earlier."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -740,8 +758,8 @@
"outputs": [],
"source": [
"# Enter information about your team and your team's project\n",
"DIFFERENT_TEAM_ENTITY = \"smle-reg-team-1\"\n",
"DIFFERENT_PROJECT = \"Compare_Zoo_Models\"\n",
"DIFFERENT_TEAM_ENTITY = \"<TEAM_B>\"\n",
"DIFFERENT_PROJECT = \"Check_Zoo_Model\"\n",
"\n",
"run = wandb.init(entity=DIFFERENT_TEAM_ENTITY, project=DIFFERENT_PROJECT)\n",
"registry_model = run.use_artifact(artifact_or_name=model_artifact_name)\n",
Expand Down Expand Up @@ -1014,8 +1032,21 @@
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
"display_name": "example_notebooks",
"language": "python",
"name": "example_notebooks"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
}
},
"nbformat": 4,
Expand Down

0 comments on commit c8ebac8

Please sign in to comment.