Teams Management SDK¶
One of FiftyOne’s core design principles is that you should be able to do everything programmatically if you want.
To this end, the fiftyone.management
module provides Teams-specific methods
for managing users, invitations, dataset permissions, plugins, API keys, and
more.
Note
You must use an API connection (not a direct MongoDB connection) in order to use Management SDK methods.
API reference¶
Connections¶
API connection.
Functions:
|
Reloads the API connection. |
|
Tests the API connection. |
-
fiftyone.management.connection.
reload_api_connection
() → None¶ Reloads the API connection.
This is necessary if the API URI or API key are changed after the first usage of this module.
Note
This should rarely be needed unless a script is working across deployments.
Examples:
import fiftyone.management as fom import fiftyone as fo # https://api.dev.mycompany.org print(fo.config.api_uri) fom.whoami() # Change API URI, need to reload cached connection fo.config.api_uri = "https://api.test.mycompany.org" fom.reload_api_connection() fom.whoami()
-
fiftyone.management.connection.
test_api_connection
()¶ Tests the API connection.
If the connection succeeds, a message will be printed. If the connection failes, an exception will be raised.
Examples:
import fiftyone.management as fom fom.test_api_connection() # API connection succeeded
API keys¶
API key management.
Classes:
|
API key dataclass. |
Functions:
|
Deletes the API key for the given user (default: current user). |
|
Generates an API key for the given user (default: current user). |
|
Lists all API keys for the given user (default: current user). |
-
class
fiftyone.management.api_key.
APIKey
(id: str, name: str, created_at: datetime.datetime)¶ API key dataclass.
Attributes:
-
id
: str¶
-
name
: str¶
-
created_at
: datetime.datetime¶
-
-
fiftyone.management.api_key.
delete_api_key
(key: str, user: Optional[Union[str, fiftyone.management.users.User]] = None) → None¶ Deletes the API key for the given user (default: current user).
Note
Only admins can delete keys for other users.
Examples:
import fiftyone.management as fom # Delete all keys from a user email = "user@company.com" for key in fom.list_api_keys(email): fom.delete_api_key(key.id, email)
- Parameters
key – the ID of the key to delete
user (None) – an optional user ID, email string, or
User
instance. Defaults to the current user.
-
fiftyone.management.api_key.
generate_api_key
(key_name: str, user: Optional[Union[str, fiftyone.management.users.User]] = None) → str¶ Generates an API key for the given user (default: current user).
Note
Only admins can generate keys for other users.
Warning
Once generated, this key cannot be recovered! If it’s lost, you must generate a new key.
Examples:
import fiftyone.management as fom # 1. Generate key for myself fom.generate_api_key("my-key") # 2.a Generate key for user@example.com fom.generate_api_key("your-key", "user@example.com") # 2.b Generate key for user@example.com user = fom.get_user("user@example.com") fom.generate_api_key("your-key", user)
- Parameters
key_name – a descriptive name for the key
user (None) – an optional user ID, email string, or
User
instance. Defaults to the current user.
- Returns
the API key string
-
fiftyone.management.api_key.
list_api_keys
(user: Optional[Union[str, fiftyone.management.users.User]] = None)¶ Lists all API keys for the given user (default: current user).
The returned key objects only have their name and IDs populated; the raw key is only available at time of generation.
Note
Only admins can request keys for other users.
Examples:
import fiftyone.management as fom # 1. List my keys fom.list_api_keys() # list my keys # 2.a List keys for user@example.com fom.list_api_keys("user@example.com") # 2.b List keys for user@example.com user = fom.get_user("user@example.com") fom.list_api_keys(user)
Cloud credentials¶
Cloud credentials management.
Classes:
|
Cloud Credentials Info |
Credential factory methods for Amazon AWS provider |
|
Credential factory methods for Microsoft Azure provider |
|
Credential factory methods for MINIO provider |
Functions:
|
Adds cloud credentials to the system. |
|
Deletes the installed cloud credentials. |
Lists all cloud credentials installed in the system. |
-
class
fiftyone.management.cloud_credentials.
CloudCredential
(created_at: datetime.datetime, prefixes: List[str], provider: str, description: Optional[str] = None)¶ Cloud Credentials Info
Attributes:
-
created_at
: datetime.datetime¶
-
prefixes
: List[str]¶
-
provider
: str¶
-
description
: Optional[str] = None¶
-
-
fiftyone.management.cloud_credentials.
add_cloud_credentials
(provider: Literal[GCP, AWS, AZURE, MINIO], credential_type: Literal[ini, json, factory], credentials: Union[str, Dict], description: Optional[str] = None, prefixes: Optional[List[str]] = None, overwrite: Optional[bool] = True) → None¶ Adds cloud credentials to the system.
Note
Only admins can add cloud credentials.
Warning
This will overwrite any previously existing credentials with the same provider/prefixes combination.
Warning
Cloud credentials are made available for use for all app users (no access to the credentials themselves). This is for media only and doesn’t affect FiftyOne dataset permissions.
Examples:
import os import fiftyone.management as fom # Add default GCP credentials from service account json file fom.add_cloud_credentials( "GCP", "json", "/path/to/gcp-svc-acct.json", description="Default GCP credentials" ) # Add bucket-specific AWS credentials from .ini file fom.add_cloud_credentials( "AWS", "ini", "/path/to/aws-creds.ini", description="Readonly credentials for bucket1,bucket2", prefixes=["bucket1", "bucket2"] ) # Add default AWS credentials from formatted_credentials = fom.AwsCredentialsFactory.from_access_keys( access_key_id=os.environ["AWS_ACCESS_KEY_ID"], secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"], default_region="us-west-2" ) fom.add_cloud_credentials( "AWS", "factory", formatted_credentials, description="Default AWS credentials from access keys" )
- Parameters
provider – the shorthand cloud provider string. One of [“GCP”, “AWS”, “AZURE”, “MINIO”]
credential_type –
Type of credentials passed into
credentials
param. One of["ini", "json", "factory"]
.ini
: Path to an .ini file containing the credentials, such as/Users/voxel51/.aws/credentials
json
: Path to a JSON file containing credentials, such as/Users/voxel51/.config/gcloud/service-account-creds.json
factory
: Adict
returned by a class method in one of theprovider-specific credentials factories:
AwsCredentialsFactory
,AzureCredentialsFactory
,MinIoCredentialsFactory
credentials – Dict of factory-built credentials or string path to credentials file, based on
credential_type
parameter.description (
None
) – Optional description for this credential set.prefixes (
None
) – The list of bucket names the credentials apply to, if applicable. Defaults toNone
meaning the default credentials for the provider.overwrite (
True
) – Whether to overwrite existing credentials for the same provider/prefixes combination.
- Raises
ValueError – if invalid provider is supplied
-
fiftyone.management.cloud_credentials.
delete_cloud_credentials
(provider: Literal[GCP, AWS, AZURE, MINIO], prefixes: Optional[List[str]] = None) → None¶ Deletes the installed cloud credentials.
Note
Only admins can delete cloud credentials.
Warning
This will delete credentials for all app users in the system. Ensure there is another cloud media storage access method in place to avoid system outage.
Examples:
import fiftyone.management as fom # Delete all credentials for a provider provider = "AWS" for credentials in fom.list_cloud_credentials(): if credentials.provider == provider: fom.delete_cloud_credentials(provider, credentials.prefixes)
- Parameters
provider – the shorthand cloud provider string. One of [“GCP”, “AWS”, “AZURE”, “MINIO”]
prefixes (None) – The list of bucket names the credentials apply to, if applicable. Defaults to
None
meaning the default credentials for the provider.
- Raises
ValueError – if invalid provider is supplied
-
fiftyone.management.cloud_credentials.
list_cloud_credentials
() → List[fiftyone.management.cloud_credentials.CloudCredential]¶ Lists all cloud credentials installed in the system.
The returned credentials objects only have their provider, prefixes, description, and creation time set. You cannot view the plaintext or encrypted credentials.
Note
Only admins can list cloud credentials
Examples:
import fiftyone.management as fom fom.list_cloud_credentials()
- Returns
a list of
CloudCredential
instances
-
class
fiftyone.management.cloud_credentials.
AwsCredentialsFactory
¶ Credential factory methods for Amazon AWS provider
Methods:
from_access_keys
(access_key_id, …[, …])Get formatted AWS credentials from access keys.
-
classmethod
from_access_keys
(access_key_id: str, secret_access_key: str, default_region: Optional[str] = None, session_token: Optional[str] = None) → Dict[str, str]¶ Get formatted AWS credentials from access keys.
For use in
fom.add_cloud_credentials()
only.- Parameters
access_key_id – AWS access key ID
secret_access_key – AWS secret access key
default_region (
None
) – default AWS region to setsession_token (
None
) – AWS session token
- Returns
Formatted credentials
-
classmethod
-
class
fiftyone.management.cloud_credentials.
AzureCredentialsFactory
¶ Credential factory methods for Microsoft Azure provider
Methods:
from_account_key
(account_name, account_key)Get formatted AZURE credentials from access keys
from_connection_string
(connection_string[, …])Get formatted AZURE credentials from connection string
from_client_secret
(account_name, client_id, …)Get formatted AZURE credentials from client secret
-
classmethod
from_account_key
(account_name, account_key, alias: Optional[str] = None) → Dict[str, str]¶ Get formatted AZURE credentials from access keys
For use in
fom.add_cloud_credentials()
only.- Parameters
account_name – Azure account name
account_key – Azure account key
alias (
None
) – alias to use for storage blobs
- Returns
Formatted credentials
-
classmethod
from_connection_string
(connection_string, alias: Optional[str] = None) → Dict[str, str]¶ Get formatted AZURE credentials from connection string
For use in
fom.add_cloud_credentials()
only.- Parameters
connection_string – Azure connection string
alias (
None
) – alias to use for storage blobs
- Returns
Formatted credentials
-
classmethod
from_client_secret
(account_name, client_id, client_secret, tenant_id, alias: Optional[str] = None) → Dict[str, str]¶ Get formatted AZURE credentials from client secret
For use in
fom.add_cloud_credentials()
only.- Parameters
account_name – Azure account name
client_id – Azure client ID
client_secret – Azure client secret
tenant_id – Azure tenant ID
alias (
None
) – alias to use for storage blobs
- Returns
Formatted credentials
-
classmethod
-
class
fiftyone.management.cloud_credentials.
MinIoCredentialsFactory
¶ Credential factory methods for MINIO provider
Methods:
from_access_keys
(access_key_id, …[, …])Get formatted MINIO credentials from access keys
-
classmethod
from_access_keys
(access_key_id: str, secret_access_key: str, endpoint_url: str, alias: Optional[str] = None, default_region: Optional[str] = None) → Dict[str, str]¶ Get formatted MINIO credentials from access keys
For use in
fom.add_cloud_credentials()
only.- Parameters
access_key_id – MinIO access key ID
secret_access_key – MinIO secret access key
endpoint_url – MinIO endpoint URL
alias (
None
) – alias to use for storage blobsdefault_region (
None
) – default MinIO region to set
- Returns
Formatted credentials
-
classmethod
Dataset permissions¶
Dataset management.
Classes:
|
Dataset permission enum. |
Functions:
|
Removes the given user’s specific access to the given dataset. |
|
Gets creator of a dataset, if known. |
|
Gets the specified dataset or user permissions. |
|
Gets the list of users that have access to the given dataset. |
Gets the access permission (if any) that a given user has to a given dataset. |
|
Gets the access permission (if any) that a given user group has to a given dataset. |
|
|
Gets a list of datasets a given user has access to. |
|
Gets a list of datasets a given user group has access to. |
|
Sets the default member access level for the given dataset. |
|
Grants the given user specific access to the given dataset at the specified permission level. |
Grants the given user group specific access to the given dataset at the specified permission level. |
|
Remove the user group’s explicit access to the given dataset |
-
class
fiftyone.management.dataset.
DatasetPermission
(value)¶ Dataset permission enum.
Attributes:
-
NO_ACCESS
= 'NO_ACCESS'¶
-
VIEW
= 'VIEW'¶
-
TAG
= 'TAG'¶
-
EDIT
= 'EDIT'¶
-
MANAGE
= 'MANAGE'¶
-
-
fiftyone.management.dataset.
delete_dataset_user_permission
(dataset_name: str, user: Union[str, fiftyone.management.users.User]) → None¶ Removes the given user’s specific access to the given dataset.
Note
The caller must have
Can Manage
permissions on the dataset.Examples:
import fiftyone.management as fom dataset_name = "special-dataset" user = "guest@company.com" fom.set_dataset_user_permission(dataset_name, user, fom.VIEW) fom.delete_dataset_user_permission(dataset_name, user) assert fom.get_permissions(dataset_name=dataset_name, user=user) == fom.NO_ACCESS
- Parameters
dataset_name – the dataset name
user – a user ID, email string, or
User
instance.
-
fiftyone.management.dataset.
get_dataset_creator
(dataset_name: str) → Optional[fiftyone.management.users.User]¶ Gets creator of a dataset, if known.
Examples:
import fiftyone.management as fom user = fom.get_dataset_creator("dataset")
- Parameters
dataset_name – the dataset name
- Raises
ValueError – if
dataset_name
does not exist or calling user does not have access to it.- Returns
User
instance, orNone
if dataset has no recorded creator.
-
fiftyone.management.dataset.
get_permissions
(*, dataset_name: Optional[str] = None, user: Optional[Union[str, fiftyone.management.users.User]] = None, user_group: Optional[Union[str, fiftyone.management.user_groups.UserGroup]] = None)¶ Gets the specified dataset or user permissions.
This method is a convenience wrapper around the methods below based on which arguments you provide:
dataset_name
:get_permissions_for_dataset()
user_group
:get_permissions_for_dataset_user_group()
dataset_name
anduser
:get_permissions_for_dataset_user()
dataset_name
anduser_group
:
Note
Only admins can retrieve this information.
Examples:
import fiftyone.management as fom dataset_name = "special-dataset" user = "guest@company.com" # Get permissions for user assert ( fom.get_permissions(user=user) == fom.get_permissions_for_user(user) ) # Get permissions for dataset assert ( fom.get_permissions(dataset_name=dataset_name) == fom.get_permissions_for_dataset(dataset_name) ) # Get permissions for user-dataset combination assert ( fom.get_permissions(dataset_name=dataset_name, user=user) == fom.get_permissions_for_dataset_user(dataset_name, user) ) # Get permissions for user group-dataset assert ( fom.get_permissions(dataset_name=dataset_name, user_group="some-id") == fom.get_permissions_for_dataset_user_group(dataset_name, "some-id") )
-
fiftyone.management.dataset.
get_permissions_for_dataset
(dataset_name: str, include_groups=True) → Dict¶ Gets the list of users that have access to the given dataset.
Note
Only admins can retrieve this information.
Examples:
import fiftyone.management as fom dataset_name = "special-dataset" fom.get_permissions_for_dataset(dataset_name)
Example output:
[ {'name': 'A. User', 'email': 'a@company.com', 'id': '12345', 'permission': 'MANAGE'}, {'name': 'B. User', 'email': 'b@company.com', 'id': '67890', 'permission': 'EDIT'}, ]
- Parameters
dataset_name – the dataset name
- Returns
- If include_groups is True, return a dictionary contains a list of user
info and group info. Otherwise, return a list of user info.
-
fiftyone.management.dataset.
get_permissions_for_dataset_user
(dataset_name: str, user: str) → fiftyone.management.dataset.DatasetPermission¶ Gets the access permission (if any) that a given user has to a given dataset.
Note
Only admins can retrieve this information.
Examples:
import fiftyone.management as fom dataset_name = "special-dataset" user = "guest@company.com" fom.get_permissions_for_dataset_user(dataset_name, user)
- Parameters
dataset_name – the dataset name
user – a user ID, email string, or
User
instance
- Returns
-
fiftyone.management.dataset.
get_permissions_for_dataset_user_group
(dataset_name: str, user_group: Union[str, fiftyone.management.user_groups.UserGroup]) → fiftyone.management.dataset.DatasetPermission¶ Gets the access permission (if any) that a given user group has to a given dataset.
Note
Only admins can retrieve this information.
Examples:
import fiftyone.management as fom dataset_name = "special-dataset" user_group = "interns" fom.get_permissions_for_dataset_user_group(dataset_name, user_group)
- Parameters
dataset_name – the dataset name
user_group – a user group ID or name string or
UserGroup
- Returns
-
fiftyone.management.dataset.
get_permissions_for_user
(user: str)¶ Gets a list of datasets a given user has access to.
Note
Only admins can retrieve this information.
Examples:
import fiftyone.management as fom user = "guest@company.com" fom.get_permissions_for_user(user)
Example output:
[ {'name': 'datasetA', 'permission': 'EDIT'}, {'name': 'datasetB', 'permission': 'VIEW'}, ]
- Parameters
user – a user ID, email string, or
User
instance- Returns
a list of permission dicts
-
fiftyone.management.dataset.
get_permissions_for_user_group
(user_group: Union[str, fiftyone.management.user_groups.UserGroup])¶ Gets a list of datasets a given user group has access to.
Note
Only admins can retrieve this information.
Examples:
import fiftyone.management as fom user_group = "some-group-id" fom.get_permissions_for_user_group(user_group)
Example output:
[ {'name': 'datasetA', 'permission': 'EDIT'}, {'name': 'datasetB', 'permission': 'VIEW'}, ]
- Parameters
user_group – a user group ID or name or
UserGroup
- Returns
a list of permission dicts
-
fiftyone.management.dataset.
set_dataset_default_permission
(dataset_name: str, permission: fiftyone.management.dataset.DatasetPermission) → None¶ Sets the default member access level for the given dataset.
Note
The caller must have
Can Manage
permissions on the dataset.Examples:
import fiftyone.management as fom dataset_name = "special-dataset" # Give every Member Edit access by default fom.set_dataset_default_permission(dataset_name, fom.EDIT)
- Parameters
dataset_name – the dataset name
permission – the
DatasetPermission
to set
-
fiftyone.management.dataset.
set_dataset_user_permission
(dataset_name: str, user: Union[str, fiftyone.management.users.User], permission: fiftyone.management.dataset.DatasetPermission, invite: bool = False) → None¶ Grants the given user specific access to the given dataset at the specified permission level.
Note
The caller must have
Can Manage
permissions on the dataset.Warning
If an unknown email is passed to this function and
invite
isTrue
, an invitation to join the organization will be sent to the email. The user will be created and have access to the dataset on invitation acceptance. Please double-check the email correctness before running.Examples:
import fiftyone.management as fom dataset_name = "special-dataset" guest = "guest@company.com" new_guest = "new-guest@company.com" # Existing user fom.set_dataset_user_permission(dataset_name, guest, fom.VIEW) assert fom.get_permissions(dataset_name=dataset_name, user=guest) == fom.VIEW # Nonexisting user fom.set_dataset_user_permission(dataset_name, new_guest, fom.VIEW, invite=True) assert guest in [i.invitee_email for i in fom.list_pending_invitations()]
- Parameters
dataset_name – the dataset name
user – a user ID, email string, or
User
instancepermission – the
DatasetPermission
to grantinvite (False) – if
True
anduser
is an email, an invitation will be sent to join the organization.
-
fiftyone.management.dataset.
set_dataset_user_group_permission
(dataset_name: str, user_group: Union[str, fiftyone.management.user_groups.UserGroup], permission: Union[str, fiftyone.management.dataset.DatasetPermission]) → None¶ Grants the given user group specific access to the given dataset at the specified permission level.
Note
The caller must have
Can Manage
permissions on the dataset.Examples:
import fiftyone.management as fom dataset_name = "special-dataset" group_id = "some-group-id" fom.set_dataset_user_permission(dataset_name, group_id, fom.VIEW)
- Parameters
dataset_name – the dataset name
user_group – a user group ID or name string or a
UserGroup
instancepermission – the
DatasetPermission
-
fiftyone.management.dataset.
remove_dataset_user_group_permission
(dataset_name: str, user_group: Union[str, fiftyone.management.user_groups.UserGroup]) → None¶ Remove the user group’s explicit access to the given dataset
Note
The caller must have
Can Manage
permissions on the dataset.Examples:
import fiftyone.management as fom dataset_name = "special-dataset" group_id = "some-group-id" fom.remove_dataset_user_group_permission(dataset_name, group_id)
- Parameters
dataset_name – the dataset name
user_group – a user group id or name string or a
UserGroup
instance
Organization settings¶
Organization settings management.
Classes:
|
Functions:
Gets organization-wide settings for the Teams deployment. |
|
|
Sets organization-wide settings for the Teams deployment |
-
class
fiftyone.management.organization.
OrganizationSettings
(default_user_role: fiftyone.management.users.UserRole, default_dataset_permission: fiftyone.management.dataset.DatasetPermission, default_operator_minimum_role: fiftyone.management.users.UserRole, default_operator_minimum_dataset_permission: fiftyone.management.dataset.DatasetPermission)¶ Attributes:
-
default_user_role
: fiftyone.management.users.UserRole¶
-
default_dataset_permission
: fiftyone.management.dataset.DatasetPermission¶
-
default_operator_minimum_role
: fiftyone.management.users.UserRole¶
-
default_operator_minimum_dataset_permission
: fiftyone.management.dataset.DatasetPermission¶
-
-
fiftyone.management.organization.
get_organization_settings
() → fiftyone.management.organization.OrganizationSettings¶ Gets organization-wide settings for the Teams deployment.
Note
Only admins can retrieve this information
Examples:
import fiftyone.management as fom fom.get_organization_settings()
- Returns
-
fiftyone.management.organization.
set_organization_settings
(*, default_user_role: Optional[fiftyone.management.users.UserRole] = None, default_dataset_permission: Optional[fiftyone.management.dataset.DatasetPermission] = None, default_operator_minimum_role: Optional[fiftyone.management.users.UserRole] = None, default_operator_minimum_dataset_permission: Optional[fiftyone.management.dataset.DatasetPermission] = None) → fiftyone.management.organization.OrganizationSettings¶ Sets organization-wide settings for the Teams deployment
Note
Only admins can perform this action.
Examples:
import fiftyone.management as fom user_role = fom.MEMBER dataset_perm = fom.EDIT # Set only default user role fom.set_organization_settings(default_user_role=user_role) # Set only default dataset permission fom.set_organization_settings(default_dataset_permission=dataset_perm) # Set multiple settings at once fom.set_organization_settings( default_user_role=user_role, default_dataset_permission=dataset_perm, default_operator_minimum_role=user_role, default_operator_minimum_dataset_permission=dataset_perm, )
- Parameters
default_user_role (None) – an optional
UserRole
to set.default_dataset_permission (None) – an optional
DatasetPermission
to set,default_operator_minimum_role (None) – an optional
UserRole
to setdefault_operator_minimum_dataset_permission (None) – an optional
DatasetPermission
to set
- Returns
Plugin management¶
Plugin management.
Classes:
|
Operator permission dataclass. |
|
Plugin operator dataclass. |
|
Plugin dataclass. |
Functions:
|
Returns a list of all installed plugins in central FiftyOne Teams. |
|
Gets information about the specified plugin in central FiftyOne Teams. |
|
Uploads a plugin to central FiftyOne Teams. |
|
Deletes the given plugin from central FiftyOne Teams. |
|
Downloads a plugin from central FiftyOne Teams. |
|
Sets the enabled status of the given plugin in central FiftyOne Teams. |
|
Sets the enabled status of the given plugin operator in central FiftyOne Teams. |
|
Sets permission levels of the given plugin operator in central FiftyOne Teams. |
-
class
fiftyone.management.plugin.
OperatorPermission
(minimum_role: fiftyone.management.users.UserRole, minimum_dataset_permission: fiftyone.management.dataset.DatasetPermission)¶ Operator permission dataclass.
Attributes:
-
minimum_role
: fiftyone.management.users.UserRole¶
-
minimum_dataset_permission
: fiftyone.management.dataset.DatasetPermission¶
-
-
class
fiftyone.management.plugin.
PluginOperator
(name: str, enabled: bool, permission: fiftyone.management.plugin.OperatorPermission)¶ Plugin operator dataclass.
Attributes:
-
name
: str¶
-
enabled
: bool¶
-
permission
: fiftyone.management.plugin.OperatorPermission¶
-
-
class
fiftyone.management.plugin.
Plugin
(name: str, description: str, version: str, fiftyone_version: str, enabled: bool, operators: List[fiftyone.management.plugin.PluginOperator])¶ Plugin dataclass.
Attributes:
-
name
: str¶
-
description
: str¶
-
version
: str¶
-
fiftyone_version
: str¶
-
enabled
: bool¶
-
operators
: List[fiftyone.management.plugin.PluginOperator]¶
-
-
fiftyone.management.plugin.
list_plugins
(include_builtin: bool = False) → List[fiftyone.management.plugin.Plugin]¶ Returns a list of all installed plugins in central FiftyOne Teams.
Examples:
import fiftyone.management as fom fom.list_plugins()
- Parameters
include_builtin (False) – whether to include builtin plugins
- Returns
a list of
Plugin
instances
-
fiftyone.management.plugin.
get_plugin_info
(plugin_name: str) → fiftyone.management.plugin.Plugin¶ Gets information about the specified plugin in central FiftyOne Teams.
Examples:
import fiftyone.management as fom fom.get_plugin_info("my-plugin")
- Parameters
plugin_name – a plugin name
- Returns
Plugin
, orNone
if no such plugin is found
-
fiftyone.management.plugin.
upload_plugin
(plugin_path: str, overwrite: bool = False, optimize=False) → fiftyone.management.plugin.Plugin¶ Uploads a plugin to central FiftyOne Teams.
The local plugin must be a zip file that contains a single directory with a
fiftyone.yml
orfiftyone.yaml
file. For example:my_plugin/ fiftyone.yml __init__.py data.txt
Note
Only admins can upload plugins.
Examples:
import fiftyone.management as fom # Upload a raw plugin directory fom.upload_plugin("/path/to/plugin_dir", overwrite=True) # Upload a plugin, optimizing the directory before the upload fom.upload_plugin("/path/to/plugin_dir", overwrite=True, optimize=True) # Upload a plugin as ZIP file fom.upload_plugin("/path/to/plugin.zip", overwrite=True)
- Parameters
plugin_path – the path to a plugin zip or directory
overwrite (False) – whether to overwrite an existing plugin with same name
optimize (False) – whether to optimize the created zip file before uploading. If a
.gitignore
file exists, an attempt will first be made to usegit archive
to create the zip. If not or this doesn’t work, a zip will be created by pruning various known system-generated files and directories such as.git/
and__pycache__/
. This argument has no effect ifplugin_path
does not point to a directory
-
fiftyone.management.plugin.
delete_plugin
(plugin_name: str) → None¶ Deletes the given plugin from central FiftyOne Teams.
Examples:
import fiftyone.management as fom plugin_name = "special-plugin" fom.delete_plugin(plugin_name) plugins = fom.list_plugins() assert not any(plugin.name == plugin_name for plugin in plugins)
Note
Only admins can perform this action.
- Parameters
plugin_name – a plugin name
-
fiftyone.management.plugin.
download_plugin
(plugin_name: str, download_dir: str) → str¶ Downloads a plugin from central FiftyOne Teams.
Examples:
import fiftyone.management as fom fom.download_plugin("special-plugin", "/path/to/local/plugins/")
- Parameters
plugin_name – a plugin name
download_dir – a directory into which to download the plugin
- Returns
the path to the downloaded plugin
-
fiftyone.management.plugin.
set_plugin_enabled
(plugin_name: str, enabled: bool) → None¶ Sets the enabled status of the given plugin in central FiftyOne Teams.
Note
Only admins can perform this action.
Examples:
import fiftyone.management as fom # Disable whole plugin fom.set_plugin_enabled("special-plugin", False)
- Parameters
plugin_name – a plugin name
enabled – a bool specifying what to set enabled status to
-
fiftyone.management.plugin.
set_plugin_operator_enabled
(plugin_name: str, operator_name: str, enabled: bool) → None¶ Sets the enabled status of the given plugin operator in central FiftyOne Teams.
Note
Only admins can perform this action.
Examples:
import fiftyone.management as fom # Disable a particular operator fom.set_plugin_operator_enabled("special-plugin", "special-operator", False)
- Parameters
plugin_name – a plugin name
operator_name – an operator name within the given plugin
enabled – a bool specifying what to set operator enabled status to
-
fiftyone.management.plugin.
set_plugin_operator_permissions
(plugin_name: str, operator_name: str, minimum_role: Optional[fiftyone.management.users.UserRole] = None, minimum_dataset_permission: Optional[fiftyone.management.dataset.DatasetPermission] = None)¶ Sets permission levels of the given plugin operator in central FiftyOne Teams.
At least one of
minimum_role
andminimum_dataset_permission
must be set.Note
Only admins can perform this action.
Examples:
import fiftyone.management as fom plugin_name = "special-plugin" operator_name = "special-operator" # Set minimum role permission only fom.set_plugin_operator_permissions( plugin_name, operator_name, minimum_role=fom.MEMBER ) # Set minimum dataset permission only fom.set_plugin_operator_permissions( plugin_name, operator_name, minimum_dataset_permission=fom.EDIT ) # Set both minimum role and minimum dataset permissions fom.set_plugin_operator_permissions( plugin_name, operator_name, minimum_role=fom.EDIT, minimum_dataset_permission=fom.EDIT )
- Parameters
plugin_name – a plugin name
operator_name – an operator name within the given plugin
minimum_role (None) – an optional
UserRole
to setminimum_dataset_permission (None) – an optional
DatasetPermission
to set
Snapshots¶
Dataset snapshot management.
Classes:
|
User role enum. |
|
|
|
Functions:
|
Archive snapshot to the configured cold storage location. |
Calculate change summary between recent snapshot and HEAD of dataset. |
|
|
Create and store a snapshot of the current state of |
|
Delete snapshot |
|
Gets change summary between most recent snapshot and HEAD of dataset |
|
Gets information about the specified dataset snapshot, or |
|
Returns a list of all snapshots of a dataset in order of creation. |
|
Revert dataset to a previous snapshot state. |
|
Unarchive snapshot from the configured cold storage location. |
-
class
fiftyone.management.snapshot.
DatasetSnapshotStatus
(value)¶ User role enum.
Attributes:
-
UNLOADED
= 'UNLOADED'¶
-
LOADING
= 'LOADING'¶
-
LOADED
= 'LOADED'¶
-
-
class
fiftyone.management.snapshot.
SampleChangeSummary
(total_samples: int, num_samples_added: int, num_samples_deleted: int, num_samples_changed: int, updated_at: Optional[datetime.datetime] = None)¶ Attributes:
-
total_samples
: int¶
-
num_samples_added
: int¶
-
num_samples_deleted
: int¶
-
num_samples_changed
: int¶
-
updated_at
: Optional[datetime.datetime] = None¶
-
-
class
fiftyone.management.snapshot.
DatasetSnapshot
(created_at: Optional[datetime.datetime], created_by: str, description: Optional[str], id: str, linear_change_summary: Optional[fiftyone.management.snapshot.SampleChangeSummary], load_status: fiftyone.management.snapshot.DatasetSnapshotStatus, name: str, slug: str)¶ Attributes:
-
created_at
: Optional[datetime.datetime]¶
-
created_by
: str¶
-
description
: Optional[str]¶
-
id
: str¶
-
linear_change_summary
: Optional[fiftyone.management.snapshot.SampleChangeSummary]¶
-
load_status
: fiftyone.management.snapshot.DatasetSnapshotStatus¶
-
name
: str¶
-
slug
: str¶
-
-
fiftyone.management.snapshot.
archive_snapshot
(dataset_name: str, snapshot_name: str) → None¶ Archive snapshot to the configured cold storage location.
Note
Only users with
MANAGE
access can create a snapshotWarning
Archiving a snapshot will make it unavailable for browsing to any user, even if they are currently using/browsing.
Examples:
import fiftyone as fo import fiftyone.management as fom snapshot_name = "v0.1" # We don't use this regularly, archive it! fom.archive_snapshot(dataset.name, snapshot_name) fo.load_dataset(dataset.name, snapshot_name) # throws error, can't load!
- Parameters
dataset_name – the dataset name
snapshot_name – the snapshot name
-
fiftyone.management.snapshot.
calculate_dataset_latest_changes_summary
(dataset_name: str) → fiftyone.management.snapshot.SampleChangeSummary¶ Calculate change summary between recent snapshot and HEAD of dataset.
Examples:
import fiftyone.management as fom old = fom.calculate_dataset_latest_changes_summary(dataset.name) assert old == fom.get_dataset_latest_changes_summary(dataset.name) dataset.delete_samples(dataset.take(5)) # Cached summary hasn't been updated assert old == fom.get_dataset_latest_changes_summary(dataset.name) new = fom.calculate_dataset_latest_changes_summary(dataset.name) assert new.updated_at > changes.updated_at
- Parameters
dataset_name – the dataset name
- Returns
Change summary between most recent snapshot and HEAD of this dataset.
-
fiftyone.management.snapshot.
create_snapshot
(dataset_name: str, snapshot_name: str, description: Optional[str] = None) → fiftyone.management.snapshot.DatasetSnapshot¶ Create and store a snapshot of the current state of
dataset_name
.Snapshot name must be unique for the given dataset.
Note
Only users with
MANAGE
access can create a snapshotExamples:
import fiftyone.management as fom snapshot_name = "v0.1" description = "Initial dataset snapshot" fom.create_snapshot(dataset.name, snapshot_name, description)
- Parameters
dataset_name – the dataset name
snapshot_name – the name of the snapshot to create
description (None) – Optional description to attach to this snapshot
-
fiftyone.management.snapshot.
delete_snapshot
(dataset_name: str, snapshot_name: str)¶ Delete snapshot
snapshot_name
from datasetdataset_name
.Note
Only users with
MANAGE
access can delete a snapshot.Examples:
import fiftyone.management as fom snapshot_name = "v0.1" description = "Initial dataset snapshot" fom.create_snapshot(dataset.name, snapshot_name, description) # Some time later ... fom.delete_snapshot(dataset, snapshot_name)
- Parameters
dataset_name – the dataset name
snapshot_name – the snapshot name
-
fiftyone.management.snapshot.
get_dataset_latest_changes_summary
(dataset_name: str) → fiftyone.management.snapshot.SampleChangeSummary¶ Gets change summary between most recent snapshot and HEAD of dataset
Note
This summary is not continuously computed, the result of this function may be stale. Use
calculate_dataset_latest_changes_summary()
to recalculate.Examples:
import fiftyone.management as fom fom.get_dataset_latest_changes_summary(dataset.name)
- Parameters
dataset_name – the dataset name
- Returns
- Change summary between most recent snapshot and HEAD of this dataset.
Or
None
if no summary has been calculated yet.
- Raises
ValueError – if dataset doesn’t exist or no access
-
fiftyone.management.snapshot.
get_snapshot_info
(dataset_name: str, snapshot_name: str) → Optional[fiftyone.management.snapshot.DatasetSnapshot]¶ - Gets information about the specified dataset snapshot, or
None
if
snapshot_name
doesn’t exist.
Examples:
import fiftyone.management as fom dataset = "quickstart" snapshot_name = "v0.1" fom.get_snapshot_info(dataset.name, snapshot_name)
- Parameters
dataset_name – the dataset name
snapshot_name – the snapshot name
- Raises
ValueError – if dataset doesn’t exist or no access
- Gets information about the specified dataset snapshot, or
-
fiftyone.management.snapshot.
list_snapshots
(dataset_name: str) → List[str]¶ Returns a list of all snapshots of a dataset in order of creation.
Examples:
import fiftyone.management as fom fom.list_snapshots(dataset.name)
- Parameters
dataset_name – the dataset name
- Raises
ValueError – if dataset doesn’t exist or no access
- Returns
a list of
DatasetSnapshot
instances
-
fiftyone.management.snapshot.
revert_dataset_to_snapshot
(dataset_name: str, snapshot_name: str)¶ Revert dataset to a previous snapshot state.
Reverts the current (HEAD) state of
dataset_name
to a previous state encapsulated by the snapshotsnapshot_name
. All changes since then are lost. All snapshots created after this one will be deleted as well.If you are attempting to view the dataset at the point of a snapshot but not completely revert, you can do so with:
snapshot = fo.load_dataset(dataset_name, snapshot=snapshot_name)
Note
Only users with
MANAGE
access can revert a datasetWarning
This action is very destructive! All changes between
snapshot_name
and the current HEAD state ofdataset_name
will be destroyed! Including all snapshots created aftersnapshot_name
.Examples:
import fiftyone.management as fom snapshot_name = "v0.1" description = "Initial dataset snapshot" fom.create_snapshot(dataset.name, snapshot_name, description) # Oops we deleted everything! dataset.delete_samples(dataset.values("id")) # Phew! fom.revert_dataset_to_snapshot(dataset.name, snapshot_name) dataset.reload() assert len(dataset) > 0
- Parameters
dataset_name – the dataset name
snapshot_name – the snapshot name
-
fiftyone.management.snapshot.
unarchive_snapshot
(dataset_name: str, snapshot_name: str) → None¶ Unarchive snapshot from the configured cold storage location.
Examples:
import fiftyone as fo import fiftyone.management as fom snapshot_name = "v0.1" description = "Initial dataset snapshot" # We don't use this regularly, archive it! fom.archive_snapshot(dataset.name, snapshot_name) fo.load_dataset(dataset.name, snapshot_name) # throws error, can't load! # Oops we need it now, unarchive it! fom.unarchive_snapshot(dataset.name, snapshot_name) fo.load_dataset(dataset.name, snapshot_name) # works now!
- Parameters
dataset_name – the dataset name
snapshot_name – the snapshot name
User management¶
User management.
Classes:
|
User role enum. |
|
User information dataclass. |
|
Invitation dataclass. |
Functions:
|
Deletes the given user. |
|
Deletes/revokes a previously-sent invitation if it has not been accepted. |
|
Gets information about the specified user (if any). |
Returns a list of pending user invitations. |
|
|
Returns a list of all users. |
|
Sends an email invitation to join your FiftyOne Teams organization. |
|
Sets the role of the given user. |
|
Returns information about the calling user. |
|
Resolves user ID - by looking up user by email if it has to |
-
class
fiftyone.management.users.
UserRole
(value)¶ User role enum.
Attributes:
-
ADMIN
= 'ADMIN'¶
-
MEMBER
= 'MEMBER'¶
-
COLLABORATOR
= 'COLLABORATOR'¶
-
GUEST
= 'GUEST'¶
-
-
class
fiftyone.management.users.
User
(id: str, name: str, email: str, role: fiftyone.management.users.UserRole)¶ User information dataclass.
Attributes:
-
id
: str¶
-
name
: str¶
-
email
: str¶
-
-
class
fiftyone.management.users.
Invitation
(id: str, created_at: datetime.datetime, expires_at: datetime.datetime, invitee_email: str, invitee_role: fiftyone.management.users.UserRole, url: str)¶ Invitation dataclass.
Attributes:
-
id
: str¶
-
created_at
: datetime.datetime¶
-
expires_at
: datetime.datetime¶
-
invitee_email
: str¶
-
invitee_role
: fiftyone.management.users.UserRole¶
-
url
: str¶
-
-
fiftyone.management.users.
delete_user
(user: Union[str, fiftyone.management.users.User]) → None¶ Deletes the given user.
Note
Only admins can perform this action.
Warning
This action is irreversible! Once deleted, the user will have to be re-invited to the organization to have access again.
Examples:
import fiftyone.management as fom delete_user = "guest@company.com" fom.delete_user(delete_user) assert fom.get_user(delete_user) is None
- Parameters
user – a user ID, email string, or
User
instance
-
fiftyone.management.users.
delete_user_invitation
(invitation: str) → None¶ Deletes/revokes a previously-sent invitation if it has not been accepted.
Note
Only admins can perform this action.
Examples:
import fiftyone.management as fom new_guest = "guest@company.com" invite_id = fom.send_user_invitation(new_guest, fom.GUEST) # Delete by invitation ID fom.delete_user_invitation(invite_id) # Delete by user email fom.delete_user_invitation(new_guest) pending = fom.list_pending_invitations() assert not any(p.id == invite_id for p in pending)
- Parameters
invitation – an invitation ID as returned by
send_user_invitation()
, or email address
-
fiftyone.management.users.
get_user
(user: str) → Optional[fiftyone.management.users.User]¶ Gets information about the specified user (if any).
Note
Only admins can retrieve information about other users.
Examples:
import fiftyone.management as fom known_user = "member@company.com" user = fom.get_user(known_user) assert user.email == known_user unknown_user = "unknown@company.com" assert fom.get_user(unknown_user) is None
- Parameters
user – a user ID or email string
- Returns
User
, orNone
if no such user is found
-
fiftyone.management.users.
list_pending_invitations
() → List[fiftyone.management.users.Invitation]¶ Returns a list of pending user invitations.
Note
Only admins can retrieve this information.
Examples:
import fiftyone.management as fom fom.list_pending_invitations()
- Returns
a list of
Invitation
instances
-
fiftyone.management.users.
list_users
(verbose=True) → Union[List[fiftyone.management.users.User], List[str]]¶ Returns a list of all users.
Note
Only admins can retrieve this information.
Examples:
import fiftyone.management as fom fom.list_users()
-
fiftyone.management.users.
send_user_invitation
(email: str, role: fiftyone.management.users.UserRole) → str¶ Sends an email invitation to join your FiftyOne Teams organization.
Note
Only admins can perform this action.
Examples:
import fiftyone.management as fom new_guest = "guest@company.com" invite_id = fom.send_user_invitation(new_guest, fom.GUEST) pending = fom.list_pending_invitations() assert any(p.invitee_email == new_guest for p in pending)
- Parameters
email – the email address
role – the
UserRole
to grant the new user
- Returns
the invitation ID string
-
fiftyone.management.users.
set_user_role
(user: Union[str, fiftyone.management.users.User], role: fiftyone.management.users.UserRole) → None¶ Sets the role of the given user.
Note
Only admins can perform this action.
Examples:
import fiftyone.management as fom user = "user@company.com" #1.a set role from email fom.set_user_role(user, fom.MEMBER) #1.b set role from user instance user_obj = fom.get_user(user_obj) fom.set_user_role(user_obj, fom.MEMBER) assert fom.get_user(user).role == fom.MEMBER
-
fiftyone.management.users.
whoami
() → fiftyone.management.users.User¶ Returns information about the calling user.
Examples:
import fiftyone.management as fom me = fom.whoami() assert fom.get_user(me.id) == me
- Returns
-
fiftyone.management.users.
resolve_user_id
(user_or_id_or_email: Optional[Union[str, fiftyone.management.users.User]], nullable: bool = False, pass_unknown_email: bool = False) → Optional[str]¶ Resolves user ID - by looking up user by email if it has to
Group management¶
Group management.
Classes:
|
User Group information dataclass. |
Functions:
|
Adds users to the given group. |
|
Creates a new user group. |
|
Deletes the given group. |
|
Gets information about the specified group (if any). |
|
Gets all user groups for the given user. |
|
Returns a list of all user groups. |
|
Removes users from the given group. |
|
Updates the given group. |
|
Resolves group ID - by looking up group by name if it has to |
-
class
fiftyone.management.user_groups.
UserGroup
(id: str, name: str, description: Optional[str], users: Optional[List[fiftyone.management.users.User]])¶ User Group information dataclass.
Attributes:
-
id
: str¶
-
name
: str¶
-
description
: Optional[str]¶
-
users
: Optional[List[fiftyone.management.users.User]]¶
-
-
fiftyone.management.user_groups.
add_users_to_group
(user_group: str, users: Union[List[Any], str], resolved_users: bool = False) → fiftyone.management.user_groups.UserGroup¶ Adds users to the given group.
Note
Only admins can perform this action.
Examples:
import fiftyone.management as fom group_id = "group id" user_ids = ["user id 1", "user id 2"] fom.add_users_to_group(user_group=group_id, user_ids=user_ids)
- Parameters
user_group – a group ID, name string, or
Group
instanceusers (None) – list of users (email or ID strings or User instances or dictionary objects with valid fields) or a single user string/obj
resolved_users (False) – If True, the user_ids are already resolved/validated
-
fiftyone.management.user_groups.
create_user_group
(name: str, description: Optional[str] = None, users: Optional[List[Union[str, fiftyone.management.users.User]]] = None) → fiftyone.management.user_groups.UserGroup¶ Creates a new user group.
Note
Only admins can perform this action.
Examples:
import fiftyone.management as fom group_name = "Name" group_description = "Description" fom.add_user_group(name=group_name, description=group_description) assert fom.get_user_group(group_name) is not None
- Parameters
name – group name, string
description (None) – optional group description, string
users (None) – optional list of user_ids, names or Users instance
-
fiftyone.management.user_groups.
delete_user_group
(user_group: Union[str, fiftyone.management.user_groups.UserGroup]) → None¶ Deletes the given group.
Note
Only admins can perform this action.
Warning
This action is irreversible!
Examples:
import fiftyone.management as fom group_name = "Group Name" fom.delete_user_group(group_name) assert fom.get_user_group(group_name) is None
- Parameters
user_group – a group ID, name string, or
Group
instance
-
fiftyone.management.user_groups.
get_user_group
(user_group: str) → Optional[fiftyone.management.user_groups.UserGroup]¶ Gets information about the specified group (if any).
Note
Only admins can retrieve information about user groups.
Examples:
import fiftyone.management as fom group_name = "Group Name" group = fom.get_user_group(group_name) assert group.name == group_name unknown_group = "Unknown Group" assert fom.get_user_group(unknown_group) is None
- Parameters
user_group – a group ID or name string
- Returns
Group
, orNone
if no such group is found
-
fiftyone.management.user_groups.
list_user_groups_for_user
(user: Union[str, dict, fiftyone.management.users.User], verbose=False) → List[dict]¶ Gets all user groups for the given user.
If the user_id does not exist, an empty list is returned.
if the email address is incorrect, an exception is raised.
If there is no group associated with the user, an empty list is returned.
Note
Only admins can retrieve this information.
Examples:
import fiftyone.management as fom user_id = "user id" fom.list_user_groups_for_user(user_id)
- Parameters
user – a user ID or email string, or
User
instanceverbose (True) – If True, returns the list of groups, otherwise return the list of group names
- Returns
- a list of dictionaries containing user group information or a list of
group names
-
fiftyone.management.user_groups.
list_user_groups
(num_groups: int = 100, verbose=False) → Union[List[fiftyone.management.user_groups.UserGroup], List[str]]¶ Returns a list of all user groups.
Note
Only admins can retrieve this information.
Examples:
import fiftyone.management as fom fom.list_user_groups()
- Parameters
num_groups (100) – The number of user groups to fetch
verbose (False) – If True, returns the list of groups, otherwise return
list of group names (the) –
- Returns
a list of
Group
instances or a list of group names
-
fiftyone.management.user_groups.
remove_users_from_group
(user_group: str, users: Union[List[Any], str], resolved_users: bool = False) → fiftyone.management.user_groups.UserGroup¶ Removes users from the given group.
Note
Only admins can perform this action.
Examples:
import fiftyone.management as fom user_group = "group id" user_ids = ["user id 1", "user id 2"] fom.remove_users_from_group(user_group=group_id, user_ids=user_ids)
- Parameters
user_group – a group ID, name string, or
Group
instanceusers (None) – list of users (email or ID strings or User instances or dictionary objects with valid fields) or a single user string/obj
resolved_users (False) – If True, the user_ids are already resolved/validated
-
fiftyone.management.user_groups.
update_user_group
(user_group: str, name: Optional[str] = None, description: Optional[str] = None, users: Optional[List[Union[str, fiftyone.management.user_groups.UserGroup]]] = None) → fiftyone.management.user_groups.UserGroup¶ Updates the given group.
Note
Only admins can perform this action.
Examples:
import fiftyone.management as fom group_id = "group id" group_name = "New Name" fom.update_user_group(user_group=group_id, name=group_name) assert fom.get_user_group(group_name) is not None
- Parameters
user_group – a group ID, name string, or
Group
instancename (None) – group name, string
description (None) – group description, string
users (None) – list of user id, name string or User instance. Existing users not in this list will be removed.
-
fiftyone.management.user_groups.
resolve_user_group_id
(group_or_id_or_name: Union[str, fiftyone.management.user_groups.UserGroup, None, dict]) → str¶ Resolves group ID - by looking up group by name if it has to