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
9 changes: 1 addition & 8 deletions src/lumino/api_key.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
"""
API key management endpoints for the Lumino SDK.

This module contains the ApiKeyEndpoint class, which provides methods
for interacting with API key-related endpoints.
"""

import logging
from typing import Any, List
from typing import Any

from lumino.models import (
ApiKeyCreate,
Expand Down
34 changes: 1 addition & 33 deletions src/lumino/dataset.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
"""
Dataset operation endpoints for the Lumino SDK.

This module contains the DatasetEndpoint class, which provides methods
for interacting with dataset-related API endpoints.
"""

import logging
from typing import Any, List
from typing import Any

import aiohttp

Expand Down Expand Up @@ -139,28 +132,3 @@ async def delete_dataset(self, dataset_name: str) -> None:
"""
self.logger.info("Deleting dataset: %s", dataset_name)
await self._sdk._request("DELETE", f"/datasets/{dataset_name}")

async def download_dataset(self, dataset_name: str, output_path: str) -> None:
"""
Download a dataset.

Args:
dataset_name (str): The name of the dataset to download.
output_path (str): The path where the downloaded dataset will be saved.

Raises:
LuminoAPIError: If the API request fails.
IOError: If there's an error writing the file.
"""
self.logger.info("Downloading dataset: %s", dataset_name)
response = await self._sdk._request("GET", f"/datasets/{dataset_name}/download", stream=True)

try:
with open(output_path, 'wb') as f:
async for chunk in response.content.iter_chunked(8192):
f.write(chunk)
except IOError as e:
self.logger.error("Error writing dataset to file: %s", str(e))
raise

self.logger.info("Dataset downloaded successfully to: %s", output_path)
57 changes: 6 additions & 51 deletions src/lumino/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
"""
Custom exception classes for the Lumino SDK.

This module defines exception classes specific to the Lumino SDK,
allowing for more precise error handling in client applications.
"""

from typing import Any, Optional


class LuminoError(Exception):
"""Base exception class for all Lumino SDK errors."""
class LuminoValueError(Exception):
"""
Exception raised when attempting to send an invalid value to the Lumino API.
"""
pass

def __init__(self, message: str):
"""
Initialize the LuminoError.

Args:
message (str): The error message.
"""
self.message = message
super().__init__(self.message)


class LuminoAPIError(LuminoError):
class LuminoAPIError(Exception):
"""Exception raised for errors returned by the Lumino API."""

def __init__(self, status: int, message: str, details: Optional[Any] = None):
Expand All @@ -37,34 +23,3 @@ def __init__(self, status: int, message: str, details: Optional[Any] = None):
self.status = status
self.details = details
super().__init__(f"Lumino API Error (Status {status}): {message}")


class LuminoConfigurationError(LuminoError):
"""Exception raised for configuration errors in the Lumino SDK."""

def __init__(self, message: str):
"""
Initialize the LuminoConfigurationError.

Args:
message (str): The error message describing the configuration issue.
"""
super().__init__(f"Lumino SDK Configuration Error: {message}")


class LuminoValidationError(LuminoError):
"""Exception raised for validation errors in the Lumino SDK."""

def __init__(self, message: str, field: Optional[str] = None):
"""
Initialize the LuminoValidationError.

Args:
message (str): The error message describing the validation issue.
field (Optional[str]): The name of the field that failed validation, if applicable.
"""
self.field = field
error_message = f"Validation Error: {message}"
if field:
error_message = f"{error_message} (Field: {field})"
super().__init__(error_message)
64 changes: 1 addition & 63 deletions src/lumino/fine_tuning.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
"""
Fine-tuning job management endpoints for the Lumino SDK.

This module contains the FineTuningEndpoint class, which provides methods
for interacting with fine-tuning job-related API endpoints.
"""

import logging
from typing import Any, List, Optional
from typing import Any, Optional

from lumino.models import (
FineTuningJobCreate,
Expand Down Expand Up @@ -109,58 +102,3 @@ async def cancel_fine_tuning_job(self, job_name: str) -> FineTuningJobDetailResp
self.logger.info("Cancelling fine-tuning job: %s", job_name)
data = await self._sdk._request("POST", f"/fine-tuning/{job_name}/cancel")
return FineTuningJobDetailResponse(**data)

async def delete_fine_tuning_job(self, job_name: str) -> None:
"""
Delete a fine-tuning job.

Args:
job_name (str): The name of the fine-tuning job to delete.

Raises:
LuminoAPIError: If the API request fails.
"""
self.logger.info("Deleting fine-tuning job: %s", job_name)
await self._sdk._request("DELETE", f"/fine-tuning/{job_name}")

async def get_fine_tuning_job_metrics(self, job_name: str) -> dict:
"""
Get metrics for a specific fine-tuning job.

Args:
job_name (str): The name of the fine-tuning job.

Returns:
dict: A dictionary containing metrics for the fine-tuning job.

Raises:
LuminoAPIError: If the API request fails.
"""
self.logger.info("Getting metrics for fine-tuning job: %s", job_name)
data = await self._sdk._request("GET", f"/fine-tuning/{job_name}/metrics")
return data

async def get_fine_tuning_job_logs(self, job_name: str, start_time: Optional[str] = None,
end_time: Optional[str] = None) -> List[str]:
"""
Get logs for a specific fine-tuning job.

Args:
job_name (str): The name of the fine-tuning job.
start_time (Optional[str]): The start time for log retrieval (ISO format).
end_time (Optional[str]): The end time for log retrieval (ISO format).

Returns:
List[str]: A list of log entries for the fine-tuning job.

Raises:
LuminoAPIError: If the API request fails.
"""
self.logger.info("Getting logs for fine-tuning job: %s", job_name)
params = {}
if start_time:
params["start_time"] = start_time
if end_time:
params["end_time"] = end_time
data = await self._sdk._request("GET", f"/fine-tuning/{job_name}/logs", params=params)
return data["logs"]
56 changes: 1 addition & 55 deletions src/lumino/model.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
"""
Model information retrieval endpoints for the Lumino SDK.

This module contains the ModelEndpoint class, which provides methods
for interacting with model-related API endpoints.
"""

import logging
from typing import Any, Optional
from typing import Any

from lumino.models import (
BaseModelResponse,
Expand Down Expand Up @@ -108,50 +101,3 @@ async def get_fine_tuned_model(self, model_name: str) -> FineTunedModelResponse:
self.logger.info("Getting fine-tuned model: %s", model_name)
data = await self._sdk._request("GET", f"/models/fine-tuned/{model_name}")
return FineTunedModelResponse(**data)

async def delete_fine_tuned_model(self, model_name: str) -> None:
"""
Delete a fine-tuned model.

Args:
model_name (str): The name of the fine-tuned model to delete.

Raises:
LuminoAPIError: If the API request fails.
"""
self.logger.info("Deleting fine-tuned model: %s", model_name)
await self._sdk._request("DELETE", f"/models/fine-tuned/{model_name}")

async def get_model_performance(self, model_name: str) -> dict:
"""
Get performance metrics for a specific model.

Args:
model_name (str): The name of the model (base or fine-tuned).

Returns:
dict: A dictionary containing performance metrics for the model.

Raises:
LuminoAPIError: If the API request fails.
"""
self.logger.info("Getting performance metrics for model: %s", model_name)
data = await self._sdk._request("GET", f"/models/{model_name}/performance")
return data

async def compare_models(self, model_names: list[str]) -> dict:
"""
Compare performance metrics for multiple models.

Args:
model_names (list[str]): A list of model names to compare.

Returns:
dict: A dictionary containing comparative performance metrics for the specified models.

Raises:
LuminoAPIError: If the API request fails.
"""
self.logger.info("Comparing models: %s", ", ".join(model_names))
data = await self._sdk._request("POST", "/models/compare", json={"models": model_names})
return data
Loading