diff --git a/basics/user_management.ipynb b/basics/user_management.ipynb index a190b99..40b8abf 100644 --- a/basics/user_management.ipynb +++ b/basics/user_management.ipynb @@ -1,18 +1,16 @@ { - "nbformat": 4, - "nbformat_minor": 5, - "metadata": {}, "cells": [ { + "cell_type": "markdown", "metadata": {}, "source": [ "\n", " \n", "\n" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "markdown", "metadata": {}, "source": [ "\n", @@ -24,10 +22,10 @@ "\n", "" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "markdown", "metadata": {}, "source": [ "# User Management\n", @@ -38,136 +36,151 @@ " * assign users to projects\n", " * set / update / revoke project role\n", " * delete users from org" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "code", + "execution_count": null, "metadata": {}, + "outputs": [], "source": [ "%pip install \"labelbox[data]\"" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "f8f0b762", "metadata": {}, + "outputs": [], "source": [ "import labelbox as lb\n", "import os\n", "from labelbox.schema.user_group import UserGroup, UserGroupColor" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "markdown", + "id": "0a9ce6de", "metadata": {}, "source": [ "# API Key and Client\n", "Provide a valid api key below in order to properly connect to the Labelbox Client." - ], - "cell_type": "markdown" + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "45d4c8b9", "metadata": {}, + "outputs": [], "source": [ "# Add your api key\n", "API_KEY = None\n", "client = lb.Client(api_key=API_KEY)\n", "organization = client.get_organization()" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "markdown", + "id": "9eb49c63", "metadata": {}, "source": [ "## Roles\n", "* When inviting a new user to an organization, there are various roles to select from.\n", "* All available roles to your org can be accessed via `client.get_roles()`" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "23b3306c", "metadata": {}, + "outputs": [], "source": [ "roles = client.get_roles()\n", "for name, role in roles.items():\n", " print(role.name, \":\", role.uid)" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "markdown", + "id": "45b90b0d", "metadata": {}, "source": [ "* Above we printed out all of the roles available to the current org.\n", "* Notice the `NONE`. That is for project level roles" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "markdown", + "id": "9e648548", "metadata": {}, "source": [ "## Create\n", "* Users are created by sending an invite\n", "* An email will be sent to them and they will be asked to join your organization" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "markdown", + "id": "03992ca5", "metadata": {}, "source": [ "### Organization Level Permissions\n", "* Invite a new labeler with labeling permissions on all projects" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "5a0bb7a3", "metadata": {}, + "outputs": [], "source": [ "# First make sure that you have enough seats:\n", "organization.invite_limit()" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "476aaaa1", "metadata": {}, + "outputs": [], "source": [ "USER_EMAIL = \"\"\n", "invite = organization.invite_user(USER_EMAIL, roles[\"LABELER\"])" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "5b5629c6", "metadata": {}, + "outputs": [], "source": [ "print(invite.created_at)\n", "print(invite.organization_role_name)\n", "print(invite.email)" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "markdown", + "id": "dfdcf919", "metadata": {}, "source": [ "### Project Level Permissions\n", "* Invite a new labeler with labeling permissions specific to a set of projects\n", "* Here we set organization level permissions to Roles.NONE to indicate that the user only has project level permissions" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "781110d0", "metadata": {}, + "outputs": [], "source": [ "USER_EMAIL = \"\"\n", "project = client.create_project(\n", @@ -177,41 +190,45 @@ "invite = organization.invite_user(\n", " USER_EMAIL, roles[\"NONE\"], project_roles=[project_role]\n", ")" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "markdown", + "id": "1766b081", "metadata": {}, "source": [ "## Read\n", "* Outstanding invites cannot be queried for at this time. This information can be found in the members tab of the web app.\n", "* You are able to query for members once they have joined." - ], - "cell_type": "markdown" + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "5233d339", "metadata": {}, + "outputs": [], "source": [ "users = list(organization.users())\n", "print(users[0])" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "markdown", + "id": "00f84675", "metadata": {}, "source": [ "## Update\n", "* There is no update on invites. Instead you must delete and resend them\n", "* You can update User roles" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "b36aff4e", "metadata": {}, + "outputs": [], "source": [ "# Get all users in the organization\n", "users = organization.users()\n", @@ -234,21 +251,23 @@ "# Make the user a labeler for the current project\n", "user.upsert_project_role(project, roles[\"LABELER\"])\n", "print(user.org_role())" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "markdown", + "id": "31107d47", "metadata": {}, "source": [ "## Delete\n", "You can remove users from projects and your organization using the SDK. Invites can only be deleted using the **Members** tab on the web platform at this moment." - ], - "cell_type": "markdown" + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "9ae61408", "metadata": {}, + "outputs": [], "source": [ "# Remove the user from a project\n", "user.remove_from_project(project)\n", @@ -256,21 +275,23 @@ "user.update_org_role(roles[\"NONE\"])\n", "# Remove the user from the org\n", "organization.remove_user(user)" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "markdown", + "id": "390da677", "metadata": {}, "source": [ "## Manage user groups\n", "### Create user groups" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "83cc4ddc", "metadata": {}, + "outputs": [], "source": [ "# Define a user group\n", "user_group = UserGroup(\n", @@ -283,20 +304,22 @@ "\n", "# Create the defined user group\n", "created_group = user_group.create() " - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "markdown", + "id": "9f713aa8", "metadata": {}, "source": [ "### Update user groups" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "4daac0ab", "metadata": {}, + "outputs": [], "source": [ "# Define the user group properties to be updated\n", "user_group.name = \"Updated User Group Name\"\n", @@ -316,13 +339,14 @@ "\n", "# Push the changes to the group\n", "user_group.update()" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "1143d3f5", "metadata": {}, + "outputs": [], "source": [ "## Remove all members and projects from the group\n", "user_group.users = []\n", @@ -331,30 +355,33 @@ "\n", "# Push the changes to the group\n", "user_group.update()" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "905ff680", "metadata": {}, + "outputs": [], "source": [ "# Delete a user group\n", "user_group.delete()" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "markdown", + "id": "ca6f223c", "metadata": {}, "source": [ "## Get user group info" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "code", + "execution_count": null, + "id": "f87ce871", "metadata": {}, + "outputs": [], "source": [ "# Get info of a user group\n", "user_group.get()\n", @@ -370,27 +397,32 @@ " print(f\"Found user group 'example_name' with ID: {example_group.id}\")\n", "else:\n", " print(\"No user group named 'example_name' found\")" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] }, { + "cell_type": "markdown", + "id": "4895b32a", "metadata": {}, "source": [ "## Cleanup\n", "Delete the project if you no longer need it:" - ], - "cell_type": "markdown" + ] }, { + "cell_type": "code", + "execution_count": null, "metadata": {}, + "outputs": [], "source": [ "project.delete()" - ], - "cell_type": "code", - "outputs": [], - "execution_count": null + ] } - ] -} \ No newline at end of file + ], + "metadata": { + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}