Skip to content

Fix pipeline module alignment and run_likelihood hang#1

Draft
Copilot wants to merge 26 commits intomainfrom
copilot/add-basic-ui-infrastructure
Draft

Fix pipeline module alignment and run_likelihood hang#1
Copilot wants to merge 26 commits intomainfrom
copilot/add-basic-ui-infrastructure

Conversation

Copy link

Copilot AI commented Mar 3, 2026

Pipeline module boxes were left-aligned, causing connectors to be diagonal when modules had different widths. Running a likelihood evaluation could hang indefinitely due to cosmosis child processes keeping a pipe write-end alive.

Pipeline module centre alignment (pipeline.js)

Added _modLeft(module) helper that offsets each module's left edge so all boxes share a single centre x:

_modLeft(module) {
  return this._modX() + (this._maxModWidth() - this._moduleBoxWidth(module.name)) / 2;
}
  • _appendModule, _appendPorts, _appendSourceOutputBoxes, _computeSourceOutputPositions, _appendPortEdges — all updated to use _modLeft(module) for the module's left edge
  • _appendConnections — simplified to a single cx = _modX() + maxModWidth/2 for both endpoints → perfectly vertical arrows

Fix run_likelihood hang (worker.py)

_FdCapture uses a pipe + drain thread. CosmoSIS spawns child processes (OpenMP, external programs) that inherit the pipe write end; when the parent restores stdout/stderr the children keep the write end alive, so the drain thread never sees EOF and the worker blocks.

  • run_likelihood: replaced _FdCapture with new _FdDevNull — redirects fd 1/2 to /dev/null instead of a pipe. Writes are instant and non-blocking; child fd inheritance is harmless. The captured text was unused on the success path anyway.
  • _FdCapture (still used in prepare_pipeline): saves self._r, reduces initial join timeout to 5 s, then force-closes the pipe read end to unblock the drain thread, with a final 3 s join — worst-case delay is now ~8 s instead of indefinite.
Original prompt

I'd like to create in this new new repo and package that provides a GUI to my python package CosmoSIS, which is in the repository cosmosis-developers/cosmosis.

I'd like the interface to be in a web browser, so all the UI logic to be in javascript. CosmoSIS is in python, and I'd like to use flask with websockets to do the communication between the two.

To start with let's do that basic infrastructure, and try out UI idea.s

I'd like there to be a tab bar at the top of the main UI page with different contents that we will work on one-by-one. To start with I'd like to work on the first tab, called "Pipeline". As a placeholder, please add other tabs called "Results", "Sampling" and "Campaign", but they can be empty for now.

So first we can design the first tab, "Pipeline". This main area of this tab should be a canvas which will display a representation of a workflow which is a sequence of "modules" that are to be run. Each module has some inputs and some outputs which should be displayed like flow chart items flowing into and out of the module when the user clicks on the module.

The python side will be supplying the list of available modules and their inputs and outputs, but for now should just supply some placeholders.

For the inputs that are displayed when the user clicks, the corresponding earlier module that created them as an output should also show as an edge on the chart.

You can use any open source library you want for the chart, or just roll your own, whichever suits better.

The canvas should initially have one single module in, called "Sampler", which will always be present and can't be removed.

In a sidebar on the left we will display a library of components that the user can drag onto the canvas. These components form a linear sequence, so when a user drags them in they should slot into the pipeline between any existing elements. The linear sequence should be evenly spaced.

There should also be a sidebar on the right that only opens when the user clicks on a module, either in the left sidebar or in the main canvas. We'll work on that later.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…ation

Co-authored-by: joezuntz <220537+joezuntz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add basic UI infrastructure for CosmoSIS web app Add CosmoSIS GUI v2: Flask/WebSocket backend + interactive pipeline canvas Mar 3, 2026
Copilot stopped work on behalf of joezuntz due to an error March 3, 2026 17:53
… on drop

Co-authored-by: joezuntz <220537+joezuntz@users.noreply.github.com>
Copilot AI changed the title Add CosmoSIS GUI v2: Flask/WebSocket backend + interactive pipeline canvas Vertical pipeline layout with left/right bezier arcs and deselect on drop Mar 3, 2026
Co-authored-by: joezuntz <220537+joezuntz@users.noreply.github.com>
Copilot AI changed the title Vertical pipeline layout with left/right bezier arcs and deselect on drop Module library categories, canvas drag-to-reorder, and correct arc source tracing Mar 3, 2026
…r and syntax error

Co-authored-by: joezuntz <220537+joezuntz@users.noreply.github.com>
Copilot AI changed the title Module library categories, canvas drag-to-reorder, and correct arc source tracing Ingest modules from cosmosis-standard-library; categories collapsed by default Mar 4, 2026
Co-authored-by: joezuntz <220537+joezuntz@users.noreply.github.com>
Copilot AI changed the title Ingest modules from cosmosis-standard-library; categories collapsed by default Module library ingestion, visual canvas improvements, expandable ports, and params form Mar 4, 2026
…ne button

Co-authored-by: joezuntz <220537+joezuntz@users.noreply.github.com>
Copilot AI changed the title Module library ingestion, visual canvas improvements, expandable ports, and params form Visual tweaks, expandable port sections, params form, server-side library scan, and CosmoSIS INI pipeline loading Mar 4, 2026
Copilot AI changed the title Fix per-module setup output splitting via OS-level fd capture Fix per-module setup output splitting and show actual DataBlock I/O after pipeline run Mar 9, 2026
…responsive UI

Co-authored-by: joezuntz <220537+joezuntz@users.noreply.github.com>
Copilot AI changed the title Fix per-module setup output splitting and show actual DataBlock I/O after pipeline run Show actual DataBlock I/O per module after pipeline run; colour modules green on success Mar 9, 2026
Co-authored-by: joezuntz <220537+joezuntz@users.noreply.github.com>
Copilot AI changed the title Show actual DataBlock I/O per module after pipeline run; colour modules green on success Results tab, pipeline status indicators, and CWD auto-scan Mar 10, 2026
Co-authored-by: joezuntz <220537+joezuntz@users.noreply.github.com>
Copilot AI changed the title Results tab, pipeline status indicators, and CWD auto-scan Fix Results tab layout and section expand Mar 10, 2026
…b sections are not empty

Co-authored-by: joezuntz <220537+joezuntz@users.noreply.github.com>
Copilot AI changed the title Fix Results tab layout and section expand Fix Results tab layout and empty sections Mar 10, 2026
…ion, placeholder fix, pipeline connector centering

Co-authored-by: joezuntz <220537+joezuntz@users.noreply.github.com>
Copilot AI changed the title Fix Results tab layout and empty sections Results tab: two-column Plotly layout, axis selection, log-scale toggles, pipeline connector alignment Mar 10, 2026
- pipeline.js: add _modLeft(module) helper; all module boxes are now
  horizontally centred at _modX() + maxModWidth/2.  Update _appendModule,
  _appendPorts, _appendSourceOutputBoxes, _computeSourceOutputPositions,
  and _appendPortEdges to use the per-module left edge.  Restore
  _appendConnections to use a single shared centre x → perfectly vertical
  connecting arrows.

- worker.py: replace _FdCapture with _FdDevNull in run_likelihood.
  Cosmosis pipelines can spawn child processes that keep the pipe write
  end open indefinitely, causing the drain thread to never see EOF.
  Since the captured text is unused on the success path, _FdDevNull
  (redirects to /dev/null, no drain thread, no blocking) is sufficient.
  Also harden _FdCapture for prepare_pipeline: save self._r, reduce
  initial join timeout to 5 s, then force-close the read end to unblock
  the drain thread if it is still alive.

Co-authored-by: joezuntz <220537+joezuntz@users.noreply.github.com>
Copilot AI changed the title Results tab: two-column Plotly layout, axis selection, log-scale toggles, pipeline connector alignment Fix pipeline module alignment and run_likelihood hang Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants