Leonydis137 commited on
Commit
d5d03f8
·
verified ·
1 Parent(s): ee3ba6f

Update src/utils/hf_packager.py

Browse files
Files changed (1) hide show
  1. src/utils/hf_packager.py +22 -2
src/utils/hf_packager.py CHANGED
@@ -1,2 +1,22 @@
1
- def create_snapshot():
2
- return "https://huggingface.co/spaces/your-snapshot-url"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # src/utils/hf_packager.py
2
+
3
+ import os
4
+ from datetime import datetime
5
+
6
+ class HFSpacePackager:
7
+ def __init__(self, snapshot_dir="snapshots"):
8
+ self.snapshot_dir = snapshot_dir
9
+ os.makedirs(snapshot_dir, exist_ok=True)
10
+
11
+ def create_snapshot(self, data=None):
12
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
13
+ filename = f"snapshot_{timestamp}.txt"
14
+ filepath = os.path.join(self.snapshot_dir, filename)
15
+
16
+ with open(filepath, "w") as f:
17
+ f.write("Snapshot created.\n")
18
+ if data:
19
+ f.write(str(data))
20
+
21
+ return f"https://huggingface.co/spaces/your-username/your-space-name/blob/main/{self.snapshot_dir}/{filename}"
22
+