Skip to content

Commit

Permalink
chore(project create): add erroneously removed exc_info in logging (D…
Browse files Browse the repository at this point in the history
  • Loading branch information
Nora-Olivia-Ammann committed Mar 11, 2024
1 parent 5ed62fc commit 19d1f25
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions src/dsp_tools/commands/project/create/project_create.py
Expand Up @@ -119,7 +119,7 @@ def _create_groups(
"not possible to retrieve the remote groups from the DSP server."
)
print(f"WARNING: {err_msg}")
logger.warning(err_msg)
logger.warning(err_msg, exc_info=True)
remote_groups = []
overall_success = False

Expand All @@ -129,8 +129,9 @@ def _create_groups(
# if the group already exists, add it to "current_project_groups" (for later usage), then skip it
if remotely_existing_group := [g for g in remote_groups if g.name == group_name]:
current_project_groups[group_name] = remotely_existing_group[0]
print(f" WARNING: Group name '{group_name}' already exists on the DSP server. Skipping...")
logger.warning(f"Group name '{group_name}' already exists on the DSP server. Skipping...")
err_msg = f"Group name '{group_name}' already exists on the DSP server. Skipping..."
print(f" WARNING: {err_msg}")
logger.warning(err_msg, exc_info=True)
overall_success = False
continue

Expand All @@ -146,8 +147,9 @@ def _create_groups(
try:
group_remote: Group = group_local.create()
except BaseError:
print(f" WARNING: Unable to create group '{group_name}'.")
logger.warning(f"Unable to create group '{group_name}'.")
err_msg = "Unable to create group '{group_name}'."
print(f" WARNING: {err_msg}")
logger.warning(err_msg, exc_info=True)
overall_success = False
continue

Expand Down Expand Up @@ -196,7 +198,7 @@ def _get_group_iris_for_user(
)
if ":" not in full_group_name and full_group_name != "SystemAdmin":
print(f" WARNING: {inexisting_group_msg}")
logger.warning(inexisting_group_msg)
logger.warning(inexisting_group_msg, exc_info=True)
success = False
continue

Expand All @@ -213,7 +215,7 @@ def _get_group_iris_for_user(
# full_group_name refers to a group inside the same project
if group_name not in current_project_groups:
print(f" WARNING: {inexisting_group_msg}")
logger.warning(inexisting_group_msg)
logger.warning(inexisting_group_msg, exc_info=True)
success = False
continue
group = current_project_groups[group_name]
Expand All @@ -228,13 +230,13 @@ def _get_group_iris_for_user(
f"exists on the DSP server, but no groups could be retrieved from the DSP server."
)
print(f" WARNING: {err_msg}")
logger.warning(err_msg)
logger.warning(err_msg, exc_info=True)
success = False
continue
existing_group = [g for g in remote_groups if g.project == current_project.iri and g.name == group_name]
if not existing_group:
print(f" WARNING: {inexisting_group_msg}")
logger.warning(inexisting_group_msg)
logger.warning(inexisting_group_msg, exc_info=True)
success = False
continue
group = existing_group[0]
Expand Down Expand Up @@ -274,10 +276,9 @@ def _get_projects_where_user_is_admin(
for full_project_name in json_user_definition.get("projects", []):
# full_project_name has the form '[project_name]:member' or '[project_name]:admin'
if ":" not in full_project_name:
print(
f" WARNING: Provided project '{full_project_name}' for user '{username}' is not valid. Skipping..."
)
logger.warning(f"Provided project '{full_project_name}' for user '{username}' is not valid. Skipping...")
err_msg = "Provided project '{full_project_name}' for user '{username}' is not valid. Skipping..."
print(f" WARNING: {err_msg}")
logger.warning(err_msg, exc_info=True)
success = False
continue

Expand All @@ -296,14 +297,14 @@ def _get_projects_where_user_is_admin(
f"because the projects cannot be retrieved from the DSP server."
)
print(f" WARNING: {err_msg}")
logger.warning(err_msg)
logger.warning(err_msg, exc_info=True)
success = False
continue
in_project_list = [p for p in remote_projects if p.shortname == project_name]
if not in_project_list:
msg = f"Provided project '{full_project_name}' for user '{username}' is not valid. Skipping..."
print(f" WARNING: {msg}")
logger.warning(msg)
logger.warning(msg, exc_info=True)
success = False
continue
in_project = in_project_list[0]
Expand Down Expand Up @@ -346,8 +347,9 @@ def _create_users(
# skip the user if he already exists
all_users = User.getAllUsers(con)
if json_user_definition["email"] in [user.email for user in all_users]:
print(f" WARNING: User '{username}' already exists on the DSP server. Skipping...")
logger.warning(f"User '{username}' already exists on the DSP server. Skipping...")
err_msg = f"User '{username}' already exists on the DSP server. Skipping..."
print(f" WARNING: {err_msg}")
logger.warning(err_msg, exc_info=True)
overall_success = False
continue
# add user to the group(s)
Expand Down Expand Up @@ -389,7 +391,7 @@ def _create_users(
user_local.create()
except BaseError:
print(f" WARNING: Unable to create user '{username}'.")
logger.warning(f"Unable to create user '{username}'.")
logger.warning(f"Unable to create user '{username}'.", exc_info=True)
overall_success = False
continue
print(f" Created user '{username}'.")
Expand Down Expand Up @@ -502,8 +504,9 @@ def _create_ontology(
"""
# skip if it already exists on the DSP server
if onto_name in [onto.name for onto in project_ontologies]:
print(f" WARNING: Ontology '{onto_name}' already exists on the DSP server. Skipping...")
logger.warning(f"Ontology '{onto_name}' already exists on the DSP server. Skipping...")
err_msg = f"Ontology '{onto_name}' already exists on the DSP server. Skipping..."
print(f" WARNING: {err_msg}")
logger.warning(err_msg, exc_info=True)
return None

print(f"Create ontology '{onto_name}'...")
Expand Down Expand Up @@ -580,7 +583,7 @@ def _create_ontologies(
except BaseError:
err_msg = "Unable to retrieve remote ontologies. Cannot check if your ontology already exists."
print("WARNING: {err_msg}")
logger.warning(err_msg)
logger.warning(err_msg, exc_info=True)
project_ontologies = []

for ontology_definition in ontology_definitions:
Expand Down Expand Up @@ -693,8 +696,9 @@ def _add_resource_classes_to_remote_ontology(
print(f" Created resource class '{res_class['name']}'")
logger.info(f"Created resource class '{res_class['name']}'")
except BaseError:
print(f"WARNING: Unable to create resource class '{res_class['name']}'.")
logger.warning(f"Unable to create resource class '{res_class['name']}'.")
err_msg = f"Unable to create resource class '{res_class['name']}'."
print(f"WARNING: {err_msg}")
logger.warning(err_msg, exc_info=True)
overall_success = False

return last_modification_date, new_res_classes, overall_success
Expand Down Expand Up @@ -788,8 +792,9 @@ def _add_property_classes_to_remote_ontology(
print(f" Created property class '{prop_class['name']}'")
logger.info(f"Created property class '{prop_class['name']}'")
except BaseError:
print(f"WARNING: Unable to create property class '{prop_class['name']}'.")
logger.warning(f"Unable to create property class '{prop_class['name']}'.")
err_msg = f"Unable to create property class '{prop_class['name']}'."
print(f"WARNING: {err_msg}")
logger.warning(f"Unable to create property class '{prop_class['name']}'.", exc_info=True)
overall_success = False

return last_modification_date, overall_success
Expand Down Expand Up @@ -837,7 +842,7 @@ def _add_cardinalities_to_resource_classes(
f"This class doesn't exist on the DSP server."
)
print(f"WARNINIG: {msg}")
logger.warning(msg)
logger.warning(msg, exc_info=True)
overall_success = False
continue
for card_info in res_class.get("cardinalities", []):
Expand All @@ -860,7 +865,7 @@ def _add_cardinalities_to_resource_classes(
except BaseError:
err_msg = f"Unable to add cardinality '{qualified_propname}' to resource class {res_class['name']}."
print(f"WARNING: {err_msg}")
logger.warning(err_msg)
logger.warning(err_msg, exc_info=True)
overall_success = False

ontology_remote.lastModificationDate = last_modification_date
Expand Down Expand Up @@ -913,7 +918,7 @@ def _rectify_hlist_of_properties(
f"which is not a valid list name. "
f"Assuming that you meant '{deduced_list_name}' instead."
)
logger.warning(msg)
logger.warning(msg, exc_info=True)
print(msg)
else:
msg = f"Property '{prop['name']}' references an unknown list: '{prop['gui_attributes']['hlist']}'"
Expand Down Expand Up @@ -1057,7 +1062,7 @@ def create_project(
f"but during the creation process, some problems occurred. Please carefully check the console output."
)
print(f"========================================================\nWARNING: {msg}")
logger.warning(msg)
logger.warning(msg, exc_info=True)

return overall_success

Expand Down

0 comments on commit 19d1f25

Please sign in to comment.