Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: system default CA certificate not being fetched #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 12 additions & 5 deletions src/lumino/fine_tuning.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import ssl
import certifi
from typing import Optional

from lumino.models import (
Expand All @@ -16,6 +18,11 @@ class FineTuningEndpoint:
Handles fine-tuning job-related API endpoints for the Lumino SDK.
"""

"""
The SSL context to use for API requests. This is set to use the system's default CA certificates.
"""
ssl = ssl.create_default_context(cafile=certifi.where())

def __init__(self, sdk: LuminoSDK):
"""
Initialize the FineTuningEndpoint.
Expand All @@ -41,7 +48,7 @@ async def create_fine_tuning_job(self, job_create: FineTuningJobCreate) -> FineT
LuminoValidationError: If the provided data is invalid.
"""
self.logger.info("Creating fine-tuning job: %s", job_create.name)
data = await self._sdk.request("POST", "/fine-tuning", json=job_create.model_dump())
data = await self._sdk.request("POST", "/fine-tuning", json=job_create.model_dump(), ssl=ssl)
return FineTuningJobResponse(**data)

async def list_fine_tuning_jobs(self, page: int = 1, items_per_page: int = 20,
Expand All @@ -64,7 +71,7 @@ async def list_fine_tuning_jobs(self, page: int = 1, items_per_page: int = 20,
params = {"page": page, "items_per_page": items_per_page}
if status:
params["status"] = status
data = await self._sdk.request("GET", "/fine-tuning", params=params)
data = await self._sdk.request("GET", "/fine-tuning", params=params, ssl=ssl)
return ListResponse(
data=[FineTuningJobResponse(**item) for item in data['data']],
pagination=Pagination(**data['pagination'])
Expand All @@ -84,7 +91,7 @@ async def get_fine_tuning_job(self, job_name: str) -> FineTuningJobDetailRespons
LuminoAPIError: If the API request fails.
"""
self.logger.info("Getting fine-tuning job: %s", job_name)
data = await self._sdk.request("GET", f"/fine-tuning/{job_name}")
data = await self._sdk.request("GET", f"/fine-tuning/{job_name}", ssl=ssl)
return FineTuningJobDetailResponse(**data)

async def cancel_fine_tuning_job(self, job_name: str) -> FineTuningJobDetailResponse:
Expand All @@ -101,7 +108,7 @@ async def cancel_fine_tuning_job(self, job_name: str) -> FineTuningJobDetailResp
LuminoAPIError: If the API request fails.
"""
self.logger.info("Cancelling fine-tuning job: %s", job_name)
data = await self._sdk.request("POST", f"/fine-tuning/{job_name}/cancel")
data = await self._sdk.request("POST", f"/fine-tuning/{job_name}/cancel", ssl=ssl)
return FineTuningJobDetailResponse(**data)

async def delete_fine_tuning_job(self, job_name: str) -> None:
Expand All @@ -115,5 +122,5 @@ async def delete_fine_tuning_job(self, job_name: str) -> None:
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}")
await self._sdk.request("DELETE", f"/fine-tuning/{job_name}", ssl=ssl)
self.logger.info("Deleted fine-tuning job: %s", job_name)