diff --git a/scripts/sparsezoo.py b/scripts/sparsezoo_script.py similarity index 100% rename from scripts/sparsezoo.py rename to scripts/sparsezoo_script.py diff --git a/src/sparsezoo/main.py b/src/sparsezoo/main.py index a4f9a814..8ac41992 100644 --- a/src/sparsezoo/main.py +++ b/src/sparsezoo/main.py @@ -179,7 +179,6 @@ DOWNLOAD_COMMAND = "download" SEARCH_COMMAND = "search" -logging.basicConfig(level=logging.INFO) LOGGER = logging.getLogger() @@ -330,13 +329,7 @@ def _get_command_from_model(model: Model): if hasattr(model, field) and getattr(model, field) is not None ] - command_string = download_command + " ".join( - # [ - # " \\ \n ".join(command_strings[i : i + 2]) - # for i in range(0, len(command_strings), 2) - # ] - command_strings - ) + command_string = download_command + " ".join(command_strings) return command_string diff --git a/src/sparsezoo/models/zoo.py b/src/sparsezoo/models/zoo.py index 6006ad92..6835d74c 100644 --- a/src/sparsezoo/models/zoo.py +++ b/src/sparsezoo/models/zoo.py @@ -68,7 +68,7 @@ def parse_zoo_stub( if valid_params is not None and any(param not in valid_params for param in params): warnings.warn( - f"Invalid query string for stub {stub} valid params include {valid_params}, " + f"Invalid query string for stub {stub} valid params include {valid_params}," f" given {list(params.keys())}" ) diff --git a/src/sparsezoo/requests/authentication.py b/src/sparsezoo/requests/authentication.py index 9b56a8c8..60d83db1 100644 --- a/src/sparsezoo/requests/authentication.py +++ b/src/sparsezoo/requests/authentication.py @@ -54,7 +54,7 @@ class SparseZooCredentials: def __init__(self): if os.path.exists(CREDENTIALS_YAML): - _LOGGER.info(f"Loading sparse zoo credentials from {CREDENTIALS_YAML}") + _LOGGER.debug(f"Loading sparse zoo credentials from {CREDENTIALS_YAML}") with open(CREDENTIALS_YAML) as credentials_file: credentials_yaml = yaml.safe_load(credentials_file) if credentials_yaml and CREDENTIALS_YAML_TOKEN_KEY in credentials_yaml: @@ -66,7 +66,9 @@ def __init__(self): self._token = None self._created = None else: - _LOGGER.info(f"No sparse zoo credentials files found at {CREDENTIALS_YAML}") + _LOGGER.debug( + f"No sparse zoo credentials files found at {CREDENTIALS_YAML}" + ) self._token = None self._created = None @@ -78,7 +80,7 @@ def save_token(self, token: str, created: float): :param token: the jwt for accessing sparse zoo APIs :param created: the approximate time the token was created """ - _LOGGER.info(f"Saving sparse zoo credentials at {CREDENTIALS_YAML}") + _LOGGER.debug(f"Saving sparse zoo credentials at {CREDENTIALS_YAML}") if not os.path.exists(CREDENTIALS_YAML): create_parent_dirs(CREDENTIALS_YAML) with open(CREDENTIALS_YAML, "w+") as credentials_file: @@ -99,17 +101,17 @@ def token(self): """ :return: obtain the token if under 1 day old, else return None """ - _LOGGER.info(f"Obtaining sparse zoo credentials from {CREDENTIALS_YAML}") + _LOGGER.debug(f"Obtaining sparse zoo credentials from {CREDENTIALS_YAML}") if self._token and self._created is not None: creation_date = datetime.fromtimestamp(self._created, tz=timezone.utc) creation_difference = datetime.now(tz=timezone.utc) - creation_date - if creation_difference.days == 0: + if creation_difference.days < 30: return self._token else: - _LOGGER.warning(f"Expired sparse zoo credentials at {CREDENTIALS_YAML}") + _LOGGER.debug(f"Expired sparse zoo credentials at {CREDENTIALS_YAML}") return None else: - _LOGGER.warning(f"No sparse zoo credentials found at {CREDENTIALS_YAML}") + _LOGGER.debug(f"No sparse zoo credentials found at {CREDENTIALS_YAML}") return None @@ -138,7 +140,7 @@ def get_auth_header( if token and not force_token_refresh: return {NM_TOKEN_HEADER: token} elif authentication_type.lower() == PUBLIC_AUTH_TYPE: - _LOGGER.warning("Obtaining new sparse zoo credentials token") + _LOGGER.info("Obtaining new sparse zoo credentials token") created = time.time() response = requests.post( url=AUTH_API, data=json.dumps({"authentication_type": PUBLIC_AUTH_TYPE}) diff --git a/src/sparsezoo/requests/search.py b/src/sparsezoo/requests/search.py index 084f5444..83c22f46 100644 --- a/src/sparsezoo/requests/search.py +++ b/src/sparsezoo/requests/search.py @@ -64,7 +64,7 @@ def search_get_request( search_args = "&".join(search_args) url = f"{BASE_API_URL}/{SEARCH_PATH}/{args.model_url_root}?{search_args}" - _LOGGER.debug(f"Searching objects from {url}") + _LOGGER.info(f"Searching objects from {url}") response_json = requests.get(url=url, headers=header).json() return response_json