Quilt manages data like code with packages, repositories, browsing and revision history for machine learning and data-driven domains
—
Administrative capabilities for managing users, roles, SSO configuration, and other Quilt stack administrative tasks.
The quilt3.admin module provides administrative functions for Quilt stack backend services, including identity management, user administration, and system configuration.
import quilt3.adminfrom typing import Optional, List, Literal
from datetime import datetime
from dataclasses import dataclassAdministrative functions for managing users in the Quilt stack.
import quilt3.admin.users
def get(name: str) -> Optional[User]:
"""
Get a specific user from the registry.
Parameters:
- name: Username to retrieve
Returns:
User object if found, None otherwise
"""
def list() -> List[User]:
"""
Get a list of all users in the registry.
Returns:
List of User objects
"""
def create(name: str, email: str, role: str, extra_roles: Optional[List[str]] = None) -> User:
"""
Create a new user in the registry.
Parameters:
- name: Username for the new user
- email: Email address for the user
- role: Primary role for the user
- extra_roles: Additional roles to assign
Returns:
Created User object
"""
def delete(name: str) -> None:
"""
Delete user from the registry.
Parameters:
- name: Username to delete
"""
def set_email(name: str, email: str) -> User:
"""
Set the email for a user.
Parameters:
- name: Username to update
- email: New email address
Returns:
Updated User object
"""
def set_admin(name: str, admin: bool) -> User:
"""
Set the admin status for a user.
Parameters:
- name: Username to update
- admin: Whether user should have admin privileges
Returns:
Updated User object
"""
def set_active(name: str, active: bool) -> User:
"""
Set the active status for a user.
Parameters:
- name: Username to update
- active: Whether user account should be active
Returns:
Updated User object
"""
def reset_password(name: str) -> None:
"""
Reset password for a user.
Parameters:
- name: Username to reset password for
"""Administrative functions for managing roles and permissions.
import quilt3.admin.roles
def list() -> List[Role]:
"""
Get a list of all roles in the registry.
Returns:
List of Role objects (ManagedRole and UnmanagedRole)
"""Administrative functions for configuring Single Sign-On settings.
import quilt3.admin.sso_config
# SSO configuration functions for managing Single Sign-On settings
# Specific implementation depends on deployment configurationAdministrative functions for data tabulation and analysis.
import quilt3.admin.tabulator
# Tabulator functions for data processing and table management
# Specific implementation depends on deployment configuration@dataclass
class User:
"""
Represents a user in the Quilt system.
Attributes:
- name: Username
- email: User email address
- date_joined: When user account was created
- last_login: Last login timestamp
- is_active: Whether account is active
- is_admin: Whether user has admin privileges
- is_sso_only: Whether user can only login via SSO
- is_service: Whether this is a service account
- role: Primary role assigned to user
- extra_roles: Additional roles assigned to user
"""
name: str
email: str
date_joined: datetime
last_login: datetime
is_active: bool
is_admin: bool
is_sso_only: bool
is_service: bool
role: Optional[Role]
extra_roles: List[Role]@dataclass
class ManagedRole:
"""
Represents a managed role in the Quilt system.
Managed roles are controlled by the Quilt stack administrators
and have predefined permissions and policies.
"""
id: str
name: str
arn: str
typename__: Literal["ManagedRole"]
@dataclass
class UnmanagedRole:
"""
Represents an unmanaged role in the Quilt system.
Unmanaged roles are custom roles that can be configured
with specific permissions as needed.
"""
id: str
name: str
arn: str
typename__: Literal["UnmanagedRole"]@dataclass
class SSOConfig:
"""
Represents Single Sign-On configuration settings.
Contains SSO provider settings, authentication parameters,
and integration configuration.
"""
text: str
timestamp: datetime
uploader: User
@dataclass
class TabulatorTable:
"""
Represents a tabulator table configuration.
Contains table definition, schema, and processing settings
for data tabulation operations.
"""
name: str
config: strclass Quilt3AdminError(Exception):
"""
General administrative operation error.
Raised when admin operations fail due to permissions,
configuration issues, or system errors.
"""
pass
class UserNotFoundError(Quilt3AdminError):
"""
User not found error.
Raised when attempting to perform operations on
a user that doesn't exist in the system.
"""
pass
class BucketNotFoundError(Quilt3AdminError):
"""
Bucket not found error.
Raised when attempting to perform operations on
a bucket that doesn't exist or isn't accessible.
"""
passimport quilt3.admin
# Import specific admin modules
from quilt3.admin import users, roles, sso_config
# Admin operations require appropriate permissions
# and authentication to the Quilt stackimport quilt3.admin.users
from quilt3.admin import User, UserNotFoundError
try:
# User management operations
# (Specific APIs depend on admin implementation)
# Example operations might include:
# - List users
# - Create users
# - Update user permissions
# - Delete users
pass # Placeholder for actual admin operations
except UserNotFoundError as e:
print(f"User not found: {e}")
except Exception as e:
print(f"Admin operation failed: {e}")import quilt3.admin.roles
from quilt3.admin import ManagedRole, UnmanagedRole
# Role management operations
# (Specific APIs depend on admin implementation)
# Example operations might include:
# - List available roles
# - Create custom roles
# - Assign roles to users
# - Update role permissions
# - Delete roles
# Work with managed roles (predefined by system)
managed_roles = [] # Get managed roles from system
# Work with unmanaged roles (custom roles)
custom_roles = [] # Get custom roles from systemimport quilt3.admin.sso_config
from quilt3.admin import SSOConfig
# SSO configuration operations
# (Specific APIs depend on admin implementation)
# Example operations might include:
# - Configure SSO providers
# - Update authentication settings
# - Test SSO integration
# - Manage SSO user mappings
try:
# Configure SSO settings
sso_settings = SSOConfig()
# Update SSO configuration
except Exception as e:
print(f"SSO configuration failed: {e}")import quilt3.admin.tabulator
from quilt3.admin import TabulatorTable
# Tabulator operations for data analysis
# (Specific APIs depend on admin implementation)
# Example operations might include:
# - Define tabulation schemas
# - Process data through tabulator
# - Generate reports
# - Manage tabulation jobs
try:
# Configure tabulation table
table_config = TabulatorTable()
# Process data through tabulator
except Exception as e:
print(f"Tabulation operation failed: {e}")import quilt3.admin
from quilt3.admin import (
Quilt3AdminError,
UserNotFoundError,
BucketNotFoundError
)
def safe_admin_operation():
"""Example of safe admin operation with error handling"""
try:
# Perform admin operations
# result = admin_operation()
pass
except UserNotFoundError as e:
print(f"User does not exist: {e}")
return None
except BucketNotFoundError as e:
print(f"Bucket not accessible: {e}")
return None
except Quilt3AdminError as e:
print(f"Admin operation failed: {e}")
return None
except Exception as e:
print(f"Unexpected error: {e}")
return None
# Use safe operation
result = safe_admin_operation()
if result:
print("Admin operation successful")
else:
print("Admin operation failed - check permissions and configuration")import quilt3
# Admin operations require:
# 1. Proper authentication to Quilt stack
# 2. Administrative privileges
# 3. Correct configuration
def check_admin_access():
"""Check if current user has admin access"""
# Verify authentication
if not quilt3.logged_in():
print("Error: Not authenticated. Run quilt3.login() first.")
return False
# Verify configuration
config = quilt3.config()
if not config.get('registryUrl'):
print("Error: No registry URL configured.")
return False
# Test basic admin access
try:
import quilt3.admin
print("Admin module imported successfully")
return True
except ImportError as e:
print(f"Error: Admin module not available: {e}")
return False
except Exception as e:
print(f"Error: Admin access check failed: {e}")
return False
# Check admin prerequisites
if check_admin_access():
print("Ready for admin operations")
# Proceed with admin tasks
else:
print("Admin operations not available")
# Handle lack of admin accessInstall with Tessl CLI
npx tessl i tessl/pypi-quilt3