Skip to content

Commit

Permalink
#290 Fix reissue access token (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
Only-bottle authored Jul 15, 2024
1 parent 3a72773 commit dbffbe2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion netspresso/benchmarker/v2/benchmarker.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def benchmark_model(
if wait_until_done:
while True:
# Poll Benchmark Task status
self.token_handler.validate_token()
response = launcher_client_v2.benchmarker.read_task(
access_token=self.token_handler.tokens.access_token,
task_id=response.data.benchmark_task_id,
Expand All @@ -159,7 +160,6 @@ def benchmark_model(
TaskStatusForDisplay.TIMEOUT,
]:
break
self.token_handler.validate_token()
time.sleep(3)

if launcher_client_v2.is_cloud():
Expand Down
4 changes: 3 additions & 1 deletion netspresso/converter/v2/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def _download_converted_model(
e: If an error occurs while getting the conversion task information.
"""

self.token_handler.validate_token()

try:
if convert_task.status == TaskStatusForDisplay.ERROR:
raise FileNotFoundError(
Expand Down Expand Up @@ -166,6 +168,7 @@ def convert_model(
if wait_until_done:
while True:
# Poll Convert Task status
self.token_handler.validate_token()
response = launcher_client_v2.converter.read_task(
access_token=self.token_handler.tokens.access_token,
task_id=response.data.convert_task_id,
Expand All @@ -176,7 +179,6 @@ def convert_model(
TaskStatusForDisplay.TIMEOUT,
]:
break
self.token_handler.validate_token()
time.sleep(3)

self._download_converted_model(
Expand Down
6 changes: 3 additions & 3 deletions netspresso/metadata/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,17 @@ class ExceptionDetail:
@dataclass
class BaseMetadata:
status: Status = Status.IN_PROGRESS
message: ExceptionDetail = field(default_factory=ExceptionDetail)
error_detail: ExceptionDetail = field(default_factory=ExceptionDetail)

def asdict(self) -> Dict:
_dict = json.loads(json.dumps(asdict(self)))
return _dict

def update_message(self, exception_detail):
if isinstance(exception_detail, str):
self.message.message = exception_detail
self.error_detail.message = exception_detail
else:
self.message = ExceptionDetail(**exception_detail)
self.error_detail = ExceptionDetail(**exception_detail)

def update_status(self, status: Status):
self.status = status
1 change: 1 addition & 0 deletions netspresso/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ def _apply_img_size(self):
self.augmentation.inference = self._change_transforms(self.augmentation.inference)

def _get_available_options(self):
self.token_handler.validate_token()
options_response = launcher_client_v2.converter.read_framework_options(
access_token=self.token_handler.tokens.access_token,
framework=Framework.ONNX,
Expand Down
4 changes: 4 additions & 0 deletions netspresso/utils/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pathlib import Path
from typing import Tuple, Union
from urllib import request
from loguru import logger

FRAMEWORK_EXTENSION_MAP = {

Check failure on line 9 in netspresso/utils/file.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

netspresso/utils/file.py:1:1: I001 Import block is un-sorted or un-formatted
"tensorflow_keras": ".h5",
Expand Down Expand Up @@ -67,6 +68,7 @@ def create_folder(
"""
if is_folder_check and not FileHandler.check_exists(folder_path=folder_path):
Path(folder_path).mkdir(parents=parents, exist_ok=exist_ok)
logger.info(f"The folder has been created. Local Path: {Path(folder_path)}")
elif is_folder_check:
sys.exit(f"This folder already exists. Local Path: {Path(folder_path)}")

Expand All @@ -75,13 +77,15 @@ def create_unique_folder(folder_path: str) -> str:
folder_path = Path(folder_path)
if not folder_path.exists():
folder_path.mkdir(parents=True)
logger.info(f"The folder has been created. Local Path: {folder_path.as_posix()}")
else:
count = 1
while True:
new_folder_path = folder_path.with_name(f"{folder_path.name} ({count})")
if not new_folder_path.exists():
new_folder_path.mkdir(parents=True)
folder_path = new_folder_path
logger.info(f"The folder has been created. Local Path: {folder_path.as_posix()}")
break
count += 1

Expand Down

0 comments on commit dbffbe2

Please sign in to comment.