Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -22,13 +22,6 @@ def download_dataset_file(dataset_id, local_dir):
|
|
22 |
dataset = load_dataset(dataset_id)
|
23 |
cache_file_info = dataset.cache_files
|
24 |
print(f"Cache File Info: {cache_file_info}\n")
|
25 |
-
# filename = cache_file_info['test'][0]['filename']
|
26 |
-
# snapshot_id = filename.split('/')[-2]
|
27 |
-
# dataset_name = filename.split('/')[-5]
|
28 |
-
# dataset_name = dataset_name.replace('___', '--')
|
29 |
-
# base_path = os.path.join('/home/user/.cache/huggingface/hub', 'datasets--' + dataset_name)
|
30 |
-
# snapshot_path = os.path.join(base_path, "snapshots", snapshot_id)
|
31 |
-
# print(f"snapshot_path: {snapshot_path}")
|
32 |
|
33 |
snapshot_path = "/home/user/.cache/huggingface/hub/datasets--350016z--flores_plus_Taiwanese/snapshots/9a8fe738903c9ab08620db4553c582376bcdd64f"
|
34 |
contents = os.listdir(snapshot_path)
|
@@ -42,18 +35,25 @@ def download_dataset_file(dataset_id, local_dir):
|
|
42 |
source_file_path = os.path.join(snapshot_path, file_name)
|
43 |
local_file_path = os.path.join(local_dir, file_name)
|
44 |
|
45 |
-
shutil.
|
46 |
-
print(f"
|
|
|
|
|
47 |
if not os.path.exists(local_file_path):
|
48 |
-
print(f"Error: {local_file_path} does not exist after
|
49 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
return local_dir
|
52 |
|
53 |
DATASET_ID = "350016z/flores_plus_Taiwanese"
|
54 |
current_dir = os.getcwd()
|
55 |
print(f"Before -------- Contents of current_dir: {os.listdir(current_dir)}--------")
|
56 |
-
|
57 |
download_dataset_file(DATASET_ID, current_dir)
|
58 |
print(f"After -------- Contents of current_dir: {os.listdir(current_dir)}--------")
|
59 |
|
|
|
22 |
dataset = load_dataset(dataset_id)
|
23 |
cache_file_info = dataset.cache_files
|
24 |
print(f"Cache File Info: {cache_file_info}\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
snapshot_path = "/home/user/.cache/huggingface/hub/datasets--350016z--flores_plus_Taiwanese/snapshots/9a8fe738903c9ab08620db4553c582376bcdd64f"
|
27 |
contents = os.listdir(snapshot_path)
|
|
|
35 |
source_file_path = os.path.join(snapshot_path, file_name)
|
36 |
local_file_path = os.path.join(local_dir, file_name)
|
37 |
|
38 |
+
shutil.copy(source_file_path, local_file_path) # 改為複製操作
|
39 |
+
print(f"Copied {file_name} to {local_file_path}")
|
40 |
+
|
41 |
+
# 確認檔案存在
|
42 |
if not os.path.exists(local_file_path):
|
43 |
+
print(f"Error: {local_file_path} does not exist after copying.")
|
44 |
continue
|
45 |
+
|
46 |
+
# 檢查檔案權限
|
47 |
+
print(f"Permissions for {local_file_path}: {oct(os.stat(local_file_path).st_mode)}")
|
48 |
+
|
49 |
+
# 延遲以確保檔案系統同步
|
50 |
+
time.sleep(1)
|
51 |
|
52 |
return local_dir
|
53 |
|
54 |
DATASET_ID = "350016z/flores_plus_Taiwanese"
|
55 |
current_dir = os.getcwd()
|
56 |
print(f"Before -------- Contents of current_dir: {os.listdir(current_dir)}--------")
|
|
|
57 |
download_dataset_file(DATASET_ID, current_dir)
|
58 |
print(f"After -------- Contents of current_dir: {os.listdir(current_dir)}--------")
|
59 |
|