@@ -25,7 +25,7 @@ def get(
2525 return query .first ()
2626
2727
28- def get_by_id (org_id : str , file_transformation_id : str ) -> FileTransformation :
28+ def get_by_org_and_id (org_id : str , file_transformation_id : str ) -> FileTransformation :
2929 return (
3030 session .query (FileTransformation )
3131 .filter (
@@ -36,6 +36,16 @@ def get_by_id(org_id: str, file_transformation_id: str) -> FileTransformation:
3636 )
3737
3838
39+ def get_by_id (file_transformation_id : str ) -> FileTransformation :
40+ return (
41+ session .query (FileTransformation )
42+ .filter (
43+ FileTransformation .id == file_transformation_id ,
44+ )
45+ .first ()
46+ )
47+
48+
3949def get_all_by_file_extraction_id (
4050 org_id : str , file_extraction_id : str
4151) -> List [FileTransformation ]:
@@ -79,7 +89,7 @@ def update(
7989 state : Optional [str ] = None ,
8090 with_commit : bool = True ,
8191) -> FileTransformation :
82- file_transformation = get_by_id (org_id , file_transformation_id )
92+ file_transformation = get_by_org_and_id (org_id , file_transformation_id )
8393 if file_transformation .state == enums .FileCachingState .CANCELED .value :
8494 return
8595 if minio_path is not None :
@@ -91,14 +101,14 @@ def update(
91101
92102
93103def delete (org_id : str , file_transformation_id : str , with_commit : bool = True ):
94- file_transformation = get_by_id (org_id , file_transformation_id )
104+ file_transformation = get_by_org_and_id (org_id , file_transformation_id )
95105 general .delete (file_transformation , with_commit )
96106
97107
98108def set_state_to_failed (
99109 org_id : str , file_transformation_id : str , with_commit : bool = True
100110) -> FileTransformation :
101- file_transformation = get_by_id (org_id , file_transformation_id )
111+ file_transformation = get_by_org_and_id (org_id , file_transformation_id )
102112 if (
103113 not file_transformation
104114 or file_transformation .state == enums .FileCachingState .CANCELED .value
@@ -148,6 +158,9 @@ def create_file_transformation_llm_log(
148158 finished_at : Optional [datetime ] = None ,
149159 with_commit : bool = True ,
150160) -> None :
161+ file_transformation = get_by_id (file_transformation_id )
162+ if not file_transformation :
163+ return
151164 file_transformation_llm_log = FileTransformationLLMLogs (
152165 file_transformation_id = file_transformation_id ,
153166 input = input_text ,
0 commit comments