portals
portals copied to clipboard
The logger always prints the same TaskId
The logger will currently always log the same TaskId for all tasks in a workflow. The following example in the playground shows this error, in which the first and second logger are in different tasks, yet print the same taskid:
var builder = PortalsJS.ApplicationBuilder("rangeFilter")
var _ = builder.workflows
.source(builder.generators.fromRange(0, 1024, 8).stream)
.logger()
.filter(x => x % 2 == 0)
.logger()
.sink()
.freeze()
var rangeFilter = builder.build()
var system = PortalsJS.System()
system.launch(rangeFilter)
system.stepUntilComplete()
The problem is that the TaskExecutor initializes a single shared execution context for all tasks in the workflow (for the interpreter) https://github.com/portals-project/portals/blob/main/core/src/main/scala/portals/runtime/executor/TaskExecutorImpl.scala#L22; and this is then only assigned once lazily https://github.com/portals-project/portals/blob/main/core/src/main/scala/portals/application/task/TaskContextImpl.scala#L38.