MCPcopy Create free account
hub / github.com/modelscope/modelscope / _local_oid

Method _local_oid

modelscope/utils/repo_utils.py:545–565  ·  view source on GitHub ↗

Return the OID of the local file. This OID is then compared to `self._remote_oid` to check if the file has changed compared to the remote one. If the file did not change, we won't upload it again to prevent empty commits. For LFS files, the OID corresponds to the SHA256 of

(self)

Source from the content-addressed store, hash-verified

543
544 @property
545 def _local_oid(self) -> Optional[str]:
546 """Return the OID of the local file.
547
548 This OID is then compared to `self._remote_oid` to check if the file has changed compared to the remote one.
549 If the file did not change, we won't upload it again to prevent empty commits.
550
551 For LFS files, the OID corresponds to the SHA256 of the file content (used a LFS ref).
552 For regular files, the OID corresponds to the SHA1 of the file content.
553 Note: this is slightly different to git OID computation since the oid of an LFS file is usually the git-SHA1
554 of the pointer file content (not the actual file content). However, using the SHA256 is enough to detect
555 changes and more convenient client-side.
556 """
557 if self._upload_mode is None:
558 return None
559 elif self._upload_mode == 'lfs':
560 return self.upload_info.sha256
561 else:
562 # Regular file => compute sha1
563 # => no need to read by chunk since the file is guaranteed to be <=5MB.
564 with self.as_file() as file:
565 return git_hash(file.read())
566
567
568def _validate_path_in_repo(path_in_repo: str) -> str:

Callers

nothing calls this directly

Calls 3

as_fileMethod · 0.95
git_hashFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected