Skip to content
Merged
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
22 changes: 22 additions & 0 deletions chipcompiler/cli/commands/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
workspace_response,
)
from chipcompiler.cli.workspace.service import (
collect_signoff_package,
create_workspace_from_request,
get_workspace_home,
get_workspace_info,
Expand Down Expand Up @@ -272,3 +273,24 @@ def get_home_cmd(
json_output: Annotated[bool, typer.Option("--json")] = False,
) -> None:
_dispatch_runtime(lambda: get_workspace_home(directory), json_output)


@workspace_app.command("signoff", help="Collect a harden-flow signoff package")
def signoff_cmd(
directory: Annotated[str, typer.Option("--directory")] = "",
output_dir: Annotated[str, typer.Option("--output")] = "",
archive: Annotated[bool, typer.Option("--archive/--no-archive")] = True,
include_debug: Annotated[bool, typer.Option("--include-debug")] = False,
allow_incomplete: Annotated[bool, typer.Option("--allow-incomplete")] = False,
json_output: Annotated[bool, typer.Option("--json")] = False,
) -> None:
_dispatch_runtime(
lambda: collect_signoff_package(
directory,
output_dir,
archive,
include_debug,
allow_incomplete,
),
json_output,
)
77 changes: 76 additions & 1 deletion chipcompiler/cli/workspace/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ def run_workspace_step(directory: str, step: str, rerun: bool) -> dict:

def refresh_workspace_config(directory: str) -> dict:
cmd = "refresh_config"
response_data = {"directory": os.path.abspath(directory) if directory else "", "refreshed": False}
response_data = {
"directory": os.path.abspath(directory) if directory else "",
"refreshed": False,
}
if not directory:
return workspace_response(
cmd,
Expand Down Expand Up @@ -394,6 +397,78 @@ def get_workspace_home(directory: str) -> dict:
)


def collect_signoff_package(directory: str,
output_dir: str,
archive: bool,
include_debug: bool,
allow_incomplete: bool) -> dict:
cmd = "signoff"
response_data = {
"directory": os.path.abspath(directory) if directory else "",
"output_dir": os.path.abspath(output_dir) if output_dir else "",
"archive": bool(archive),
"include_debug": bool(include_debug),
"allow_incomplete": bool(allow_incomplete),
}
if not directory:
return workspace_response(
cmd,
"failed",
data=response_data,
message=["missing required field: directory"],
)

try:
workspace, engine_flow = load_workspace_runtime(
directory,
create_step_workspaces=False,
)
from chipcompiler.engine.signoff import SignoffPackageOptions

result = engine_flow.collect_signoff_package(
SignoffPackageOptions(
output_dir=output_dir or None,
archive=archive,
include_debug=include_debug,
allow_incomplete=allow_incomplete,
)
)
except WorkspaceValidationError as exc:
return workspace_response(cmd, "failed", data=response_data, message=[str(exc)])
except Exception as exc:
return workspace_response(
cmd,
"error",
data=response_data,
message=[f"collect signoff package failed : {exc}"],
)

response_data.update({
"directory": os.path.abspath(workspace.directory),
"package_dir": result.package_dir,
"archive_path": result.archive_path or "",
"manifest_path": result.manifest_path or "",
"summary_path": result.summary_path or "",
"copied_count": len(result.copied),
"missing_required": result.missing_required,
"warnings": result.warnings,
})
if result.ok:
return workspace_response(
cmd,
"success",
data=response_data,
message=[f"collect signoff package success : {result.package_dir}"],
)

return workspace_response(
cmd,
"failed",
data=response_data,
message=["collect signoff package incomplete"],
)


def load_workspace_runtime(directory: str, create_step_workspaces: bool = True):
import chipcompiler.data as data_api

Expand Down
9 changes: 8 additions & 1 deletion chipcompiler/engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
EngineFlow
)

from .signoff import (
SignoffPackageCollector,
SignoffPackageOptions
)

__all__ = [
'EngineDB',
'EngineFlow'
'EngineFlow',
'SignoffPackageCollector',
'SignoffPackageOptions'
]
19 changes: 17 additions & 2 deletions chipcompiler/engine/flow.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

import logging
import os
import time
import logging
import traceback
from threading import Event, Thread

from chipcompiler.data import Workspace, WorkspaceStep, StateEnum, StepEnum, log_flow
from chipcompiler.data import StateEnum, StepEnum, Workspace, WorkspaceStep, log_flow
from chipcompiler.engine import EngineDB
from chipcompiler.engine.signoff import (
SignoffPackageCollector,
SignoffPackageOptions,
SignoffPackageResult,
)
from chipcompiler.utility.log import redirect_stdio_to_file

logger = logging.getLogger(__name__)


def get_process_rss_mb(pid : int) -> float:
peak_memory = 0
try:
Expand Down Expand Up @@ -220,6 +226,15 @@ def check_step_result(self,
success = True
return success

def collect_signoff_package(
self,
options: SignoffPackageOptions | None = None,
) -> SignoffPackageResult:
"""
Collect harden-flow signoff resources from this flow workspace.
"""
return SignoffPackageCollector(self.workspace).collect(options)

def create_step_workspaces(self):
"""
create all step workspaces
Expand Down
Loading
Loading