Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions api/transformerlab/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
get_user_personal_team_id,
validate_api_key_and_get_user,
)
from transformerlab.schemas.auth import CurrentUserResponse
from transformerlab.utils.api_key_utils import mask_key
from lab.dirs import get_workspace_dir
from lab import storage
Expand Down Expand Up @@ -437,20 +438,39 @@ async def logout_cookie():
return response


@router.get("/users/me", response_model=UserRead)
async def get_current_user(user: User = Depends(current_active_user)):
@router.get("/users/me", response_model=CurrentUserResponse)
async def get_current_user(
request: Request,
user: User = Depends(current_active_user),
session: AsyncSession = Depends(get_async_session),
):
"""
Get current user information.
Supports both JWT and API key authentication.

When authenticated via API key, api_key_team_id will be populated
with the team_id that the API key is scoped to (if any).
"""
return UserRead(
id=user.id,
api_key_team_id: Optional[str] = None

try:
auth_user, key_team_id, auth_method = await _get_user_from_jwt_or_api_key(request, session)
# Sanity check that the authenticated user matches the dependency user
if auth_user.id == user.id and auth_method == "api_key":
api_key_team_id = key_team_id
except HTTPException:
# Fallback: ignore API key-specific info if authentication helper fails
api_key_team_id = None

return CurrentUserResponse(
id=str(user.id),
email=user.email,
is_active=user.is_active,
is_superuser=user.is_superuser,
is_verified=user.is_verified,
first_name=user.first_name,
last_name=user.last_name,
api_key_team_id=api_key_team_id,
)


Expand Down
16 changes: 16 additions & 0 deletions api/transformerlab/schemas/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,19 @@ class UserResponse(BaseModel):
authenticated: bool = False
source: Literal["session", "api_key", "anonymous"] = "anonymous"
api_key: Optional[str] = None


class CurrentUserResponse(BaseModel):
"""
Response model for /users/me that is compatible with UserRead
but also includes api_key_team_id when authenticated via API key.
"""

id: str
email: str
is_active: bool
is_superuser: bool
is_verified: bool
first_name: Optional[str] = None
last_name: Optional[str] = None
api_key_team_id: Optional[str] = None
44 changes: 37 additions & 7 deletions cli/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,26 @@ lab task queue <task_id> --no-interactive
|--------------------|------------------------------------------------|
| `--no-interactive` | Skip interactive prompts and use defaults |

#### `task gallery`

Browse the task gallery. Optionally import a task into the current experiment.

```bash
# List all gallery tasks
lab task gallery

# List interactive templates only
lab task gallery --type interactive

# Import directly (non-interactive)
lab task gallery --import <gallery_id>
```

| Option | Description |
|------------|----------------------------------------------------------|
| `--type` | Gallery type: `all` (default) or `interactive` |
| `--import` | Gallery ID to import as a task (skips interactive prompt)|

---

### `job`
Expand All @@ -192,27 +212,37 @@ lab job info <job_id>

#### `job artifacts`

List artifacts for a specific job.
List artifacts for a specific job. Includes filename, path, and size (when available).

```bash
lab job artifacts <job_id>
```

#### `job download`

Download all artifacts for a job as a zip file.
Download artifacts for a job.

```bash
# Download to current directory
# Download all as zip (existing behavior)
lab job download <job_id>

# Download a single file
lab job download <job_id> --file model.bin

# Download files matching a glob pattern
lab job download <job_id> --file "*.json"

# Download multiple specific files
lab job download <job_id> --file weights.bin --file config.json

# Download to a specific directory
lab job download <job_id> --output ./downloads
lab job download <job_id> --file "*.ckpt" --output ./checkpoints
```

| Option | Description |
|-----------------|--------------------------------------------------------------|
| `-o`, `--output`| Output directory for the zip file (default: current directory)|
| Option | Description |
|-----------------|---------------------------------------------------------------------------|
| `--file` | Filename or glob pattern (repeatable). Omit to download all as zip. |
| `-o`, `--output`| Output directory (default: current directory) |

#### `job monitor`

Expand Down
Loading
Loading