gblazex commited on
Commit
656940c
·
1 Parent(s): b9687ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -31,8 +31,26 @@ from src.submission.submit import add_new_eval
31
 
32
 
33
 
34
- import os
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
 
36
  def count_files_in_directory_tree(directory):
37
  file_count = 0
38
  for root, dirs, files in os.walk(directory):
@@ -41,13 +59,13 @@ def count_files_in_directory_tree(directory):
41
 
42
 
43
  from huggingface_hub import hf_hub_download, Repository
44
-
45
  def download_dataset(repo_id, local_dir):
46
  # Clone the repository
47
  repo_id_full = f"https://huggingface.co/datasets/{repo_id}"
48
  repo = Repository(local_dir=local_dir, clone_from=repo_id_full)
49
  files_cnt = count_files_in_directory_tree(local_dir)
50
  print(f"{local_dir}: {files_cnt}")
 
51
  # Alternatively, you can download specific files using hf_hub_download
52
  # file_path = hf_hub_download(repo_id, filename="your_file_name")
53
 
 
31
 
32
 
33
 
34
+ import json
35
+ def print_first_json_content(directory):
36
+ for root, dirs, files in os.walk(directory):
37
+ for file in files:
38
+ if file.endswith(".json"):
39
+ json_file_path = os.path.join(root, file)
40
+ try:
41
+ with open(json_file_path, 'r') as json_file:
42
+ data = json.load(json_file)
43
+ print(f"Contents of {json_file_path}:")
44
+ print(json.dumps(data, indent=4))
45
+ return True
46
+ except Exception as e:
47
+ print(f"Error reading {json_file_path}: {e}")
48
+ return False
49
+ print("No JSON file found.")
50
+ return False
51
+
52
 
53
+ import os
54
  def count_files_in_directory_tree(directory):
55
  file_count = 0
56
  for root, dirs, files in os.walk(directory):
 
59
 
60
 
61
  from huggingface_hub import hf_hub_download, Repository
 
62
  def download_dataset(repo_id, local_dir):
63
  # Clone the repository
64
  repo_id_full = f"https://huggingface.co/datasets/{repo_id}"
65
  repo = Repository(local_dir=local_dir, clone_from=repo_id_full)
66
  files_cnt = count_files_in_directory_tree(local_dir)
67
  print(f"{local_dir}: {files_cnt}")
68
+ print_first_json_content(local_dir)
69
  # Alternatively, you can download specific files using hf_hub_download
70
  # file_path = hf_hub_download(repo_id, filename="your_file_name")
71