Skip to content

Commit

Permalink
Show compile progress (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
ducky64 authored May 23, 2024
1 parent 7cb9afb commit e358673
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
15 changes: 8 additions & 7 deletions src/main/scala/edg_ide/runner/CompileProcessHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,7 @@ class CompileProcessHandler(
s"Using interpreter from configured SDK '$sdkName': $pythonCommand\n",
ConsoleViewContentType.LOG_INFO_OUTPUT
)
println(pythonPaths)
val pythonInterface =
new LoggingPythonInterface(console, pythonCommand, pythonPaths)
val pythonInterface = new LoggingPythonInterface(console, pythonCommand, pythonPaths)
pythonInterfaceOpt = Some(pythonInterface)

(pythonInterface.getProtoVersion() match {
Expand Down Expand Up @@ -357,8 +355,7 @@ class CompileProcessHandler(
// this can be skipped - library elements can be built dynamically as they are used during compile
runFailableStageUnit("rebuild libraries", indicator, Some(0.0f)) {
def rebuildProgressFn(library: ref.LibraryPath, index: Int, total: Int): Unit = {
// this also includes requests that hit cache
indicator.setFraction(index.toFloat / total)
indicator.setFraction(index.toFloat / total) // this also includes requests that hit cache
}

val designModule = options.designName.split('.').init.mkString(".")
Expand All @@ -367,9 +364,13 @@ class CompileProcessHandler(
f"${indexed.size} elements"
}

val (compiled, compiler, refinements) = runRequiredStage("compile", indicator) {
val (compiled, compiler, refinements) = runRequiredStage("compile", indicator, Some(0.0f)) {
def compileProgressFn(progress: Float): Unit = {
indicator.setFraction(progress)
}

val designType = ElemBuilder.LibraryPath(options.designName)
val output = EdgCompilerService(project).compile(designType)
val output = EdgCompilerService(project).compile(designType, Some(compileProgressFn))
(output, "")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object CompilerErrorNodeBase {
}

private lazy val all: (String, String, Seq[CompilerErrorNodeBase]) = err match {
case CompilerError.Unelaborated(ElaborateRecord.Block(path), deps) =>
case CompilerError.Unelaborated(ElaborateRecord.Block(path, _), deps) =>
("Unelaborated Block", path.toString, deps.toSeq.map(elaborateRecordToDetailNode))
case CompilerError.Unelaborated(ElaborateRecord.Link(path), deps) =>
("Unelaborated Link", path.toString, deps.toSeq.map(elaborateRecordToDetailNode))
Expand Down
12 changes: 10 additions & 2 deletions src/main/scala/edg_ide/ui/EdgCompilerService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,23 @@ class EdgCompilerService(project: Project)

// Compiles a top level design
// progressFn is called (by compiler hook) for each compiler elaborate record
def compile(designType: ref.LibraryPath): (schema.Design, Compiler, edgrpc.Refinements) = {
def compile(
designType: ref.LibraryPath,
progressFn: Option[Float => Unit] = None
): (schema.Design, Compiler, edgrpc.Refinements) = {
val (block, refinements) = EdgCompilerService(project).pyLib
.getDesignTop(designType)
.mapErr(msg => s"invalid top-level design: $msg")
.get // TODO propagate Errorable
val design = schema.Design(contents = Some(block))

val compiler =
new Compiler(design, EdgCompilerService(project).pyLib, refinements = Refinements(refinements))
new Compiler(
design,
EdgCompilerService(project).pyLib,
refinements = Refinements(refinements),
progressFn = progressFn
)
(compiler.compile(), compiler, refinements)
}

Expand Down

0 comments on commit e358673

Please sign in to comment.