Skip to content

Commit 55fc611

Browse files
committed
Merge branch 'incubate/paddlenlp-fleety' of https://github.com/PaddlePaddle/PaddleNLP into support_flash_device_on_static_model
2 parents 0b2aff9 + 64c9207 commit 55fc611

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

paddlenlp/utils/pdc_sdk.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class PDCErrorCode(Enum):
4747
CalculateHashFail = 1502
4848
InvalidArgument = 1503
4949
CommandTimeout = 1504
50+
CheckSumCommandFail = 1505
5051

5152
UnknownError = 1999
5253

@@ -490,6 +491,48 @@ def _download_file(self, remote_path: str, local_path: str) -> PDCErrorCode:
490491
raise Exception(f"exec cmd {download_cmd_args} with error: {e}")
491492
return error_code
492493

494+
def pdc_fc_generate_checksum(self, path: str) -> PDCErrorCode:
495+
"""
496+
Args
497+
:param localPath:
498+
:return:
499+
"""
500+
if not os.path.exists(path):
501+
logger.error(f"pdc_fc_generate_checksum gi{path} not exist")
502+
return PDCErrorCode.CommandFail
503+
generate_checksum_args = [self._pdc_agent_bin, "-mode", "command", "-type", "generateSum", "-path", f"{path}"]
504+
error_code = PDCErrorCode.Success
505+
try:
506+
logger.info(f"begin to generate_sum path: {path}")
507+
res, error_code = self._exec_cmd(generate_checksum_args)
508+
if error_code == PDCErrorCode.Success:
509+
logger.info(f"generate_sum {path} successfully")
510+
except Exception as e:
511+
logger.error(f"exec cmd {generate_checksum_args} with error: {e}")
512+
return PDCErrorCode.CheckSumCommandFail
513+
return error_code
514+
515+
def pdc_fc_do_check(self, path: str) -> PDCErrorCode:
516+
"""
517+
Args
518+
:param localPath:
519+
:return:
520+
"""
521+
if not os.path.exists(path):
522+
logger.error(f"pdc_fc_do_check {path} not exist")
523+
return PDCErrorCode.CommandFail
524+
generate_checksum_args = [self._pdc_agent_bin, "-mode", "command", "-type", "checkSum", "-path", f"{path}"]
525+
error_code = PDCErrorCode.Success
526+
try:
527+
logger.info(f"begin to check_sum path: {path}")
528+
res, error_code = self._exec_cmd(generate_checksum_args)
529+
if error_code == PDCErrorCode.Success:
530+
logger.info(f"check_sum {path} successfully")
531+
except Exception as e:
532+
logger.error(f"exec cmd {generate_checksum_args} with error: {e}")
533+
return PDCErrorCode.CheckSumCommandFail
534+
return error_code
535+
493536
def _clean_tmp_files(self, tmp_files: List[str]):
494537
"""clean tmp files
495538

0 commit comments

Comments
 (0)