aipmodel 0.2.69__tar.gz → 0.2.70__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aipmodel
3
- Version: 0.2.69
3
+ Version: 0.2.70
4
4
  Summary: SDK for model registration, versioning, and storage
5
5
  Home-page: https://github.com/AIP-MLOPS/model-registry
6
6
  Author: AIP MLOPS Team
@@ -11,5 +11,5 @@ if _os.environ.get("AIPMODEL_UPDATE_CHECK", "").lower() in ("1", "true", "yes"):
11
11
 
12
12
  __all__ = ["MLOpsManager", "CephS3Manager"]
13
13
 
14
- __version__ = "0.2.69"
14
+ __version__ = "0.2.70"
15
15
  __description__ = "SDK for model registration, versioning, and storage"
@@ -1772,6 +1772,70 @@ class MLOpsManager:
1772
1772
  pass
1773
1773
  return None
1774
1774
 
1775
+ def remove_missing_version(self, model_name, version):
1776
+ """
1777
+ Sync-repair for a ZOMBIE version: the registry references `version` but
1778
+ its S3 files are gone (e.g. deleted by hand in Ceph). Removes the version
1779
+ from the registry so registry and storage agree again. Refuses to run if
1780
+ the files actually still exist (use delete_model for a real delete).
1781
+ """
1782
+ report = self.verify_model_integrity(model_name=model_name)
1783
+ entry = next((v for v in report["versions"] if v["version"] == version), None)
1784
+ if entry is None:
1785
+ raise ModelNotFoundError(f"Version '{version}' not found for model '{model_name}'")
1786
+ if entry["files_exist"]:
1787
+ raise ValueError(
1788
+ f"Files for version '{version}' of '{model_name}' still exist in storage — "
1789
+ f"this is not a zombie. Use delete_model to actually delete it."
1790
+ )
1791
+ # delete_model is metadata-first and its S3 delete is a no-op for an
1792
+ # already-empty prefix, so it is exactly the sync we need.
1793
+ self.delete_model(model_name=model_name, version=version)
1794
+ print(f"[SDK_SUCCESS] Synced: removed zombie version '{version}' of '{model_name}' from registry.")
1795
+
1796
+ def purge_orphan_folders(self, model_name=None, model_id=None):
1797
+ """
1798
+ Sync-repair for ORPHAN folders inside a registered model: S3 folders
1799
+ under the model that no registry version references (leftovers from an
1800
+ interrupted operation). Deletes those folders. Returns the list purged.
1801
+ """
1802
+ report = self.verify_model_integrity(model_name=model_name, model_id=model_id)
1803
+ mid = report["model_id"]
1804
+ data = self.models.get_by_id(mid)
1805
+ is_public = self._extract_metadata_value(data.get("metadata", {}), "public", "false").lower() == "true"
1806
+ mgr = self._get_ceph_manager(is_public)
1807
+ purged = []
1808
+ for folder in report["orphan_folders"]:
1809
+ prefix = f"_models/{mid}/{folder}/"
1810
+ try:
1811
+ mgr.delete_folder(prefix)
1812
+ purged.append(folder)
1813
+ except Exception as e:
1814
+ print(f"[SDK_WARN] Could not purge orphan folder {prefix}: {e}")
1815
+ print(f"[SDK_SUCCESS] Purged {len(purged)} orphan folder(s) for model '{report['model_name']}'.")
1816
+ return purged
1817
+
1818
+ def purge_orphan_model(self, model_id):
1819
+ """
1820
+ Sync-repair for an ORPHAN model: an S3 model folder the registry does
1821
+ not know about (e.g. the registry entry was deleted while storage
1822
+ survived). Deletes the whole `_models/{model_id}/` folder. Refuses to
1823
+ run if the id IS known to the registry (that would be a real delete —
1824
+ use delete_model).
1825
+ """
1826
+ registry_ids = {m.get("id") for m in (self.models.get_all(self.project_id) or [])}
1827
+ if model_id in registry_ids:
1828
+ raise ValueError(
1829
+ f"Model id '{model_id}' exists in the registry — not an orphan. "
1830
+ f"Use delete_model to delete a registered model."
1831
+ )
1832
+ mgr = self._get_ceph_manager(False)
1833
+ base = f"_models/{model_id}/"
1834
+ if not mgr.check_if_exists(base):
1835
+ raise ModelNotFoundError(f"No storage folder found at {base}")
1836
+ mgr.delete_folder(base)
1837
+ print(f"[SDK_SUCCESS] Purged orphan storage folder {base}.")
1838
+
1775
1839
  def recover_model_from_storage(self, model_id):
1776
1840
  """
1777
1841
  Rebuild a registry (Mlops-Core) entry for a model that exists in S3 but
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aipmodel
3
- Version: 0.2.69
3
+ Version: 0.2.70
4
4
  Summary: SDK for model registration, versioning, and storage
5
5
  Home-page: https://github.com/AIP-MLOPS/model-registry
6
6
  Author: AIP MLOPS Team
@@ -31,7 +31,7 @@ version, description = read_meta()
31
31
 
32
32
  setup(
33
33
  name="aipmodel",
34
- version="0.2.69",
34
+ version="0.2.70",
35
35
  description=description,
36
36
  author="AIP MLOPS Team",
37
37
  author_email="mohmmadweb@gmail.com",
File without changes
File without changes
File without changes
File without changes