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
68 changes: 35 additions & 33 deletions src/buildcompiler/api/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from dataclasses import dataclass, field
from typing import Any

from buildcompiler.planning import FullBuildPlanner

from .options import BuildOptions


@dataclass
class BuildCompiler:
"""Lightweight dependency-injected compiler facade."""

inventory: Any = None
sbol_document: Any = None
planner: Any = None
Expand All @@ -30,43 +30,42 @@ def from_synbiohub(
options: BuildOptions | None = None,
**kwargs: Any,
) -> "BuildCompiler":
"""Factory boundary reserved for future SynBioHub loading/indexing."""
if collections:
raise NotImplementedError(
"Automatic SynBioHub collection loading/indexing is not implemented yet. "
"Inject inventory dependencies directly for now."
"Automatic SynBioHub collection loading/indexing is not implemented yet. Inject inventory dependencies directly for now."
)

return cls(
sbol_document=sbol_doc,
options=options or BuildOptions(),
**kwargs,
)
return cls(sbol_document=sbol_doc, options=options or BuildOptions(), **kwargs)

def plan(self, abstract_designs: Any, options: BuildOptions | None = None) -> Any:
"""Plan a build request via injected planner (placeholder in skeleton)."""
if self.planner is None:
raise NotImplementedError(
"Build planning is not implemented in the API skeleton. "
"Inject a planner dependency to use BuildCompiler.plan()."
)

effective_options = options or self.options
return self.planner.plan(abstract_designs, options=effective_options)
planner = self.planner or FullBuildPlanner(options=effective_options)
return planner.plan(abstract_designs, options=effective_options)

def execute(self, plan: Any, options: BuildOptions | None = None) -> Any:
"""Execute a build plan via injected executor (placeholder in skeleton)."""
if self.executor is None:
raise NotImplementedError(
"Build execution is not implemented in the API skeleton. "
"Inject an executor dependency to use BuildCompiler.execute()."
)

effective_options = options or self.options
return self.executor.execute(plan, options=effective_options)
executor = self.executor
if executor is None:
if self.inventory is None:
raise ValueError(
"BuildCompiler.execute requires an inventory when no executor is injected."
)
if self.sbol_document is None:
raise ValueError(
"BuildCompiler.execute requires an sbol_document when no executor is injected."
)
from buildcompiler.execution import FullBuildExecutor

executor = FullBuildExecutor.from_dependencies(
inventory=self.inventory,
sbol_document=self.sbol_document,
options=effective_options,
adapters=self.adapters,
)
return executor.execute(plan, options=effective_options)

def full_build(self, abstract_designs: Any, options: BuildOptions | None = None) -> Any:
"""Convenience skeleton method: plan then execute."""
def full_build(
self, abstract_designs: Any, options: BuildOptions | None = None
) -> Any:
plan = self.plan(abstract_designs, options=options)
return self.execute(plan, options=options)

Expand All @@ -86,10 +85,13 @@ def full_build(
sbol_doc: Any = None,
**kwargs: Any,
) -> Any:
"""Module-level full-build entry point for the public API skeleton."""
compiler_options = options or BuildOptions()

if collections is not None or sbh_registry is not None or auth_token is not None or sbol_doc is not None:
if (
collections is not None
or sbh_registry is not None
or auth_token is not None
or sbol_doc is not None
):
compiler = BuildCompiler.from_synbiohub(
collections=collections,
sbh_registry=sbh_registry,
Expand All @@ -105,11 +107,11 @@ def full_build(
else:
compiler = BuildCompiler(
inventory=inventory,
sbol_document=sbol_document,
planner=planner,
executor=executor,
adapters=adapters,
options=compiler_options,
**kwargs,
)

return compiler.full_build(abstract_designs, options=compiler_options)
7 changes: 6 additions & 1 deletion src/buildcompiler/execution/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
"""Package scaffolding for clean architecture."""
"""Execution package exports."""

from .context import BuildContext
from .executor import FullBuildExecutor

__all__ = ["BuildContext", "FullBuildExecutor"]
20 changes: 20 additions & 0 deletions src/buildcompiler/execution/context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Execution context contract for full-build orchestration."""

from __future__ import annotations

from dataclasses import dataclass
from typing import Any

from buildcompiler.inventory import Inventory
from buildcompiler.sbol import SbolResolver


@dataclass
class BuildContext:
sbol: SbolResolver
inventory: Inventory
build_document: Any
options: Any
adapters: Any = None
graph: Any = None
logger: Any = None
Loading
Loading