bupa1018 commited on
Commit
50dd7e5
·
1 Parent(s): 8b31dd1

Delete repo_versions.py

Browse files
Files changed (1) hide show
  1. repo_versions.py +0 -41
repo_versions.py DELETED
@@ -1,41 +0,0 @@
1
- import os
2
- import json
3
- import huggingface_hub
4
- from huggingface_hub import Repository
5
- from datetime import datetime
6
-
7
- # Define the path to your JSON file
8
-
9
- DATASET_REPO_URL = "https://huggingface.co/datasets/bupa1018/Test"
10
- DATA_FILENAME = "repo_data.json"
11
- DATA_FILE = os.path.join("data", DATA_FILENAME)
12
-
13
- # Function to retrieve the last download entry from the JSON file
14
- def store_message_from_json(hf_token):
15
- try:
16
-
17
- repo = Repository(
18
- local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=hf_token
19
- )
20
- # Open and load the JSON file
21
- with open(DATA_FILE, "r") as jsonfile:
22
- data = json.load(jsonfile)
23
-
24
- # Check if the "downloads" list exists and is not empty
25
- if "downloads" in data and len(data["downloads"]) > 0:
26
- # Retrieve the last item in the "downloads" list
27
- last_download = data["downloads"][-1]
28
- version = last_download["version"]
29
- commit_hash = last_download["commit_hash"]
30
- download_date = last_download["download_date"]
31
-
32
- # Print or return the extracted data
33
- return f"Version: {version}, Commit Hash: {commit_hash}, Download Date: {download_date}"
34
- else:
35
- return "No downloads found in the JSON file."
36
- except FileNotFoundError:
37
- return "The JSON file does not exist."
38
- except json.JSONDecodeError:
39
- return "Error decoding the JSON file."
40
- except Exception as e:
41
- return f"An error occurred: {e}"