Skip to content

Commit

Permalink
#261 Save paths in metadata as absolute paths (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
Only-bottle authored Jul 1, 2024
1 parent 9d2688c commit b96e999
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion netspresso/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.0
1.7.1.b0
2 changes: 1 addition & 1 deletion netspresso/benchmarker/v2/benchmarker.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def benchmark_model(
folder_path = Path(input_model_path).parent

benchmarker_metadata = BenchmarkerMetadata()
benchmarker_metadata.input_model_path = input_model_path
benchmarker_metadata.input_model_path = Path(input_model_path).resolve().as_posix()
metadatas = []

file_path = folder_path / f"{file_name}.json"
Expand Down
2 changes: 1 addition & 1 deletion netspresso/compressor/v2/compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def initialize_metadata(self, input_model_path, metadata, framework, input_shape
)
metadata.update_is_retrainable(is_retrainable=True)

metadata.update_input_model_path(input_model_path=input_model_path)
metadata.update_input_model_path(input_model_path=Path(input_model_path).resolve().as_posix())
metadata.update_model_info(framework=framework, input_shapes=input_shapes)

return metadata
Expand Down
6 changes: 3 additions & 3 deletions netspresso/converter/v2/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ def convert_model(

self.token_handler.validate_token()

output_dir = FileHandler.create_unique_folder(folder_path=output_dir)
default_model_path, extension = FileHandler.get_path_and_extension(
folder_path=output_dir, framework=target_framework
)
output_dir = FileHandler.create_unique_folder(folder_path=output_dir)
converter_metadata = ConverterMetadata()
converter_metadata.input_model_path = input_model_path
converter_metadata.input_model_path = Path(input_model_path).resolve().as_posix()
MetadataHandler.save_json(data=asdict(converter_metadata), folder_path=output_dir)

try:
Expand Down Expand Up @@ -207,7 +207,7 @@ def convert_model(
converter_metadata.status = Status.ERROR
logger.info("Convert task failed with an error.")

converter_metadata.converted_model_path = str(default_model_path.with_suffix(extension))
converter_metadata.converted_model_path = default_model_path.with_suffix(extension).as_posix()
for available_option in available_options:
converter_metadata.available_options.append(available_option.to())

Expand Down
8 changes: 4 additions & 4 deletions netspresso/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def train(self, gpus: str, project_name: str, output_dir: Optional[str] = "./out
destination_folder = Path(output_dir) / project_name
destination_folder = FileHandler.create_unique_folder(folder_path=destination_folder)
metadata = TrainerMetadata()
metadata.update_logging_dir(logging_dir=destination_folder)
metadata.update_logging_dir(logging_dir=Path(destination_folder).resolve().as_posix())
metadata.update_model_info(
task=self.task,
model=self.model.name,
Expand Down Expand Up @@ -463,11 +463,11 @@ def train(self, gpus: str, project_name: str, output_dir: Optional[str] = "./out
available_options = self._get_available_options()

if best_fx_paths:
metadata.update_best_fx_model_path(best_fx_model_path=best_fx_paths[0].as_posix())
metadata.update_best_fx_model_path(best_fx_model_path=best_fx_paths[0].resolve().as_posix())
if best_onnx_paths:
metadata.update_best_onnx_model_path(best_onnx_model_path=best_onnx_paths[0].as_posix())
metadata.update_best_onnx_model_path(best_onnx_model_path=best_onnx_paths[0].resolve().as_posix())
metadata.update_training_result(training_summary=training_summary)
metadata.update_hparams(hparams=hparams_path.as_posix())
metadata.update_hparams(hparams=hparams_path.resolve().as_posix())
metadata.update_status(status=status)
metadata.update_available_options(available_options)

Expand Down
2 changes: 1 addition & 1 deletion netspresso/utils/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def get_path_and_extension(folder_path: str, framework: str) -> Tuple[Path, str]
Returns:
Tuple[Path, str]: A tuple containing the default model path (Path) and the file extension (str).
"""
default_model_path = Path(folder_path) / f"{Path(folder_path).name}.ext"
default_model_path = (Path(folder_path) / f"{Path(folder_path).name}.ext").resolve()
extension = FileHandler.get_extension_by_framework(framework=framework)

return default_model_path, extension
Expand Down

0 comments on commit b96e999

Please sign in to comment.