Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
9 changes: 1 addition & 8 deletions src/sparsezoo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@
DOWNLOAD_COMMAND = "download"
SEARCH_COMMAND = "search"

logging.basicConfig(level=logging.INFO)
LOGGER = logging.getLogger()


Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion src/sparsezoo/models/zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())}"
)

Expand Down
18 changes: 10 additions & 8 deletions src/sparsezoo/requests/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -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:
Expand All @@ -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


Expand Down Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion src/sparsezoo/requests/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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