Skip to content

Commit 554ef06

Browse files
committed
fix copilot review issues: add init files, fix function signatures, add comments to except clauses, improve edge counting
1 parent a49fd50 commit 554ef06

7 files changed

Lines changed: 34 additions & 31 deletions

File tree

concore_cli/__init__.py

Whitespace-only changes.

concore_cli/cli.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import click
22
from rich.console import Console
3-
from rich.table import Table
4-
from rich.panel import Panel
5-
from rich import print as rprint
63
import sys
7-
import os
8-
from pathlib import Path
94

105
from .commands.init import init_project
116
from .commands.run import run_workflow
@@ -55,10 +50,11 @@ def validate(workflow_file):
5550

5651
@cli.command()
5752
@click.argument('workflow_file', type=click.Path(exists=True))
53+
@click.option('--source', '-s', default='src', help='Source directory')
5854
@click.option('--json', 'output_json', is_flag=True, help='Output in JSON format')
59-
def inspect(workflow_file, output_json):
55+
def inspect(workflow_file, source, output_json):
6056
try:
61-
inspect_workflow(workflow_file, console, output_json)
57+
inspect_workflow(workflow_file, source, output_json, console)
6258
except Exception as e:
6359
console.print(f"[red]Error:[/red] {str(e)}")
6460
sys.exit(1)

concore_cli/commands/__init__.py

Whitespace-only changes.

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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from rich.table import Table
2-
from rich.panel import Panel
32
import psutil
43
import os
54

@@ -18,7 +17,8 @@ def show_status(console):
1817
if 'concore' in cmdline.lower() and proc.info['pid'] != current_pid:
1918
concore_processes.append(proc)
2019
except (psutil.NoSuchProcess, psutil.AccessDenied):
21-
pass
20+
# Process may have exited or be inaccessible; safe to ignore
21+
continue
2222

2323
if not concore_processes:
2424
console.print("[yellow]No running concore processes found[/yellow]")
@@ -38,7 +38,8 @@ def show_status(console):
3838

3939
table.add_row(pid, name, cmd)
4040
except (psutil.NoSuchProcess, psutil.AccessDenied):
41-
pass
41+
# Process may have exited between iterations
42+
continue
4243

4344
console.print(table)
4445
console.print()

concore_cli/commands/stop.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ def stop_all(console):
1919
proc.terminate()
2020
stopped += 1
2121
console.print(f"[green]✓[/green] Stopped process {proc.info['pid']}")
22-
except (psutil.NoSuchProcess, psutil.AccessDenied) as e:
23-
pass
22+
except (psutil.NoSuchProcess, psutil.AccessDenied):
23+
# Process already exited or access denied; continue
24+
continue
2425

2526
if stopped == 0:
2627
console.print("[yellow]No processes to stop[/yellow]")

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)