Skip to content

Commit e4e2d18

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a11db54 commit e4e2d18

File tree

21 files changed

+105
-106
lines changed

21 files changed

+105
-106
lines changed

backend/src/app/celery/background_jobs/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ def execute_text_preprocessing_pipeline_apply_async(
119119
execute_text_preprocessing_pipeline_task,
120120
)
121121

122-
assert isinstance(
123-
execute_text_preprocessing_pipeline_task, Task
124-
), "Not a Celery Task"
122+
assert isinstance(execute_text_preprocessing_pipeline_task, Task), (
123+
"Not a Celery Task"
124+
)
125125

126126
tasks = []
127127
for cargo in cargos:
@@ -136,9 +136,9 @@ def execute_image_preprocessing_pipeline_apply_async(
136136
execute_image_preprocessing_pipeline_task,
137137
)
138138

139-
assert isinstance(
140-
execute_image_preprocessing_pipeline_task, Task
141-
), "Not a Celery Task"
139+
assert isinstance(execute_image_preprocessing_pipeline_task, Task), (
140+
"Not a Celery Task"
141+
)
142142

143143
for cargo in cargos:
144144
execute_image_preprocessing_pipeline_task.apply_async(kwargs={"cargo": cargo})
@@ -151,9 +151,9 @@ def execute_audio_preprocessing_pipeline_apply_async(
151151
execute_audio_preprocessing_pipeline_task,
152152
)
153153

154-
assert isinstance(
155-
execute_audio_preprocessing_pipeline_task, Task
156-
), "Not a Celery Task"
154+
assert isinstance(execute_audio_preprocessing_pipeline_task, Task), (
155+
"Not a Celery Task"
156+
)
157157

158158
for cargo in cargos:
159159
execute_audio_preprocessing_pipeline_task.apply_async(kwargs={"cargo": cargo})
@@ -166,9 +166,9 @@ def execute_video_preprocessing_pipeline_apply_async(
166166
execute_video_preprocessing_pipeline_task,
167167
)
168168

169-
assert isinstance(
170-
execute_video_preprocessing_pipeline_task, Task
171-
), "Not a Celery Task"
169+
assert isinstance(execute_video_preprocessing_pipeline_task, Task), (
170+
"Not a Celery Task"
171+
)
172172

173173
for cargo in cargos:
174174
execute_video_preprocessing_pipeline_task.apply_async(kwargs={"cargo": cargo})

backend/src/app/core/analysis/cota/pipeline/pipeline.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ def execute(self, job: COTARefinementJobRead) -> COTARefinementJobRead:
8282
stop_t = time.perf_counter()
8383

8484
logger.info(
85-
f"Executing the COTARefinementPipeline took"
86-
f" {stop_t - start_t:0.4f} seconds"
85+
f"Executing the COTARefinementPipeline took {stop_t - start_t:0.4f} seconds"
8786
)
8887

8988
return job
@@ -163,7 +162,7 @@ def _run_step(self, cargo: Cargo, step: PipelineStep) -> Cargo:
163162
logger.error(msg)
164163
raise ValueError(msg)
165164

166-
logger.info((f"Running: {step} for " f"COTARefinementJob {cargo.job.id} "))
165+
logger.info((f"Running: {step} for COTARefinementJob {cargo.job.id} "))
167166
cargo = self._update_cota_job(
168167
cargo=cargo,
169168
current_step_name=step.name,

backend/src/app/core/data/crud/memo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ def create_for_attached_object(
138138
raise NotImplementedError(
139139
f"Unknown AttachedObjectType: {attached_object_type}"
140140
)
141-
assert (
142-
oh_create_dto is not None
143-
), f"Unknown AttachedObjectType: {attached_object_type}"
141+
assert oh_create_dto is not None, (
142+
f"Unknown AttachedObjectType: {attached_object_type}"
143+
)
144144

145145
# create an ObjectHandle for the attached object
146146
oh_db_obj = crud_object_handle.create(db=db, create_dto=oh_create_dto)

backend/src/app/core/data/dto/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ElasticSearchMemoRead(BaseModel):
7070
description="The ID of the Object the Memo is attached to"
7171
)
7272
attached_object_type: Optional[AttachedObjectType] = Field(
73-
description=("The type of the Object the Memo is " "attached to")
73+
description=("The type of the Object the Memo is attached to")
7474
)
7575
updated: Optional[datetime] = Field(
7676
description="The created date of the Memo", default=datetime.now()

backend/src/app/core/data/export/export_sdocs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def get_all_sdoc_transcripts_in_project_for_export(
5757
logger.info(f"Export sdoc datas transcript for {sdoc_ids}")
5858
sdoc_datas = crud_sdoc.read_data_batch(db=db, ids=sdoc_ids)
5959
for sdoc_data, sdoc in zip(sdoc_datas, sdocs):
60-
assert (
61-
sdoc_data
62-
), f"Expected sdoc data for id {sdoc.id} to exist, because sdocs exist."
60+
assert sdoc_data, (
61+
f"Expected sdoc data for id {sdoc.id} to exist, because sdocs exist."
62+
)
6363
wlt = sdoc_data.word_level_transcriptions
6464
if wlt is not None:
6565
logger.info(f"Exporting word_level_transcript of file {sdoc.filename}")

backend/src/app/core/data/import_/import_project.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -393,39 +393,39 @@ def import_project(
393393
execute_video_preprocessing_pipeline_task,
394394
)
395395

396-
assert isinstance(
397-
execute_text_preprocessing_pipeline_task, Task
398-
), "Not a Celery Task"
396+
assert isinstance(execute_text_preprocessing_pipeline_task, Task), (
397+
"Not a Celery Task"
398+
)
399399

400400
tasks = [
401401
execute_text_preprocessing_pipeline_task.s(cargo, is_init=False)
402402
for cargo in cargos[DocType.text]
403403
]
404404

405405
# 5. init image pipelines
406-
assert isinstance(
407-
execute_image_preprocessing_pipeline_task, Task
408-
), "Not a Celery Task"
406+
assert isinstance(execute_image_preprocessing_pipeline_task, Task), (
407+
"Not a Celery Task"
408+
)
409409
image_tasks = [
410410
execute_image_preprocessing_pipeline_task.s(cargo, is_init=False)
411411
for cargo in cargos[DocType.image]
412412
]
413413
tasks.extend(image_tasks)
414414

415415
# 6. init audio pipelines
416-
assert isinstance(
417-
execute_audio_preprocessing_pipeline_task, Task
418-
), "Not a Celery Task"
416+
assert isinstance(execute_audio_preprocessing_pipeline_task, Task), (
417+
"Not a Celery Task"
418+
)
419419
audio_tasks = [
420420
execute_audio_preprocessing_pipeline_task.s(cargo, is_init=False)
421421
for cargo in cargos[DocType.audio]
422422
]
423423
tasks.extend(audio_tasks)
424424

425425
# 7. init video pipelines
426-
assert isinstance(
427-
execute_video_preprocessing_pipeline_task, Task
428-
), "Not a Celery Task"
426+
assert isinstance(execute_video_preprocessing_pipeline_task, Task), (
427+
"Not a Celery Task"
428+
)
429429
video_tasks = [
430430
execute_video_preprocessing_pipeline_task.s(cargo, is_init=False)
431431
for cargo in cargos[DocType.video]

backend/src/app/core/data/llm/llm_service.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,12 @@ def _llm_document_tagging(
448448
approach_parameters: ZeroShotParams,
449449
task_parameters: DocumentTaggingParams,
450450
) -> LLMJobResult:
451-
assert isinstance(
452-
task_parameters, DocumentTaggingParams
453-
), "Wrong task parameters!"
454-
assert isinstance(
455-
approach_parameters, ZeroShotParams
456-
), "Wrong approach parameters!"
451+
assert isinstance(task_parameters, DocumentTaggingParams), (
452+
"Wrong task parameters!"
453+
)
454+
assert isinstance(approach_parameters, ZeroShotParams), (
455+
"Wrong approach parameters!"
456+
)
457457

458458
msg = f"Started LLMJob - Document Tagging, num docs: {len(task_parameters.sdoc_ids)}"
459459
self._update_llm_job_description(
@@ -573,12 +573,12 @@ def _llm_metadata_extraction(
573573
approach_parameters: ZeroShotParams,
574574
task_parameters: MetadataExtractionParams,
575575
) -> LLMJobResult:
576-
assert isinstance(
577-
task_parameters, MetadataExtractionParams
578-
), "Wrong task parameters!"
579-
assert isinstance(
580-
approach_parameters, ZeroShotParams
581-
), "Wrong approach parameters!"
576+
assert isinstance(task_parameters, MetadataExtractionParams), (
577+
"Wrong task parameters!"
578+
)
579+
assert isinstance(approach_parameters, ZeroShotParams), (
580+
"Wrong approach parameters!"
581+
)
582582

583583
msg = f"Started LLMJob - Metadata Extraction, num docs: {len(task_parameters.sdoc_ids)}"
584584
self._update_llm_job_description(
@@ -721,9 +721,9 @@ def _llm_annotation(
721721
task_parameters: AnnotationParams,
722722
) -> LLMJobResult:
723723
assert isinstance(task_parameters, AnnotationParams), "Wrong task parameters!"
724-
assert isinstance(
725-
approach_parameters, ZeroShotParams
726-
), "Wrong approach parameters!"
724+
assert isinstance(approach_parameters, ZeroShotParams), (
725+
"Wrong approach parameters!"
726+
)
727727

728728
msg = f"Started LLMJob - Annotation, num docs: {len(task_parameters.sdoc_ids)}"
729729
self._update_llm_job_description(
@@ -887,9 +887,9 @@ def _llm_sentence_annotation(
887887
approach_parameters: Union[ZeroShotParams, FewShotParams],
888888
task_parameters: SentenceAnnotationParams,
889889
) -> LLMJobResult:
890-
assert isinstance(
891-
task_parameters, SentenceAnnotationParams
892-
), "Wrong task parameters!"
890+
assert isinstance(task_parameters, SentenceAnnotationParams), (
891+
"Wrong task parameters!"
892+
)
893893
assert isinstance(approach_parameters, ZeroShotParams) or isinstance(
894894
approach_parameters, FewShotParams
895895
), "Wrong approach parameters!"
@@ -1101,12 +1101,12 @@ def _ray_sentence_annotation(
11011101
approach_parameters: ModelTrainingParams,
11021102
task_parameters: SentenceAnnotationParams,
11031103
) -> LLMJobResult:
1104-
assert isinstance(
1105-
task_parameters, SentenceAnnotationParams
1106-
), "Wrong task parameters!"
1107-
assert isinstance(
1108-
approach_parameters, ModelTrainingParams
1109-
), "Wrong approach parameters!"
1104+
assert isinstance(task_parameters, SentenceAnnotationParams), (
1105+
"Wrong task parameters!"
1106+
)
1107+
assert isinstance(approach_parameters, ModelTrainingParams), (
1108+
"Wrong approach parameters!"
1109+
)
11101110

11111111
msg = f"Started LLMJob - Sentence Annotation (RAY), num docs: {len(task_parameters.sdoc_ids)}"
11121112
self._update_llm_job(

backend/src/app/core/data/llm/ollama_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def __new__(cls, *args, **kwargs):
4040
)
4141
logger.info(f"Model {model} has been created successfully.")
4242
available_models = [x.model for x in ollamac.list()["models"]]
43-
assert (
44-
model in available_models
45-
), f"Model {model} is not available. Available models are: {available_models}"
43+
assert model in available_models, (
44+
f"Model {model} is not available. Available models are: {available_models}"
45+
)
4646

4747
cls.__model = model
4848
cls.__client = ollamac

backend/src/app/core/data/llm/prompts/sentence_annotation_prompt_builder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ def _build_user_prompt_template(
140140

141141
# check that there are at least 4 examples per code
142142
for code_id, annotations in code_id2sentence_annotations.items():
143-
assert (
144-
len(annotations) >= sent_anno_conf.few_shot_threshold
145-
), f"Code {code_id} has less than {sent_anno_conf.few_shot_threshold} annotations!"
143+
assert len(annotations) >= sent_anno_conf.few_shot_threshold, (
144+
f"Code {code_id} has less than {sent_anno_conf.few_shot_threshold} annotations!"
145+
)
146146

147147
# find corrsponding sdoc datas
148148
sdoc_ids = [sa.sdoc_id for sa in sentence_annotations]

backend/src/app/core/db/simsearch_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ def _encode_text(self, text: List[str], return_avg_emb: bool = False) -> np.ndar
7070
def _get_image_name_from_sdoc_id(self, sdoc_id: int) -> SourceDocumentRead:
7171
with self.sqls.db_session() as db:
7272
sdoc = SourceDocumentRead.model_validate(crud_sdoc.read(db=db, id=sdoc_id))
73-
assert (
74-
sdoc.doctype == DocType.image
75-
), f"SourceDocument with {sdoc_id=} is not an image!"
73+
assert sdoc.doctype == DocType.image, (
74+
f"SourceDocument with {sdoc_id=} is not an image!"
75+
)
7676
return sdoc
7777

7878
def _encode_image(self, image_sdoc_id: int) -> np.ndarray:

0 commit comments

Comments
 (0)