Skip to content

Commit eaef019

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

File tree

18 files changed

+92
-93
lines changed

18 files changed

+92
-93
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ def execute_text_preprocessing_pipeline_apply_async(
140140
execute_text_preprocessing_pipeline_task,
141141
)
142142

143-
assert isinstance(
144-
execute_text_preprocessing_pipeline_task, Task
145-
), "Not a Celery Task"
143+
assert isinstance(execute_text_preprocessing_pipeline_task, Task), (
144+
"Not a Celery Task"
145+
)
146146

147147
tasks = []
148148
for cargo in cargos:
@@ -157,9 +157,9 @@ def execute_image_preprocessing_pipeline_apply_async(
157157
execute_image_preprocessing_pipeline_task,
158158
)
159159

160-
assert isinstance(
161-
execute_image_preprocessing_pipeline_task, Task
162-
), "Not a Celery Task"
160+
assert isinstance(execute_image_preprocessing_pipeline_task, Task), (
161+
"Not a Celery Task"
162+
)
163163

164164
for cargo in cargos:
165165
execute_image_preprocessing_pipeline_task.apply_async(kwargs={"cargo": cargo})
@@ -172,9 +172,9 @@ def execute_audio_preprocessing_pipeline_apply_async(
172172
execute_audio_preprocessing_pipeline_task,
173173
)
174174

175-
assert isinstance(
176-
execute_audio_preprocessing_pipeline_task, Task
177-
), "Not a Celery Task"
175+
assert isinstance(execute_audio_preprocessing_pipeline_task, Task), (
176+
"Not a Celery Task"
177+
)
178178

179179
for cargo in cargos:
180180
execute_audio_preprocessing_pipeline_task.apply_async(kwargs={"cargo": cargo})
@@ -187,9 +187,9 @@ def execute_video_preprocessing_pipeline_apply_async(
187187
execute_video_preprocessing_pipeline_task,
188188
)
189189

190-
assert isinstance(
191-
execute_video_preprocessing_pipeline_task, Task
192-
), "Not a Celery Task"
190+
assert isinstance(execute_video_preprocessing_pipeline_task, Task), (
191+
"Not a Celery Task"
192+
)
193193

194194
for cargo in cargos:
195195
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
@@ -142,9 +142,9 @@ def create_for_attached_object(
142142
raise NotImplementedError(
143143
f"Unknown AttachedObjectType: {attached_object_type}"
144144
)
145-
assert (
146-
oh_create_dto is not None
147-
), f"Unknown AttachedObjectType: {attached_object_type}"
145+
assert oh_create_dto is not None, (
146+
f"Unknown AttachedObjectType: {attached_object_type}"
147+
)
148148

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

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
@@ -447,12 +447,12 @@ def _llm_document_tagging(
447447
approach_parameters: ZeroShotParams,
448448
task_parameters: DocumentTaggingParams,
449449
) -> LLMJobResult:
450-
assert isinstance(
451-
task_parameters, DocumentTaggingParams
452-
), "Wrong task parameters!"
453-
assert isinstance(
454-
approach_parameters, ZeroShotParams
455-
), "Wrong approach parameters!"
450+
assert isinstance(task_parameters, DocumentTaggingParams), (
451+
"Wrong task parameters!"
452+
)
453+
assert isinstance(approach_parameters, ZeroShotParams), (
454+
"Wrong approach parameters!"
455+
)
456456

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

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

727727
msg = f"Started LLMJob - Annotation, num docs: {len(task_parameters.sdoc_ids)}"
728728
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/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
@@ -76,9 +76,9 @@ def _encode_text(self, text: List[str], return_avg_emb: bool = False) -> np.ndar
7676
def _get_image_name_from_sdoc_id(self, sdoc_id: int) -> SourceDocumentRead:
7777
with self.sqls.db_session() as db:
7878
sdoc = SourceDocumentRead.model_validate(crud_sdoc.read(db=db, id=sdoc_id))
79-
assert (
80-
sdoc.doctype == DocType.image
81-
), f"SourceDocument with {sdoc_id=} is not an image!"
79+
assert sdoc.doctype == DocType.image, (
80+
f"SourceDocument with {sdoc_id=} is not an image!"
81+
)
8282
return sdoc
8383

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

backend/src/app/preprocessing/pipeline/preprocessing_pipeline.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ def __update_status_of_ppj(
143143
) -> PipelineCargo:
144144
ppj_id = cargo.ppj_payload.prepro_job_id
145145
update_dto = PreprocessingJobUpdate(status=status)
146-
logger.info(
147-
f"Updating PreprocessingJob {ppj_id} " f"Status to {status.value}..."
148-
)
146+
logger.info(f"Updating PreprocessingJob {ppj_id} Status to {status.value}...")
149147
with self.sqls.db_session() as db:
150148
_ = crud_prepro_job.update(db=db, uuid=ppj_id, update_dto=update_dto)
151149
return cargo

backend/src/app/preprocessing/pipeline/steps/image/create_pptd_from_description.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ def create_pptd_from_description(cargo: PipelineCargo) -> PipelineCargo:
1111
description = ppid.metadata["description"]
1212
if isinstance(description, list):
1313
description = " ".join(description)
14-
assert isinstance(
15-
description, str
16-
), f"The image description has to be string, but was {type(description)} instead"
14+
assert isinstance(description, str), (
15+
f"The image description has to be string, but was {type(description)} instead"
16+
)
1717
# we don't need to set the filepath and filename as they are not used for the text
1818
# tasks we apply on the image description.
1919
pptd = PreProTextDoc(

0 commit comments

Comments
 (0)