umarise-wandb 0.1.0__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.
- umarise_wandb-0.1.0/PKG-INFO +23 -0
- umarise_wandb-0.1.0/README.md +1 -0
- umarise_wandb-0.1.0/pyproject.toml +28 -0
- umarise_wandb-0.1.0/setup.cfg +4 -0
- umarise_wandb-0.1.0/umarise_wandb/__init__.py +13 -0
- umarise_wandb-0.1.0/umarise_wandb/anchor.py +51 -0
- umarise_wandb-0.1.0/umarise_wandb/callback.py +65 -0
- umarise_wandb-0.1.0/umarise_wandb.egg-info/PKG-INFO +23 -0
- umarise_wandb-0.1.0/umarise_wandb.egg-info/SOURCES.txt +10 -0
- umarise_wandb-0.1.0/umarise_wandb.egg-info/dependency_links.txt +1 -0
- umarise_wandb-0.1.0/umarise_wandb.egg-info/requires.txt +2 -0
- umarise_wandb-0.1.0/umarise_wandb.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: umarise-wandb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Anchor W&B artifacts to Bitcoin. Zero-touch provenance for ML experiments.
|
|
5
|
+
Author-email: Umarise <partners@umarise.com>
|
|
6
|
+
License: Unlicense
|
|
7
|
+
Project-URL: Homepage, https://umarise.com
|
|
8
|
+
Project-URL: Documentation, https://umarise.com/api-reference
|
|
9
|
+
Project-URL: Repository, https://github.com/AnchoringTrust/umarise-wandb
|
|
10
|
+
Project-URL: Case Study, https://umarise.com/case/ai-code-generation
|
|
11
|
+
Keywords: umarise,wandb,weights-and-biases,anchoring,bitcoin,proof-of-existence,opentimestamps,provenance,ai-audit
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Topic :: Security :: Cryptography
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Requires-Dist: umarise-core-sdk>=1.1.0
|
|
21
|
+
Requires-Dist: wandb>=0.15
|
|
22
|
+
|
|
23
|
+
# umarise-wandb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# umarise-wandb
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "umarise-wandb"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Anchor W&B artifacts to Bitcoin. Zero-touch provenance for ML experiments."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "Unlicense" }
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
authors = [{ name = "Umarise", email = "partners@umarise.com" }]
|
|
13
|
+
keywords = ["umarise", "wandb", "weights-and-biases", "anchoring", "bitcoin", "proof-of-existence", "opentimestamps", "provenance", "ai-audit"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
19
|
+
"Topic :: Security :: Cryptography",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
]
|
|
22
|
+
dependencies = ["umarise-core-sdk>=1.1.0", "wandb>=0.15"]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://umarise.com"
|
|
26
|
+
Documentation = "https://umarise.com/api-reference"
|
|
27
|
+
Repository = "https://github.com/AnchoringTrust/umarise-wandb"
|
|
28
|
+
"Case Study" = "https://umarise.com/case/ai-code-generation"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""
|
|
2
|
+
umarise-wandb: Anchor W&B artifacts to Bitcoin.
|
|
3
|
+
|
|
4
|
+
Usage:
|
|
5
|
+
import umarise_wandb
|
|
6
|
+
umarise_wandb.enable()
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from umarise_wandb.anchor import anchor_artifact, anchor_logged_artifact
|
|
10
|
+
from umarise_wandb.callback import AnchorCallback, enable
|
|
11
|
+
|
|
12
|
+
__version__ = "0.1.0"
|
|
13
|
+
__all__ = ["anchor_artifact", "anchor_logged_artifact", "AnchorCallback", "enable"]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Core anchoring functions for W&B artifacts."""
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import os
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
import wandb
|
|
8
|
+
from umarise import UmariseCore
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _hash_file(path: str) -> str:
|
|
12
|
+
h = hashlib.sha256()
|
|
13
|
+
with open(path, "rb") as f:
|
|
14
|
+
for chunk in iter(lambda: f.read(8192), b""):
|
|
15
|
+
h.update(chunk)
|
|
16
|
+
return f"sha256:{h.hexdigest()}"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def anchor_artifact(artifact: wandb.Artifact, api_key: Optional[str] = None) -> list:
|
|
20
|
+
client = UmariseCore(api_key=api_key)
|
|
21
|
+
results = []
|
|
22
|
+
for entry in artifact.manifest.entries.values():
|
|
23
|
+
if entry.local_path and os.path.exists(entry.local_path):
|
|
24
|
+
file_hash = _hash_file(entry.local_path)
|
|
25
|
+
result = client.attest(hash=file_hash)
|
|
26
|
+
result["artifact_name"] = artifact.name
|
|
27
|
+
result["entry_path"] = entry.path
|
|
28
|
+
results.append(result)
|
|
29
|
+
if wandb.run:
|
|
30
|
+
wandb.log({"umarise/origin_id": result.get("origin_id"), "umarise/anchored": True})
|
|
31
|
+
return results
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def anchor_logged_artifact(artifact_name: str, version: str = "latest", api_key: Optional[str] = None) -> list:
|
|
35
|
+
if not wandb.run:
|
|
36
|
+
raise RuntimeError("No active W&B run. Call wandb.init() first.")
|
|
37
|
+
ref = f"{artifact_name}:{version}" if ":" not in artifact_name else artifact_name
|
|
38
|
+
artifact = wandb.run.use_artifact(ref)
|
|
39
|
+
artifact_dir = artifact.download()
|
|
40
|
+
client = UmariseCore(api_key=api_key)
|
|
41
|
+
results = []
|
|
42
|
+
for root, _, files in os.walk(artifact_dir):
|
|
43
|
+
for fname in files:
|
|
44
|
+
fpath = os.path.join(root, fname)
|
|
45
|
+
file_hash = _hash_file(fpath)
|
|
46
|
+
result = client.attest(hash=file_hash)
|
|
47
|
+
result["file"] = os.path.relpath(fpath, artifact_dir)
|
|
48
|
+
results.append(result)
|
|
49
|
+
if results:
|
|
50
|
+
wandb.log({"umarise/artifact_count": len(results), "umarise/anchored": True})
|
|
51
|
+
return results
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Auto-anchor callback for W&B."""
|
|
2
|
+
|
|
3
|
+
import threading
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
import wandb
|
|
7
|
+
from umarise_wandb.anchor import anchor_artifact as _anchor
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AnchorCallback:
|
|
11
|
+
def __init__(self, api_key: Optional[str] = None):
|
|
12
|
+
self.api_key = api_key
|
|
13
|
+
self._lock = threading.Lock()
|
|
14
|
+
|
|
15
|
+
def on_artifact_log(self, artifact: wandb.Artifact, **kwargs):
|
|
16
|
+
with self._lock:
|
|
17
|
+
try:
|
|
18
|
+
_anchor(artifact, api_key=self.api_key)
|
|
19
|
+
except Exception:
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_original_log_artifact = None
|
|
24
|
+
_enabled = False
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def enable(api_key: Optional[str] = None):
|
|
28
|
+
global _original_log_artifact, _enabled
|
|
29
|
+
if _enabled:
|
|
30
|
+
return
|
|
31
|
+
from umarise import UmariseCore
|
|
32
|
+
import hashlib
|
|
33
|
+
import os
|
|
34
|
+
client = UmariseCore(api_key=api_key)
|
|
35
|
+
_original_log_artifact = wandb.Run.log_artifact
|
|
36
|
+
|
|
37
|
+
def _patched_log_artifact(self, artifact, *args, **kwargs):
|
|
38
|
+
result = _original_log_artifact(self, artifact, *args, **kwargs)
|
|
39
|
+
try:
|
|
40
|
+
if hasattr(artifact, 'manifest') and artifact.manifest:
|
|
41
|
+
for entry in artifact.manifest.entries.values():
|
|
42
|
+
if entry.local_path and os.path.exists(entry.local_path):
|
|
43
|
+
h = hashlib.sha256()
|
|
44
|
+
with open(entry.local_path, "rb") as f:
|
|
45
|
+
for chunk in iter(lambda: f.read(8192), b""):
|
|
46
|
+
h.update(chunk)
|
|
47
|
+
file_hash = f"sha256:{h.hexdigest()}"
|
|
48
|
+
anchor_result = client.attest(hash=file_hash)
|
|
49
|
+
if wandb.run:
|
|
50
|
+
wandb.run.summary["umarise_anchored"] = True
|
|
51
|
+
wandb.run.summary["umarise_last_origin_id"] = anchor_result.get("origin_id")
|
|
52
|
+
except Exception:
|
|
53
|
+
pass
|
|
54
|
+
return result
|
|
55
|
+
|
|
56
|
+
wandb.Run.log_artifact = _patched_log_artifact
|
|
57
|
+
_enabled = True
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def disable():
|
|
61
|
+
global _original_log_artifact, _enabled
|
|
62
|
+
if _original_log_artifact:
|
|
63
|
+
wandb.Run.log_artifact = _original_log_artifact
|
|
64
|
+
_original_log_artifact = None
|
|
65
|
+
_enabled = False
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: umarise-wandb
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Anchor W&B artifacts to Bitcoin. Zero-touch provenance for ML experiments.
|
|
5
|
+
Author-email: Umarise <partners@umarise.com>
|
|
6
|
+
License: Unlicense
|
|
7
|
+
Project-URL: Homepage, https://umarise.com
|
|
8
|
+
Project-URL: Documentation, https://umarise.com/api-reference
|
|
9
|
+
Project-URL: Repository, https://github.com/AnchoringTrust/umarise-wandb
|
|
10
|
+
Project-URL: Case Study, https://umarise.com/case/ai-code-generation
|
|
11
|
+
Keywords: umarise,wandb,weights-and-biases,anchoring,bitcoin,proof-of-existence,opentimestamps,provenance,ai-audit
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Topic :: Security :: Cryptography
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Requires-Dist: umarise-core-sdk>=1.1.0
|
|
21
|
+
Requires-Dist: wandb>=0.15
|
|
22
|
+
|
|
23
|
+
# umarise-wandb
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
umarise_wandb/__init__.py
|
|
4
|
+
umarise_wandb/anchor.py
|
|
5
|
+
umarise_wandb/callback.py
|
|
6
|
+
umarise_wandb.egg-info/PKG-INFO
|
|
7
|
+
umarise_wandb.egg-info/SOURCES.txt
|
|
8
|
+
umarise_wandb.egg-info/dependency_links.txt
|
|
9
|
+
umarise_wandb.egg-info/requires.txt
|
|
10
|
+
umarise_wandb.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
umarise_wandb
|