This repository was archived by the owner on May 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsimple_mock.py
More file actions
58 lines (48 loc) · 1.51 KB
/
simple_mock.py
File metadata and controls
58 lines (48 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
"""Simple mock setup for ReadTheDocs."""
import os
import sys
from unittest.mock import MagicMock
# Create directories
os.makedirs('data/models', exist_ok=True)
os.makedirs('data/cache', exist_ok=True)
os.makedirs('config', exist_ok=True)
# Create mock config
if not os.path.exists('config/db_config.yml'):
with open('config/db_config.yml', 'w') as f:
f.write('# Mock config\ndatabases:\n memory_store:\n host: localhost\n')
# Create a special mock for diffusers.loaders.single_file
class SingleFileMock(MagicMock):
pass
# Add __type_params__ as a class attribute (not an instance attribute)
SingleFileMock.__type_params__ = tuple()
# Mock modules
MOCK_MODULES = [
'diffusers',
'diffusers.pipelines',
'diffusers.pipelines.stable_diffusion',
'diffusers.loaders',
'torch',
'transformers',
'sentence_transformers',
'memories.utils.earth',
'memories.utils.types',
'mercantile',
'pyproj',
'shapely',
'shapely.geometry'
]
# Create all mock modules
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = MagicMock()
# Special handling for the problematic module
sys.modules['diffusers.loaders.single_file'] = SingleFileMock()
# Set version for diffusers
sys.modules['diffusers'].__version__ = '0.25.0'
print("Mock setup complete")
# Test the setup
try:
import diffusers.loaders.single_file
print(f"diffusers.loaders.single_file.__type_params__: {diffusers.loaders.single_file.__type_params__}")
except Exception as e:
print(f"Error: {e}")