Skip to content

Phase 2: SAM_Multitasker assessment and background job-runner design (Tas COM/STA + licence constraints) #234

Open

Description

@michaldengusiak

Parent: #227

Goal

Decide how to reuse SAM_Multitasker for background jobs, progress, cancellation and parallel simulation, and design the job runner. Tas COM threading and licence limits must be preserved.

Findings so far (SAM_Multitasker sow/2026-Q4, read-only review)

  • It is a Roslyn C# script runner: Multitasker(code, mode).Run(inputs, maxConcurrency), with Series and Parallel modes. The core targets netstandard2.0 and the Grasshopper projects target net8.0-windows. SAM.Analytical.Multitasker is an empty stub.
  • It has no STA/COM handling, cancellation, progress, process isolation or licence guard. Its bundled scripts call Tas RunWorkflow, and it has no OpenStudio scripts.
  • Defects found:
    • Multitasker.cs:114 passes an async lambda to Parallel.For, so the work runs as async void and Run can return before it finishes.
    • Multitasker.cs:159 throws away the return value of scriptOptions.AddImports(imports).
    • The Grasshopper SAMMultitaskerRun component blocks on task.Result.
  • SAM_UI's SAMAnalyticalMultitaskerWorkflow does not use SAM_Multitasker. It calls Modify.RunWorkflow (Parallel.For, ProcessorCount-1, linked cancellation token), with no STA thread for Tas COM.
  • The Tas benchmark CLI runs WorkflowCalculator.Calculate on a dedicated STA thread with a timeout. That is the pattern to keep.

Scope

  • A decision record covering:
    • Reuse: what is reused as-is.
    • Fix: which defects are fixed in SAM_Multitasker, each through its own PR there.
    • Not used: what SAM_Multitasker is not used for.
    • Batches: whether its script/input model still serves parametric batches.
  • Job-runner design:
    • one STA thread per Tas job;
    • a Tas concurrency cap from licence count or configuration;
    • OpenStudio jobs run as separate processes, as openstudio.exe already does;
    • a shared CPU budget;
    • cooperative cancellation for Tas, process-tree kill for OpenStudio;
    • IProgress routing;
    • a job manifest in each run folder;
    • frozen-snapshot inputs, so a run is never fed a live model.
  • Review the existing RunWorkflow Parallel.For path for the missing STA thread, and record a risk or defect if Tas COM needs one.

Depends on

G3 (#233) before implementation. The design work can start earlier.

Acceptance criteria

The decision record is committed and approved by the owner. The design states what is tested on CI and what needs a local run with Tas licences.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions