-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_dev.py
More file actions
executable file
·189 lines (152 loc) · 5.97 KB
/
setup_dev.py
File metadata and controls
executable file
·189 lines (152 loc) · 5.97 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
#!/usr/bin/env python3
"""
GraphFlow Development Setup and Testing Script
This script helps with development setup, testing, and validation of the GraphFlow framework.
"""
import subprocess
import sys
from pathlib import Path
def run_command(cmd, description):
"""Run a command and handle errors."""
print(f"\n🔧 {description}")
print(f" Running: {cmd}")
try:
result = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True)
print(f" ✅ Success")
if result.stdout.strip():
print(f" Output: {result.stdout.strip()}")
return True
except subprocess.CalledProcessError as e:
print(f" ❌ Failed: {e}")
if e.stdout:
print(f" Stdout: {e.stdout}")
if e.stderr:
print(f" Stderr: {e.stderr}")
return False
def main():
"""Main setup and testing routine."""
print("🚀 GraphFlow Development Setup and Testing")
print("=" * 50)
# Check Python version
python_version = sys.version_info
print(f"🐍 Python version: {python_version.major}.{python_version.minor}.{python_version.micro}")
if python_version < (3, 11):
print("❌ Python 3.11+ is required")
sys.exit(1)
# Install package in development mode
print("\n📦 Installing GraphFlow in development mode...")
if not run_command("pip install -e .", "Installing package in editable mode"):
print("❌ Failed to install package")
sys.exit(1)
# Install development dependencies
print("\n📚 Installing development dependencies...")
dev_deps = [
"pytest>=7.4.0",
"pytest-cov>=4.1.0",
"black>=23.7.0",
"isort>=5.12.0",
"mypy>=1.5.0",
"rich>=13.0.0",
"typer>=0.9.0"
]
for dep in dev_deps:
if not run_command(f"pip install '{dep}'", f"Installing {dep}"):
print(f"⚠️ Warning: Failed to install {dep}")
# Run code formatting
print("\n🎨 Formatting code with black...")
run_command("black graphflow/ tests/ examples/ --line-length 88", "Formatting code")
print("\n📋 Sorting imports with isort...")
run_command("isort graphflow/ tests/ examples/ --profile black", "Sorting imports")
# Run type checking
print("\n🔍 Running type checks with mypy...")
run_command("mypy graphflow/ --ignore-missing-imports", "Type checking")
# Run tests
print("\n🧪 Running tests...")
if not run_command("python -m pytest tests/ -v", "Running test suite"):
print("⚠️ Some tests failed, but continuing...")
# Test basic imports
print("\n📥 Testing basic imports...")
try:
from graphflow import Pipeline, node, context, dataset
print(" ✅ Core imports successful")
# Test basic functionality
ctx = context(test_param="test_value")
pipeline = Pipeline("test", "s3://test", ctx)
@node()
def test_node(df, test_param):
return f"processed-{test_param}"
pipeline.add_node(test_node)
print(" ✅ Basic functionality test passed")
except Exception as e:
print(f" ❌ Import/functionality test failed: {e}")
# Test CLI
print("\n🖥️ Testing CLI...")
if not run_command("python -m graphflow.cli.main --help", "Testing CLI help"):
print("⚠️ CLI test failed")
# Run examples
print("\n📖 Testing examples...")
print("\n Running basic example...")
if not run_command("python examples/basic_example.py", "Running basic example"):
print("⚠️ Basic example failed")
print("\n Running advanced example (limited)...")
# Advanced example might be too resource intensive, so we just check syntax
if not run_command("python -m py_compile examples/advanced_example.py", "Compiling advanced example"):
print("⚠️ Advanced example has syntax errors")
# Project structure validation
print("\n📁 Validating project structure...")
required_files = [
"graphflow/__init__.py",
"graphflow/core/__init__.py",
"graphflow/core/context.py",
"graphflow/core/dataset.py",
"graphflow/core/decorators.py",
"graphflow/core/pipeline.py",
"graphflow/core/executors.py",
"graphflow/cli/__init__.py",
"graphflow/cli/main.py",
"pyproject.toml",
"README.md",
"LICENSE",
"tests/test_core.py",
"examples/basic_example.py",
"examples/advanced_example.py"
]
missing_files = []
for file_path in required_files:
if not Path(file_path).exists():
missing_files.append(file_path)
if missing_files:
print(f" ❌ Missing files: {missing_files}")
else:
print(" ✅ All required files present")
# Final summary
print("\n" + "=" * 50)
print("🎯 Setup and Testing Complete!")
print("\nNext steps:")
print("1. 📖 Read the documentation in README.md")
print("2. 🚀 Try the examples: python examples/basic_example.py")
print("3. 🔧 Create a new project: python -m graphflow.cli.main init my_project")
print("4. 🧪 Run tests: pytest tests/ -v")
print("5. 📊 Check coverage: pytest tests/ --cov=graphflow")
print("\n🎉 GraphFlow is ready for development!")
# Show quick usage
print("\n" + "=" * 50)
print("📚 Quick Usage Example:")
print("""
from graphflow import Pipeline, node, context, dataset
import pandas as pd
# Create context
ctx = context(multiplier=2, suffix="_processed")
# Create pipeline
pipeline = Pipeline("demo", "data/", ctx)
# Define node with auto-context injection
@node(outputs=[dataset("result")])
def process_data(multiplier, suffix): # Auto-injected!
return f"result_{multiplier}{suffix}"
# Add and run
pipeline.add_node(process_data)
result = pipeline.run()
print(result.summary())
""")
if __name__ == "__main__":
main()