Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a1e9402

Browse files
committedJan 13, 2025·
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 1de0e11 commit a1e9402

23 files changed

+56
-68
lines changed
 

‎backend/src/api/endpoints/project.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def upload_project_sdoc(
141141
uploaded_files: List[UploadFile] = File(
142142
...,
143143
description=(
144-
"File(s) that get uploaded and " "represented by the SourceDocument(s)"
144+
"File(s) that get uploaded and represented by the SourceDocument(s)"
145145
),
146146
),
147147
authz_user: AuthzUser = Depends(),

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ def execute_text_preprocessing_pipeline_apply_async(
103103
execute_text_preprocessing_pipeline_task,
104104
)
105105

106-
assert isinstance(
107-
execute_text_preprocessing_pipeline_task, Task
108-
), "Not a Celery Task"
106+
assert isinstance(execute_text_preprocessing_pipeline_task, Task), (
107+
"Not a Celery Task"
108+
)
109109

110110
for cargo in cargos:
111111
execute_text_preprocessing_pipeline_task.apply_async(kwargs={"cargo": cargo})
@@ -118,9 +118,9 @@ def execute_image_preprocessing_pipeline_apply_async(
118118
execute_image_preprocessing_pipeline_task,
119119
)
120120

121-
assert isinstance(
122-
execute_image_preprocessing_pipeline_task, Task
123-
), "Not a Celery Task"
121+
assert isinstance(execute_image_preprocessing_pipeline_task, Task), (
122+
"Not a Celery Task"
123+
)
124124

125125
for cargo in cargos:
126126
execute_image_preprocessing_pipeline_task.apply_async(kwargs={"cargo": cargo})
@@ -133,9 +133,9 @@ def execute_audio_preprocessing_pipeline_apply_async(
133133
execute_audio_preprocessing_pipeline_task,
134134
)
135135

136-
assert isinstance(
137-
execute_audio_preprocessing_pipeline_task, Task
138-
), "Not a Celery Task"
136+
assert isinstance(execute_audio_preprocessing_pipeline_task, Task), (
137+
"Not a Celery Task"
138+
)
139139

140140
for cargo in cargos:
141141
execute_audio_preprocessing_pipeline_task.apply_async(kwargs={"cargo": cargo})
@@ -148,9 +148,9 @@ def execute_video_preprocessing_pipeline_apply_async(
148148
execute_video_preprocessing_pipeline_task,
149149
)
150150

151-
assert isinstance(
152-
execute_video_preprocessing_pipeline_task, Task
153-
), "Not a Celery Task"
151+
assert isinstance(execute_video_preprocessing_pipeline_task, Task), (
152+
"Not a Celery Task"
153+
)
154154

155155
for cargo in cargos:
156156
execute_video_preprocessing_pipeline_task.apply_async(kwargs={"cargo": cargo})

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

+2-3
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

+3-3
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

+1-1
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/llm/ollama_service.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ def __new__(cls, *args, **kwargs):
2525
ollamac.pull(model)
2626
print(f"Model {model} has been pulled successfully.")
2727
available_models = [x["name"] for x in ollamac.list()["models"]]
28-
assert (
29-
model in available_models
30-
), f"Model {model} is not available. Available models are: {available_models}"
28+
assert model in available_models, (
29+
f"Model {model} is not available. Available models are: {available_models}"
30+
)
3131

3232
cls.__model = model
3333
cls.__client = ollamac

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def _encode_text(self, text: List[str], return_avg_emb: bool = False) -> np.ndar
7171
def _get_image_path_from_sdoc_id(self, sdoc_id: int) -> Path:
7272
with self.sqls.db_session() as db:
7373
sdoc = SourceDocumentRead.model_validate(crud_sdoc.read(db=db, id=sdoc_id))
74-
assert (
75-
sdoc.doctype == DocType.image
76-
), f"SourceDocument with {sdoc_id=} is not an image!"
74+
assert sdoc.doctype == DocType.image, (
75+
f"SourceDocument with {sdoc_id=} is not an image!"
76+
)
7777
return self.repo.get_path_to_sdoc_file(sdoc=sdoc, raise_if_not_exists=True)
7878

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

‎backend/src/app/core/db/weaviate_service.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def run_batch(batch):
505505
)
506506
result = query.do()["data"]["Get"][self._sentence_class_name]
507507
result_dict = {
508-
f'{r["sdoc_id"]}-{r["sentence_id"]}': r["_additional"]["vector"]
508+
f"{r['sdoc_id']}-{r['sentence_id']}": r["_additional"]["vector"]
509509
for r in result
510510
}
511511
sorted_res = []

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

+1-3
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/audio/write_ppad_to_database.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ def write_ppad_to_database(cargo: PipelineCargo) -> PipelineCargo:
124124
db.rollback()
125125
raise e
126126
else:
127-
logger.info(
128-
f"Persisted PreprocessingPipeline Results " f"for {ppad.filename}!"
129-
)
127+
logger.info(f"Persisted PreprocessingPipeline Results for {ppad.filename}!")
130128

131129
cargo.data["sdoc_id"] = sdoc_db_obj.id
132130
return cargo

‎backend/src/app/preprocessing/pipeline/steps/image/store_metadata_to_database.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@ def store_metadata_to_database(cargo: PipelineCargo) -> PipelineCargo:
8585
db.rollback()
8686
raise e
8787
else:
88-
logger.info(f"Persisted SourceDocument Metadata " f"for {ppid.filename}!")
88+
logger.info(f"Persisted SourceDocument Metadata for {ppid.filename}!")
8989

9090
return cargo

‎backend/src/app/preprocessing/pipeline/steps/image/write_ppid_to_database.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ def write_ppid_to_database(cargo: PipelineCargo) -> PipelineCargo:
121121
db.rollback()
122122
raise e
123123
else:
124-
logger.info(
125-
f"Persisted PreprocessingPipeline Results " f"for {ppid.filename}!"
126-
)
124+
logger.info(f"Persisted PreprocessingPipeline Results for {ppid.filename}!")
127125

128126
cargo.data["sdoc_id"] = sdoc_db_obj.id
129127
return cargo

‎backend/src/app/preprocessing/pipeline/steps/text/write_pptd_to_database.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,7 @@ def write_pptd_to_database(cargo: PipelineCargo) -> PipelineCargo:
233233
db.rollback()
234234
raise e
235235
else:
236-
logger.info(
237-
f"Persisted PreprocessingPipeline Results " f"for {pptd.filename}!"
238-
)
236+
logger.info(f"Persisted PreprocessingPipeline Results for {pptd.filename}!")
239237

240238
cargo.data["sdoc_id"] = sdoc_db_obj.id
241239

‎backend/src/app/preprocessing/pipeline/steps/video/write_ppvd_to_database.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ def write_ppvd_to_database(cargo: PipelineCargo) -> PipelineCargo:
119119
db.rollback()
120120
raise e
121121
else:
122-
logger.info(
123-
f"Persisted PreprocessingPipeline Results " f"for {ppvd.filename}!"
124-
)
122+
logger.info(f"Persisted PreprocessingPipeline Results for {ppvd.filename}!")
125123

126124
cargo.data["sdoc_id"] = sdoc_db_obj.id
127125
return cargo

‎backend/src/app/preprocessing/preprocessing_service.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ def abort_preprocessing_job(self, ppj_id: str) -> PreprocessingJobRead:
206206
if ppj.status != BackgroundJobStatus.RUNNING:
207207
raise HTTPException(
208208
detail=(
209-
f"Cannot abort PreprocessingJob {ppj_id} "
210-
"because it is not running!"
209+
f"Cannot abort PreprocessingJob {ppj_id} because it is not running!"
211210
),
212211
status_code=400,
213212
)

‎backend/src/app/preprocessing/ray_model_service.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
class RayModelService(metaclass=SingletonMeta):
3131
def __new__(cls, *args, **kwargs):
32-
cls.base_url = f"{conf.ray.protocol}://" f"{conf.ray.host}:" f"{conf.ray.port}"
32+
cls.base_url = f"{conf.ray.protocol}://{conf.ray.host}:{conf.ray.port}"
3333
logger.info(f"RayModelService base_url: {cls.base_url}")
3434

3535
try:

‎backend/src/app/preprocessing/ray_model_worker/models/blip2.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def __init__(self):
5757
device_map=device_map,
5858
torch_dtype=data_type,
5959
)
60-
assert isinstance(
61-
captioning_model, Blip2ForConditionalGeneration
62-
), "Failed to load captioning model"
60+
assert isinstance(captioning_model, Blip2ForConditionalGeneration), (
61+
"Failed to load captioning model"
62+
)
6363

6464
captioning_model.eval()
6565
self.data_type = data_type

‎backend/src/app/preprocessing/ray_model_worker/models/detr.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ class DETRModel:
2323
def __init__(self):
2424
logger.debug(f"Loading DetrFeatureExtractor {MODEL} ...")
2525
feature_extractor = DetrFeatureExtractor.from_pretrained(MODEL, device=DEVICE)
26-
assert isinstance(
27-
feature_extractor, DetrFeatureExtractor
28-
), "Failed to load feature extractor"
26+
assert isinstance(feature_extractor, DetrFeatureExtractor), (
27+
"Failed to load feature extractor"
28+
)
2929

3030
logger.debug(f"Loading DetrForObjectDetection {MODEL} ...")
3131
object_detection_model = DetrForObjectDetection.from_pretrained(MODEL)
32-
assert isinstance(
33-
object_detection_model, DetrForObjectDetection
34-
), "Failed to load object detection model"
32+
assert isinstance(object_detection_model, DetrForObjectDetection), (
33+
"Failed to load object detection model"
34+
)
3535

3636
object_detection_model.to(DEVICE)
3737
object_detection_model.eval()

‎backend/src/main.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,9 @@ def invalid_error_handler(_, exc: InvalidError):
272272
def main() -> None:
273273
# read port from config
274274
port = int(conf.api.port)
275-
assert (
276-
port is not None and isinstance(port, int) and port > 0
277-
), "The API port has to be a positive integer! E.g. 8081"
275+
assert port is not None and isinstance(port, int) and port > 0, (
276+
"The API port has to be a positive integer! E.g. 8081"
277+
)
278278

279279
is_debug = conf.api.production_mode == "0"
280280

‎backend/src/test/api/endpoints/test_authentication.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def test_authentication_required():
4141
and dep.dependency.__qualname__ == "get_current_user"
4242
]
4343

44-
assert (
45-
len(auth_dep) == 1
46-
), f"route {route.methods} {route.path} is not protected by authentication"
44+
assert len(auth_dep) == 1, (
45+
f"route {route.methods} {route.path} is not protected by authentication"
46+
)
4747
elif isinstance(route, starlette.routing.Route):
4848
# These routes are usually built into FastAPI, and
4949
# we expect them to not require authentication.

‎backend/src/test/app/core/data/crud/test_project_crud.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_project_users(db: Session, project: ProjectORM, user: UserORM) -> None:
139139
assert len(project_users) == 2
140140

141141
# create third user
142-
email = f'{"".join(random.choices(string.ascii_letters, k=15))}@gmail.com'
142+
email = f"{''.join(random.choices(string.ascii_letters, k=15))}@gmail.com"
143143
first_name = "".join(random.choices(string.ascii_letters, k=15))
144144
last_name = "".join(random.choices(string.ascii_letters, k=15))
145145
password = "".join(random.choices(string.ascii_letters, k=15))

‎backend/src/test/app/core/data/crud/test_user_crud.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
def test_create_delete_user(db: Session) -> None:
16-
email = f'{"".join(random.choices(string.ascii_letters, k=15))}@gmail.com'
16+
email = f"{''.join(random.choices(string.ascii_letters, k=15))}@gmail.com"
1717
first_name = "".join(random.choices(string.ascii_letters, k=15))
1818
last_name = "".join(random.choices(string.ascii_letters, k=15))
1919
password = "".join(random.choices(string.ascii_letters, k=15))
@@ -44,7 +44,7 @@ def test_create_delete_user(db: Session) -> None:
4444

4545

4646
def test_update_user(db: Session, user: UserORM) -> None:
47-
email = f'{"".join(random.choices(string.ascii_letters, k=15))}@gmail.com'
47+
email = f"{''.join(random.choices(string.ascii_letters, k=15))}@gmail.com"
4848
first_name = "".join(random.choices(string.ascii_letters, k=15))
4949
last_name = "".join(random.choices(string.ascii_letters, k=15))
5050
password = "".join(random.choices(string.ascii_letters, k=15))

‎backend/src/test/conftest.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def user(make_user: Callable[[], UserORM]) -> UserORM:
149149
@pytest.fixture
150150
def make_user(db: Session, request: FixtureRequest) -> Callable[[], UserORM]:
151151
def factory():
152-
email = f'{"".join(random.choices(string.ascii_letters, k=15))}@gmail.com'
152+
email = f"{''.join(random.choices(string.ascii_letters, k=15))}@gmail.com"
153153
first_name = "".join(random.choices(string.ascii_letters, k=15))
154154
last_name = "".join(random.choices(string.ascii_letters, k=15))
155155
password = "".join(random.choices(string.ascii_letters, k=15))
@@ -317,9 +317,9 @@ def create(self, upload_list: list, user: dict, project: dict):
317317
response = client.put(
318318
f"/project/{project['id']}/sdoc", headers=user_headers, files=files
319319
)
320-
assert (
321-
response.status_code == 200
322-
), f"Failed to upload files. Response: {response}. Files: {files}"
320+
assert response.status_code == 200, (
321+
f"Failed to upload files. Response: {response}. Files: {files}"
322+
)
323323
response = response.json()
324324
docs = {}
325325
for file in response["payloads"]:

0 commit comments

Comments
 (0)
Please sign in to comment.