Skip to content

Generate alternatives#113

Open
aaronstrachardt wants to merge 26 commits into
Workflomics:mainfrom
aaronstrachardt:generate-alternatives
Open

Generate alternatives#113
aaronstrachardt wants to merge 26 commits into
Workflomics:mainfrom
aaronstrachardt:generate-alternatives

Conversation

@aaronstrachardt

Copy link
Copy Markdown

Overview

This PR adds the user interface and client-side logic for the "Alternative Workflows" prototype component. It allows users to upload a CWL file, interact with it as a graph, and generate structural alternatives. It is designed to work together with the new /alternatives/parse endpoint introduced in the corresponding restape PR.

Changes

  • Added the Alternative Workflows component using ReactFlow for the graph visualization and dagre for automated top-down layouting
  • Implemented state management (using MobX) to handle cyclic node and edge interactions (Keep/Vary/Ban and Chain/Break)
  • Added logic (generateApeConfig) to translate the visual UI markers directly into APE JSON constraints on the client side
  • Introduced a static mapping (LABEL_TO_TOOL_IDS) to resolve discrepancies between tool labels and EDAM taxonomy IDs
  • Added a post-processing filter that automatically removes generated candidates that are structurally identical to the input workflow
  • Implemented a "Show JSON" modal so users can inspect the generated APE configuration
  • Added unit tests (Jest) for the state mapping and filtering logic
alternatives_upload alternatives_main alternatives_json

Testing

The code has been tested via the added unit tests in Jest. I also tested the complete end-to-end flow manually on my local machine by running this branch against the updated restape backend branch.

Checklist

  • Code follows project standards.
  • Self-reviewed and commented where needed.
  • Documentation updated if needed.
  • No new warnings or errors.

Translates node status (Keep/Ban/Vary) and edge status (chain/break)
into APE constraint objects and assembles the full synthesis config
JSON including I/O EDAM tuples, tool taxonomy paths, and generation
parameters.
…e initialization

Handles CWL file upload via POST /alternatives/parse, builds the
ReactFlow graph from the parsed DAG, and initialises all tool nodes
to Keep status (§4.3 conservative strategy). Node clicks cycle through
Keep/Vary/Ban; edge clicks toggle chain/break constraints.
… modal

Shows active Keep/Ban/Chain/Break constraints, APE synthesis parameters
(min/max length, timeout, solutions), a generate button with loading
state, and a modal to inspect the generated APE config JSON.
…w, and synthesis

Shows a drag-and-drop CWL upload zone before a file is loaded, then
switches to a ReactFlow graph with a filename pill overlay. Builds the
APE synthesis config from the current constraint state and navigates
to /explore/results after successful synthesis.
…aStore

Accepts a pre-built APE config object and an optional input tool
sequence string. After synthesis, filters out any solution whose
descriptive_name matches the input workflow's tool sequence to ensure
all returned alternatives genuinely differ from the uploaded workflow.
Call GET /ape/alternatives/warm when GenerateAlternatives mounts.
Show a full-page spinner while the backend loads the EDAM ontology;
show an error state if loading fails. Upload zone renders only after
warm-up completes.
EDAM loading is handled transparently by the backend on the first
/parse request. No explicit frontend warm-up needed.
APE generates step names from a tool's label, but use_m/not_use_m/connected_op
constraints must reference the taxonomy id, which differs for some tools
(e.g. mzRecal -> mzrecal1, Sage -> Sage-proteomics, idconvert -> two ids).
Add LABEL_TO_TOOL_IDS to map each label to its id(s); unknown labels fall back
to the label itself.
Convert runSynthesisWithRawConfig to async/await, retry the synthesis call
once on failure (1.5s delay), and include the response body in the error so
transient backend issues surface clearly. Add ExploreDataStore tests for the
post-filtering of identical tool sequences.
Two-line tool cards with a clipped accent bar for status; compact dashed
data nodes for inputs/outputs. Dagre now uses separate dimensions per node
type (tool 210x70, data 180x38) for correct automatic layout.
InfoTooltip renders configurable contextual help on the graph canvas, the
active-constraints panel, and the APE-settings panel. The Show-JSON modal
highlights the generated config without an external dependency. Canvas height
now scales with the viewport.
@aaronstrachardt

Copy link
Copy Markdown
Author

@eladrion And here is the corresponding PR for the frontend. Tagging you directly again due to missing assignment permissions.

@eladrion eladrion self-requested a review June 29, 2026 09:53
Comment thread src/components/explore/GenerationResults.tsx
Comment thread database/postgrest.conf Outdated
@aaronstrachardt

Copy link
Copy Markdown
Author

@eladrion Thanks for pointing that out! Fixed both in the latest commits:

@eladrion

Copy link
Copy Markdown
Contributor

@aaronstrachardt No worries, that's what reviews are for. I looked a bit into the RestApe PR and left you comments. When we have streamlined that one a bit, I can test on the internal instance.

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