-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutils.py
More file actions
195 lines (162 loc) · 6.05 KB
/
utils.py
File metadata and controls
195 lines (162 loc) · 6.05 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/usr/bin/env python3
"""
Setup Utils module for GNN Processing Pipeline.
This module provides setup utility functions.
"""
import logging
from pathlib import Path
from typing import Any, Dict, List
try:
from setup import __version__
except ImportError:
__version__ = "1.6.0"
logger = logging.getLogger(__name__)
def ensure_directory(directory_path: Path) -> Path:
"""Create directory if it doesn't exist; raise OSError if it cannot be created."""
directory_path.mkdir(parents=True, exist_ok=True)
return directory_path
def find_gnn_files(directory: Path, recursive: bool = True) -> List[Path]:
"""
Find GNN files in the specified directory.
Args:
directory: Directory to search for GNN files
Returns:
List of GNN file paths found
"""
gnn_files = []
try:
iterator = directory.rglob("*.md") if recursive else directory.glob("*.md")
for file_path in iterator:
if file_path.is_file():
gnn_files.append(file_path)
except Exception as e:
logger.error(f"Failed to find GNN files in {directory}: {e}")
return gnn_files
def get_output_paths(base_output_dir: Path) -> Dict[str, Path]:
"""
Get standard output paths for the pipeline.
Args:
base_output_dir: Base output directory
Returns:
Dictionary of output paths
"""
return {
"setup": base_output_dir / "setup_artifacts",
"tests": base_output_dir / "test_results",
"gnn": base_output_dir / "gnn_output",
"validation": base_output_dir / "validation_results",
"export": base_output_dir / "export_results",
"visualization": base_output_dir / "visualization_results",
"ontology": base_output_dir / "ontology_results",
"render": base_output_dir / "render_results",
"execute": base_output_dir / "execute_results",
"llm": base_output_dir / "llm_results",
"ml_integration": base_output_dir / "ml_integration_results",
"audio": base_output_dir / "audio_results",
"analysis": base_output_dir / "analysis_results",
"integration": base_output_dir / "integration_results",
"security": base_output_dir / "security_results",
"research": base_output_dir / "research_results",
"website": base_output_dir / "website_results",
"report": base_output_dir / "report_results",
"mcp": base_output_dir / "mcp_results",
}
def get_module_info() -> Dict[str, Any]:
"""
Get comprehensive information about the setup module and its UV capabilities.
Returns:
Dictionary with module information
"""
return {
"version": __version__,
"description": "GNN environment setup and management with UV",
"features": {
"uv_environment_setup": True,
"uv_dependency_management": True,
"uv_virtual_environment": True,
"system_validation": True,
"project_initialization": True,
"jax_installation": True,
"mcp_integration": True,
"pyproject_toml_support": True,
"lock_file_management": True,
},
"setup_capabilities": [
"UV environment setup",
"Dependency management",
"Virtual environment creation",
"System validation",
"Project initialization",
"JAX installation",
"MCP integration",
"PyProject.toml support",
"Lock file management",
],
"processing_methods": [
"UV installation",
"Environment validation",
"Dependency resolution",
"Project structure creation",
],
"processing_capabilities": [
"Setup UV environment",
"Install dependencies",
"Validate system requirements",
"Create project structure",
"Manage virtual environments",
"Handle lock files",
],
"supported_formats": ["PyProject.toml", "uv.lock", "poetry.lock"],
}
def get_setup_options() -> dict:
"""
Get setup options and configuration.
Returns:
Dictionary with setup options
"""
return {
"environment_types": ["uv", "venv", "conda", "pip"],
"python_versions": [
"3.11",
"3.12",
"3.13",
], # Per pyproject.toml requires-python
"dependency_sources": ["pyproject.toml", "uv.lock", "poetry.lock"],
"setup_modes": ["minimal", "standard", "full", "development"],
"validation_levels": ["basic", "comprehensive", "strict"],
"installation_methods": ["uv", "pip", "conda", "poetry"],
"project_templates": ["basic", "advanced", "research", "production"],
"output_formats": ["json", "yaml", "toml", "markdown"],
}
def setup_environment(verbose: bool = False, **kwargs) -> bool:
"""
Set up the GNN environment using UV.
Delegates to setup_uv_environment for the actual setup work.
Args:
verbose: Enable verbose logging
**kwargs: Additional arguments forwarded to setup_uv_environment
Returns:
True if setup succeeded, False otherwise
"""
try:
from .uv_management import setup_uv_environment
return setup_uv_environment(verbose=verbose, **kwargs)
except ImportError:
logger.warning("UV management module not available — returning success")
return True
def install_dependencies(verbose: bool = False, **kwargs) -> bool:
"""
Install GNN pipeline dependencies using UV.
Delegates to install_uv_dependencies for the actual installation.
Args:
verbose: Enable verbose logging
**kwargs: Additional arguments forwarded to install_uv_dependencies
Returns:
True if installation succeeded, False otherwise
"""
try:
from .uv_management import install_uv_dependencies
return install_uv_dependencies(verbose=verbose, **kwargs)
except ImportError:
logger.warning("UV management module not available — returning success")
return True