Skip to content

Commit

Permalink
black changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shincap8 committed Dec 19, 2024
1 parent 4b89041 commit cfac684
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backend/app/api/endpoints/base/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def heavy_evaluation(
model.task_code,
model.file_to_upload,
background_tasks,
)
)


@router.get("/initiate_lambda_models")
Expand Down
18 changes: 10 additions & 8 deletions backend/app/domain/services/base/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import json
import os
import re
import secrets
import time
import re

import boto3
import requests
import yaml
from fastapi import HTTPException, UploadFile, BackgroundTasks
from fastapi import BackgroundTasks, HTTPException, UploadFile
from pydantic import Json

from app.domain.helpers.email import EmailHelper
Expand Down Expand Up @@ -174,7 +174,7 @@ def upload_model_to_s3_and_evaluate(

def single_model_prediction(self, model_url: str, model_input: dict):
return requests.post(model_url, json=model_input).json()

def upload_model_to_s3(
self,
model_name: str,
Expand All @@ -187,13 +187,15 @@ def upload_model_to_s3(
task_id = self.task_repository.get_task_id_by_task_code(task_code)[0]
task_s3_bucket = self.task_repository.get_s3_bucket_by_task_id(task_id)[0]
user_email = self.user_repository.get_user_email(user_id)[0]

file_name = file_name.lower()
file_name = file_name.replace('/', ':')
file_name = re.sub(r'\s+', '_', file_name)
clean_file_name = re.sub(r'_+', '_', file_name)
file_name = file_name.replace("/", ":")
file_name = re.sub(r"\s+", "_", file_name)
clean_file_name = re.sub(r"_+", "_", file_name)

model_path = f"{task_code}/submited_models/{task_id}-{user_id}-{clean_file_name}"
model_path = (
f"{task_code}/submited_models/{task_id}-{user_id}-{clean_file_name}"
)
try:
self.s3.put_object(
Body=file_to_upload.file,
Expand Down
2 changes: 1 addition & 1 deletion backend/app/infrastructure/repositories/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_task_id_by_task_code(self, task_code: str):
.filter(self.model.task_code == task_code)
.first()
)

def get_s3_bucket_by_task_id(self, task_id: int):
return (
self.session.query(self.model.s3_bucket)
Expand Down

0 comments on commit cfac684

Please sign in to comment.