Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _target_load(self, file_name: str) -> Any:
"""Select gokart load_function and load model.
Args:
file_name: Path to gokart's output file.
Returns:
Loaded data.
"""
file_path = self.client.to_absolute_path(file_name)
if file_path.endswith('.zip'):
tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.path.abspath(self.tmp_path))
zip_client = gokart.zip_client_util.make_zip_client(file_path, tmp_path)
zip_client.unpack_archive()
load_function_path = os.path.join(tmp_path, 'load_function.pkl')
load_function = gokart.target.make_target(load_function_path).load()
model = load_function(os.path.join(tmp_path, 'model.pkl'))
shutil.rmtree(tmp_path)
return model
return gokart.target.make_target(file_path=file_path).load()
def make_target(self, relative_file_path: str, use_unique_id: bool = True, processor: Optional[FileProcessor] = None) -> TargetOnKart:
file_path = os.path.join(self.workspace_directory, relative_file_path)
unique_id = self.make_unique_id() if use_unique_id else None
return gokart.target.make_target(file_path=file_path, unique_id=unique_id, processor=processor)
file_name: Path to gokart's output file.
Returns:
Loaded data.
"""
file_path = self.client.to_absolute_path(file_name)
if file_path.endswith('.zip'):
tmp_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.path.abspath(self.tmp_path))
zip_client = gokart.zip_client_util.make_zip_client(file_path, tmp_path)
zip_client.unpack_archive()
load_function_path = os.path.join(tmp_path, 'load_function.pkl')
load_function = gokart.target.make_target(load_function_path).load()
model = load_function(os.path.join(tmp_path, 'model.pkl'))
shutil.rmtree(tmp_path)
return model
return gokart.target.make_target(file_path=file_path).load()