jbilcke-hf HF staff commited on
Commit
2039f5a
•
1 Parent(s): 9a5dbb2

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +31 -3
handler.py CHANGED
@@ -1,5 +1,6 @@
1
  from dataclasses import dataclass
2
  from pathlib import Path
 
3
  from typing import Dict, Any, Optional, Tuple
4
  import asyncio
5
  import base64
@@ -24,6 +25,33 @@ MAX_WIDTH = 1280
24
  MAX_HEIGHT = 720
25
  MAX_FRAMES = 257
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  def print_directory_structure(startpath):
28
  """Print the directory structure starting from the given path."""
29
  for root, dirs, files in os.walk(startpath):
@@ -34,12 +62,12 @@ def print_directory_structure(startpath):
34
  for f in files:
35
  logger.info(f"{subindent}{f}")
36
 
 
 
 
37
  logger.info("💡 Printing directory structure of ""/repository"":")
38
  print_directory_structure("/repository")
39
 
40
- logger.info("💡 Printing directory structure of os.getcwd():")
41
- print_directory_structure(os.getcwd())
42
-
43
  @dataclass
44
  class GenerationConfig:
45
  """Configuration for video generation"""
 
1
  from dataclasses import dataclass
2
  from pathlib import Path
3
+ import pathlib
4
  from typing import Dict, Any, Optional, Tuple
5
  import asyncio
6
  import base64
 
25
  MAX_HEIGHT = 720
26
  MAX_FRAMES = 257
27
 
28
+ # this is only a temporary solution (famous last words)
29
+ def apply_dirty_hack_to_patch_file_extensions_and_bypass_filter(directory):
30
+ """
31
+ Recursively rename all '._pth_hf' files to '.pth' in the given directory
32
+
33
+ Args:
34
+ directory (str): Path to the directory to process
35
+ """
36
+ # Convert the directory path to absolute path
37
+ directory = os.path.abspath(directory)
38
+
39
+ # Walk through directory and its subdirectories
40
+ for root, _, files in os.walk(directory):
41
+ for filename in files:
42
+ if filename.endswith('._pth_hf'):
43
+ # Get full path of the file
44
+ old_path = os.path.join(root, filename)
45
+ # Create new filename by replacing the extension
46
+ new_filename = filename.replace('._pth_', '.pth')
47
+ new_path = os.path.join(root, new_filename)
48
+
49
+ try:
50
+ os.rename(old_path, new_path)
51
+ print(f"Renamed: {old_path} -> {new_path}")
52
+ except OSError as e:
53
+ print(f"Error renaming {old_path}: {e}")
54
+
55
  def print_directory_structure(startpath):
56
  """Print the directory structure starting from the given path."""
57
  for root, dirs, files in os.walk(startpath):
 
62
  for f in files:
63
  logger.info(f"{subindent}{f}")
64
 
65
+ logger.info("💡 Applying a dirty hack (patch ""/repository"" to fix file extensions):")
66
+ apply_dirty_hack_to_patch_file_extensions_and_bypass_filter("/repository")
67
+
68
  logger.info("💡 Printing directory structure of ""/repository"":")
69
  print_directory_structure("/repository")
70
 
 
 
 
71
  @dataclass
72
  class GenerationConfig:
73
  """Configuration for video generation"""