Skip to content

Commit

Permalink
refactor: run duty format
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanschild committed Dec 18, 2023
1 parent 03aa535 commit 920f067
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
22 changes: 13 additions & 9 deletions src/cognitivefactory/interactive_clustering_gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,11 @@ async def create_project(
# Return the ID of the created project.
return {
"project_id": current_project_id,
"detail": "The project with name '{project_name_str}' has been created. It has the id '{project_id_str}'.".format(
project_name_str=str(project_name),
project_id_str=str(current_project_id),
"detail": (
"The project with name '{project_name_str}' has been created. It has the id '{project_id_str}'.".format(
project_name_str=str(project_name),
project_id_str=str(current_project_id),
)
),
}

Expand Down Expand Up @@ -981,9 +983,11 @@ def clear_after_import_project(): # noqa: WPS430 (nested function)
# Return the new ID of the imported project.
return {
"project_id": metadata["project_id"],
"detail": "The project with name '{project_name_str}' has been imported. It has the id '{project_id_str}'.".format(
project_name_str=str(metadata["project_name"]),
project_id_str=str(metadata["project_id"]),
"detail": (
"The project with name '{project_name_str}' has been imported. It has the id '{project_id_str}'.".format(
project_name_str=str(metadata["project_name"]),
project_id_str=str(metadata["project_id"]),
)
),
}

Expand Down Expand Up @@ -2586,7 +2590,7 @@ async def get_html_constraint_annotation_page(
)["texts"],
"texts_html_escaped": { # TODO: Escape HTML for javascript
text_id: { # Force HTML escape.
key: (html.escape(value) if key in {"text_original", "text", "text_preprocessed"} else value)
key: html.escape(value) if key in {"text_original", "text", "text_preprocessed"} else value
for key, value in text_value.items()
}
for text_id, text_value in (
Expand Down Expand Up @@ -3026,8 +3030,8 @@ async def get_html_settings_page(
)["settings"],
# Get navigation information.
"navigation": {
"previous": (None if (iteration_id == 0) else iteration_id - 1),
"next": (None if (iteration_id == project_status["iteration_id"]) else (iteration_id + 1)),
"previous": None if (iteration_id == 0) else iteration_id - 1,
"next": None if (iteration_id == project_status["iteration_id"]) else (iteration_id + 1),
},
},
status_code=status.HTTP_200_OK,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ def run_modelization_update_task(
modelization: Dict[str, Any] = json.load(modelization_fileobject_r)

# Get constraints transitivity.
constraints_transitivity: Dict[
str, Dict[str, Dict[str, None]]
] = new_constraints_manager._constraints_transitivity # noqa: WPS437
constraints_transitivity: Dict[str, Dict[str, Dict[str, None]]] = (
new_constraints_manager._constraints_transitivity # noqa: WPS437
)

# Update modelization inference.
modelization = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ def to_dict(self) -> Dict[str, Any]:
"""
return {
"vectorizer_type": self.vectorizer_type.value,
"spacy_language_model": self.spacy_language_model.value
if (self.spacy_language_model is not None)
else None,
"spacy_language_model": (
self.spacy_language_model.value if (self.spacy_language_model is not None) else None
),
"random_seed": self.random_seed,
}

Expand All @@ -203,7 +203,7 @@ class Config: # noqa: WPS431 (nested class)

schema_extra = {
"example": {
"vectorizer_type": (VectorizerType.TFIDF + "|" + VectorizerType.SPACY),
"vectorizer_type": VectorizerType.TFIDF + "|" + VectorizerType.SPACY,
"random_seed": 42,
"!!!SPECIFIC: 'vectorizer_type'=='spacy'": {
"spacy_language_model": VectorizationSpacyLanguageModel.FR_CORE_NEWS_MD,
Expand Down

0 comments on commit 920f067

Please sign in to comment.