diff --git a/.trunk/configs/.cspell.json b/.trunk/configs/.cspell.json index 0d8bee15a..feea89f80 100644 --- a/.trunk/configs/.cspell.json +++ b/.trunk/configs/.cspell.json @@ -99,6 +99,7 @@ "openmm", "equi", "Navid", - "ipykernel" + "ipykernel", + "levelname" ] } diff --git a/src/cript/api/api.py b/src/cript/api/api.py index caeef8c23..b83f7c6fd 100644 --- a/src/cript/api/api.py +++ b/src/cript/api/api.py @@ -1,5 +1,6 @@ import copy import json +import logging import os import uuid import warnings @@ -52,8 +53,28 @@ class API: """ ## Definition API Client class to communicate with the CRIPT API + + Attributes + ---------- + verbose : bool + A boolean flag that controls whether verbose logging is enabled or not. + + When `verbose` is set to `True`, the class will provide additional detailed logging + to the terminal. This can be useful for debugging and understanding the internal + workings of the class. + + When `verbose` is set to `False`, the class will only provide essential and concise + logging information, making the terminal output less cluttered and more user-friendly. + + ```python + # turn off the terminal logs + api.verbose = False + ``` """ + # dictates whether the user wants to see terminal log statements or not + verbose: bool = True + _host: str = "" _api_token: str = "" _storage_token: str = "" @@ -490,6 +511,12 @@ def _is_node_schema_valid(self, node_json: str, is_patch: bool = False) -> bool: else: raise CRIPTJsonNodeError(node_list, str(node_list)) + if self.verbose: + # logging out info to the terminal for the user feedback + # (improve UX because the program is currently slow) + logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.INFO) + logging.info(f"Validating {node_type} graph...") + # set the schema to test against http POST or PATCH of DB Schema schema_http_method: str