Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions concore_cli/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
from rich.panel import Panel
from rich.progress import Progress, SpinnerColumn, TextColumn

def _find_mkconcore_path():
for parent in Path(__file__).resolve().parents:
candidate = parent / "mkconcore.py"
if candidate.exists():
return candidate
return None

def run_workflow(workflow_file, source, output, exec_type, auto_build, console):
workflow_path = Path(workflow_file).resolve()
source_path = Path(source).resolve()
output_path = Path(output)
output_path = Path(output).resolve()

if not source_path.exists():
raise FileNotFoundError(f"Source directory '{source}' not found")
Expand All @@ -24,6 +31,10 @@ def run_workflow(workflow_file, source, output, exec_type, auto_build, console):
console.print(f"[cyan]Type:[/cyan] {exec_type}")
console.print()

mkconcore_path = _find_mkconcore_path()
if mkconcore_path is None:
raise FileNotFoundError("mkconcore.py not found. Please install concore from source.")

with Progress(
SpinnerColumn(),
TextColumn("[progress.description]{task.description}"),
Expand All @@ -33,7 +44,8 @@ def run_workflow(workflow_file, source, output, exec_type, auto_build, console):

try:
result = subprocess.run(
[sys.executable, 'mkconcore.py', str(workflow_path), str(source_path), str(output_path), exec_type],
[sys.executable, str(mkconcore_path), str(workflow_path), str(source_path), str(output_path), exec_type],
cwd=mkconcore_path.parent,
capture_output=True,
text=True,
check=True
Expand Down
21 changes: 16 additions & 5 deletions mkconcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,22 @@
import copy_with_port_portname
import numpy as np

MKCONCORE_VER = "22-09-18"

GRAPHML_FILE = sys.argv[1]
TRIMMED_LOGS = True
CONCOREPATH = "."
MKCONCORE_VER = "22-09-18"

SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))

def _resolve_concore_path():
script_concore = os.path.join(SCRIPT_DIR, "concore.py")
if os.path.exists(script_concore):
return SCRIPT_DIR
cwd_concore = os.path.join(os.getcwd(), "concore.py")
if os.path.exists(cwd_concore):
return os.getcwd()
return SCRIPT_DIR

GRAPHML_FILE = sys.argv[1]
TRIMMED_LOGS = True
CONCOREPATH = _resolve_concore_path()
CPPWIN = "g++" #Windows C++ 6/22/21
CPPEXE = "g++" #Ubuntu/macOS C++ 6/22/21
VWIN = "iverilog" #Windows verilog 6/25/21
Expand Down
17 changes: 16 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,22 @@ def test_run_command_missing_source(self):
result = self.runner.invoke(cli, ['init', 'test-project'])
result = self.runner.invoke(cli, ['run', 'test-project/workflow.graphml', '--source', 'nonexistent'])
self.assertNotEqual(result.exit_code, 0)


def test_run_command_from_project_dir(self):
with self.runner.isolated_filesystem(temp_dir=self.temp_dir):
result = self.runner.invoke(cli, ['init', 'test-project'])
self.assertEqual(result.exit_code, 0)

result = self.runner.invoke(cli, [
'run',
'test-project/workflow.graphml',
'--source', 'test-project/src',
'--output', 'out',
'--type', 'posix'
])
self.assertEqual(result.exit_code, 0)
self.assertTrue(Path('out/src/concore.py').exists())

def test_run_command_existing_output(self):
with self.runner.isolated_filesystem(temp_dir=self.temp_dir):
result = self.runner.invoke(cli, ['init', 'test-project'])
Expand Down