Skip to content

Commit 673feed

Browse files
committed
fix copilot review issues: add init files, fix function signatures, add comments to except clauses, improve edge counting
1 parent 69141e5 commit 673feed

4 files changed

Lines changed: 27 additions & 20 deletions

File tree

concore_cli/commands/inspect.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
from collections import defaultdict
77
import re
88

9-
def inspect_workflow(workflow_file, console, output_json=False):
9+
def inspect_workflow(workflow_file, source_dir, output_json, console):
1010
workflow_path = Path(workflow_file)
1111

1212
if output_json:
13-
return _inspect_json(workflow_path)
13+
return _inspect_json(workflow_path, source_dir)
1414

15-
_inspect_rich(workflow_path, console)
15+
_inspect_rich(workflow_path, source_dir, console)
1616

17-
def _inspect_rich(workflow_path, console):
17+
def _inspect_rich(workflow_path, source_dir, console):
1818
console.print()
1919
console.print(f"[bold cyan]Workflow:[/bold cyan] {workflow_path.name}")
2020
console.print()
@@ -60,7 +60,7 @@ def _inspect_rich(workflow_path, console):
6060
else:
6161
lang_counts['Other'] += 1
6262

63-
src_dir = workflow_path.parent / 'src'
63+
src_dir = workflow_path.parent / source_dir
6464
if not (src_dir / filename).exists():
6565
missing_files.append(filename)
6666

@@ -77,11 +77,11 @@ def _inspect_rich(workflow_path, console):
7777

7878
for edge in edges:
7979
label_tag = edge.find('y:EdgeLabel')
80-
if label_tag and label_tag.text:
81-
if edge_label_regex.match(label_tag.text.strip()):
82-
zmq_count += 1
83-
else:
84-
file_count += 1
80+
label_text = label_tag.text.strip() if label_tag and label_tag.text else ""
81+
if label_text and edge_label_regex.match(label_text):
82+
zmq_count += 1
83+
else:
84+
file_count += 1
8585

8686
if zmq_count > 0:
8787
edges_branch.add(f"ZMQ: {zmq_count}")
@@ -126,7 +126,7 @@ def _inspect_rich(workflow_path, console):
126126
}
127127
lang = lang_map.get(ext, 'Other')
128128

129-
src_dir = workflow_path.parent / 'src'
129+
src_dir = workflow_path.parent / source_dir
130130
status = "✓" if (src_dir / filename).exists() else "✗"
131131

132132
table.add_row(node_id, filename, lang, status)
@@ -166,7 +166,7 @@ def _inspect_rich(workflow_path, console):
166166
except Exception as e:
167167
console.print(f"[red]Inspection failed:[/red] {str(e)}")
168168

169-
def _inspect_json(workflow_path):
169+
def _inspect_json(workflow_path, source_dir):
170170
import json
171171

172172
try:
@@ -175,6 +175,10 @@ def _inspect_json(workflow_path):
175175

176176
soup = BeautifulSoup(content, 'xml')
177177

178+
if not soup.find('graphml'):
179+
print(json.dumps({'error': 'Not a valid GraphML file'}, indent=2))
180+
return
181+
178182
nodes = soup.find_all('node')
179183
edges = soup.find_all('edge')
180184

@@ -202,7 +206,7 @@ def _inspect_json(workflow_path):
202206
lang = lang_map.get(ext, 'other')
203207
lang_counts[lang] += 1
204208

205-
src_dir = workflow_path.parent / 'src'
209+
src_dir = workflow_path.parent / source_dir
206210
exists = (src_dir / filename).exists()
207211
if not exists:
208212
missing_files.append(filename)
@@ -223,13 +227,13 @@ def _inspect_json(workflow_path):
223227
target = edge.get('target')
224228

225229
label_tag = edge.find('y:EdgeLabel')
230+
label_text = label_tag.text.strip() if label_tag and label_tag.text else ""
226231
edge_type = 'file'
227-
if label_tag and label_tag.text:
228-
if edge_label_regex.match(label_tag.text.strip()):
229-
edge_type = 'zmq'
230-
zmq_count += 1
231-
else:
232-
file_count += 1
232+
if label_text and edge_label_regex.match(label_text):
233+
edge_type = 'zmq'
234+
zmq_count += 1
235+
else:
236+
file_count += 1
233237

234238
edge_list.append({
235239
'source': source,

concore_cli/commands/status.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ def show_status(console):
3838
minutes, seconds = divmod(remainder, 60)
3939
uptime_str = f"{hours}h {minutes}m {seconds}s"
4040
except:
41+
# Failed to calculate uptime
4142
uptime_str = "unknown"
4243

4344
try:
4445
mem_mb = proc.info['memory_info'].rss / 1024 / 1024
4546
mem_str = f"{mem_mb:.1f} MB"
4647
except:
48+
# Failed to get memory info
4749
mem_str = "unknown"
4850

4951
command = ' '.join(cmdline[:3]) if len(cmdline) >= 3 else cmdline_str[:50]

concore_cli/commands/stop.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def stop_all(console):
3131
if is_concore:
3232
processes_to_kill.append(proc)
3333
except (psutil.NoSuchProcess, psutil.AccessDenied):
34-
# Process may have exited or be inaccessible; safe to ignore
34+
# Process already exited or access denied; continue
3535
continue
3636

3737
except Exception as e:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ concore = "concore_cli.cli:cli"
2828

2929
[tool.setuptools]
3030
packages = ["concore_cli", "concore_cli.commands"]
31+
py-modules = ["mkconcore"]

0 commit comments

Comments
 (0)