Skip to content

Commit

Permalink
KClips -> KRec and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ivntsng committed Nov 21, 2024
1 parent 692600e commit aa0f3fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions kscale/web/krec.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ async def upload_krec(robot_id: str, file_path: Path, name: str, description: st
# Step 3: Complete the upload
logger.info("Attempting to complete upload with %d parts", len(completed_parts))
try:
completion_response = await client.complete_krec_upload(
await client.complete_krec_upload(
krec_id=create_response.krec_id,
upload_id=create_response.upload_details.upload_id,
parts=completed_parts,
)
logger.info("Complete upload response: %s", completion_response)
logger.info("Upload completed successfully")
except Exception as e:
logger.error("Failed to complete upload: %s", str(e))
raise
Expand Down
11 changes: 9 additions & 2 deletions kscale/web/www_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class KScaleStoreClient:
def __init__(self, base_url: str = get_api_root(), upload_timeout: float = 300.0) -> None:
self.base_url = base_url
self.upload_timeout = upload_timeout
self._client = None
self._client: httpx.AsyncClient | None = None

@property
def client(self) -> httpx.AsyncClient:
Expand Down Expand Up @@ -59,7 +59,7 @@ async def _request(

response = await self.client.request(method, url, **kwargs)
if response.is_error:
logger.error("Error response from K-Scale Store: %s", response.text)
logger.error("Error response from K-Scale: %s", response.text)
response.raise_for_status()
return response.json()

Expand Down Expand Up @@ -119,3 +119,10 @@ async def upload_to_presigned_url(self, url: str, file_path: str) -> None:
async with httpx.AsyncClient(timeout=httpx.Timeout(timeout=self.upload_timeout)) as client:
response = await client.put(url, content=f.read(), headers={"Content-Type": "application/octet-stream"})
response.raise_for_status()

async def get_presigned_url(self, listing_id: str, file_name: str, checksum: str | None = None) -> dict:
"""Get a presigned URL for uploading an artifact."""
params = {"filename": file_name}
if checksum:
params["checksum"] = checksum
return await self._request("POST", f"/artifacts/presigned/{listing_id}", params=params)

0 comments on commit aa0f3fe

Please sign in to comment.