-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate vj-gene-usage onto structurer + BlockModelV3 #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d796b08
chore: migrate vj-gene-usage onto block-tools structurer + SDK upgrade
vadimpiven 83f4258
feat: migrate vj-gene-usage model to BlockModelV3
vadimpiven 135171f
chore: add changeset for structurer + V3 migration
vadimpiven af6a0bd
refactor: address review — don't leak legacy upgrader types
vadimpiven File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| "@platforma-open/milaboratories.vj-usage.model": minor | ||
| "@platforma-open/milaboratories.vj-usage.ui": minor | ||
| "@platforma-open/milaboratories.vj-usage.workflow": patch | ||
| "@platforma-open/milaboratories.vj-usage": minor | ||
| --- | ||
|
|
||
| Migrate onto the block-tools structurer (full SDK upgrade: model/ui-vue 1.79.14, | ||
| workflow-tengo 6.6.3, tengo-builder 4.0.8) and BlockModelV3. | ||
|
|
||
| Persisted state is preserved via the legacy upgrader. UI bindings move to | ||
| `app.model.data`. The three plot view states, `weightedFlag`, and the derived | ||
| block label are now UI-only and no longer stale the block; only the dataset, | ||
| allele/gene toggle, single-cell chain, and custom block label do. Graphs remain | ||
| the standard `<GraphMaker>` component. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"version":1} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,3 @@ | ||
| { | ||
| "vitest.disableWorkspaceWarning": true, | ||
| "editor.defaultFormatter": "dbaeumer.vscode-eslint", | ||
| "[typescript]": { | ||
| "editor.defaultFormatter": "dbaeumer.vscode-eslint" | ||
| }, | ||
| "[vue]": { | ||
| "editor.defaultFormatter": "dbaeumer.vscode-eslint" | ||
| }, | ||
| "cSpell.words": [ | ||
| "datasource", | ||
| "pframe", | ||
| "prerun" | ||
| ], | ||
| "editor.codeActionsOnSave": { | ||
| "source.fixAll.eslint": "always" | ||
| }, | ||
| "eslint.enable": true, | ||
| "eslint.format.enable": true | ||
| "typescript.tsdk": "node_modules/typescript/lib" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,6 @@ | ||
| export {}; | ||
| declare const blockSpec: { | ||
| type: "dev-v2"; | ||
| folder: string; | ||
| }; | ||
|
|
||
| export { blockSpec }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,8 @@ | ||
| export {}; | ||
| const blockSpec = { | ||
| type: "dev-v2", | ||
| folder: __dirname, | ||
| }; | ||
|
|
||
| module.exports = { | ||
| blockSpec, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "extends": ["node_modules/@milaboratories/ts-builder/configs/oxfmt.json"], | ||
| "ignorePatterns": ["dist", "coverage", "CHANGELOG.md"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "extends": ["node_modules/@milaboratories/ts-builder/dist/configs/oxlint-block-model.json"] | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import type { GraphMakerState } from "@milaboratories/graph-maker"; | ||
| import { DataModelBuilder } from "@platforma-sdk/model"; | ||
| import { getDefaultBlockLabel } from "./label"; | ||
| import type { BlockData, LegacyBlockArgs, LegacyUiState } from "./types"; | ||
|
|
||
| const usagePlot = (title: string, currentTab: GraphMakerState["currentTab"]): GraphMakerState => ({ | ||
| title, | ||
| template: "heatmapClustered", | ||
| currentTab, | ||
| layersSettings: { heatmapClustered: { normalizationDirection: null } }, | ||
| }); | ||
|
|
||
| const initData = (): BlockData => ({ | ||
| datasetRef: undefined, | ||
| scChain: "A", | ||
| allele: false, | ||
| defaultBlockLabel: getDefaultBlockLabel({ allele: false, isSingleCell: false }), | ||
| customBlockLabel: "", | ||
| weightedFlag: true, | ||
| vUsagePlotState: usagePlot("V Usage", "settings"), | ||
| jUsagePlotState: usagePlot("J Usage", null), | ||
| vjUsagePlotState: usagePlot("V/J Usage", null), | ||
| }); | ||
|
|
||
| export const blockDataModel = new DataModelBuilder() | ||
| .from<BlockData>("v1") | ||
| // V1 split analysis params + block labels across `args`; the three plot states | ||
| // and `weightedFlag` lived under `uiState`. Fold both into unified `data`. | ||
| .upgradeLegacy<LegacyBlockArgs, LegacyUiState>(({ args, uiState }) => { | ||
| const allele = args?.allele ?? false; | ||
| return { | ||
| datasetRef: args?.datasetRef, | ||
| scChain: args?.scChain ?? "A", | ||
| allele, | ||
| defaultBlockLabel: | ||
| args?.defaultBlockLabel ?? getDefaultBlockLabel({ allele, isSingleCell: false }), | ||
| customBlockLabel: args?.customBlockLabel ?? "", | ||
| weightedFlag: uiState?.weightedFlag ?? true, | ||
| vUsagePlotState: uiState?.vUsagePlotState ?? usagePlot("V Usage", "settings"), | ||
| jUsagePlotState: uiState?.jUsagePlotState ?? usagePlot("J Usage", null), | ||
| vjUsagePlotState: uiState?.vjUsagePlotState ?? usagePlot("V/J Usage", null), | ||
| }; | ||
| }) | ||
| .init(initData); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,122 +1,72 @@ | ||
| import type { GraphMakerState } from '@milaboratories/graph-maker'; | ||
| import type { InferOutputsType, PlRef } from '@platforma-sdk/model'; | ||
| import { BlockModel, createPFrameForGraphs } from '@platforma-sdk/model'; | ||
| import { getDefaultBlockLabel } from './label'; | ||
|
|
||
| export type BlockArgs = { | ||
| defaultBlockLabel: string; | ||
| customBlockLabel: string; | ||
| datasetRef?: PlRef; | ||
| scChain?: string; | ||
| allele?: boolean; | ||
| }; | ||
|
|
||
| export type UiState = { | ||
| weightedFlag: boolean; | ||
| vUsagePlotState: GraphMakerState; | ||
| jUsagePlotState: GraphMakerState; | ||
| vjUsagePlotState: GraphMakerState; | ||
| }; | ||
|
|
||
| export const model = BlockModel.create() | ||
|
|
||
| .withArgs<BlockArgs>({ | ||
| defaultBlockLabel: getDefaultBlockLabel({ | ||
| allele: false, | ||
| isSingleCell: false, | ||
| }), | ||
| customBlockLabel: '', | ||
| scChain: 'A', | ||
| allele: false, | ||
| import type { InferOutputsType } from "@platforma-sdk/model"; | ||
| import { BlockModelV3, createPFrameForGraphs } from "@platforma-sdk/model"; | ||
| import { blockDataModel } from "./dataModel"; | ||
| import type { BlockArgs } from "./types"; | ||
|
|
||
| export { getDefaultBlockLabel } from "./label"; | ||
| export { blockDataModel } from "./dataModel"; | ||
| export type { BlockArgs, BlockData } from "./types"; | ||
|
|
||
| export const platforma = BlockModelV3.create(blockDataModel) | ||
| .args<BlockArgs>((data) => { | ||
| if (data.datasetRef === undefined) throw new Error("Dataset is required"); | ||
|
vadimpiven marked this conversation as resolved.
|
||
| return { | ||
| datasetRef: data.datasetRef, | ||
| scChain: data.scChain, | ||
| allele: data.allele, | ||
| customBlockLabel: data.customBlockLabel, | ||
| }; | ||
| }) | ||
|
|
||
| .withUiState<UiState>({ | ||
| weightedFlag: true, | ||
| vUsagePlotState: { | ||
| title: 'V Usage', | ||
| template: 'heatmapClustered', | ||
| currentTab: 'settings', | ||
| layersSettings: { | ||
| heatmapClustered: { | ||
| normalizationDirection: null, | ||
| .output("datasetOptions", (ctx) => | ||
| ctx.resultPool.getOptions( | ||
| [ | ||
| { | ||
| axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/clonotypeKey" }], | ||
| annotations: { "pl7.app/isAnchor": "true" }, | ||
| }, | ||
| }, | ||
| }, | ||
| jUsagePlotState: { | ||
| title: 'J Usage', | ||
| template: 'heatmapClustered', | ||
| currentTab: null, | ||
| layersSettings: { | ||
| heatmapClustered: { | ||
| normalizationDirection: null, | ||
| }, | ||
| }, | ||
| }, | ||
| vjUsagePlotState: { | ||
| title: 'V/J Usage', | ||
| template: 'heatmapClustered', | ||
| currentTab: null, | ||
| layersSettings: { | ||
| heatmapClustered: { | ||
| normalizationDirection: null, | ||
| { | ||
| axes: [{ name: "pl7.app/sampleId" }, { name: "pl7.app/vdj/scClonotypeKey" }], | ||
| annotations: { "pl7.app/isAnchor": "true" }, | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| .argsValid((ctx) => ctx.args.datasetRef !== undefined) | ||
|
|
||
| .output('datasetOptions', (ctx) => | ||
| ctx.resultPool.getOptions([{ | ||
| axes: [ | ||
| { name: 'pl7.app/sampleId' }, | ||
| { name: 'pl7.app/vdj/clonotypeKey' }, | ||
| ], | ||
| annotations: { 'pl7.app/isAnchor': 'true' }, | ||
| }, { | ||
| axes: [ | ||
| { name: 'pl7.app/sampleId' }, | ||
| { name: 'pl7.app/vdj/scClonotypeKey' }, | ||
| ], | ||
| annotations: { 'pl7.app/isAnchor': 'true' }, | ||
| }], | ||
| { | ||
| // suppress native label of the column (e.g. "Number of Reads") to show only the dataset label | ||
| label: { includeNativeLabel: false }, | ||
| }), | ||
| { | ||
| // suppress native label of the column (e.g. "Number of Reads") to show only the dataset label | ||
| label: { includeNativeLabel: false }, | ||
| }, | ||
| ), | ||
| ) | ||
|
|
||
| .output('datasetSpec', (ctx) => { | ||
| if (ctx.args.datasetRef === undefined) { | ||
| .output("datasetSpec", (ctx) => { | ||
| if (ctx.data.datasetRef === undefined) { | ||
| return undefined; | ||
| } | ||
|
vadimpiven marked this conversation as resolved.
|
||
|
|
||
| return ctx.resultPool.getPColumnSpecByRef(ctx.args.datasetRef); | ||
| return ctx.resultPool.getPColumnSpecByRef(ctx.data.datasetRef); | ||
| }) | ||
|
|
||
| .outputWithStatus('pf', (ctx) => { | ||
| const pCols = ctx.outputs?.resolve('pf')?.getPColumns(); | ||
| .outputWithStatus("pf", (ctx) => { | ||
| const pCols = ctx.outputs?.resolve("pf")?.getPColumns(); | ||
| if (pCols === undefined) { | ||
| return undefined; | ||
| } | ||
|
|
||
| return createPFrameForGraphs(ctx, pCols); | ||
| }) | ||
|
|
||
| .output('isRunning', (ctx) => ctx.outputs?.getIsReadyOrError() === false) | ||
| .output("isRunning", (ctx) => ctx.outputs?.getIsReadyOrError() === false) | ||
|
|
||
| .title(() => 'V/J Usage') | ||
| .title(() => "V/J Usage") | ||
|
|
||
| .subtitle((ctx) => ctx.args.customBlockLabel || ctx.args.defaultBlockLabel) | ||
| .subtitle((ctx) => ctx.data.customBlockLabel || ctx.data.defaultBlockLabel) | ||
|
|
||
| .sections((_) => [ | ||
| { type: 'link', href: '/', label: 'V Gene Usage' }, | ||
| { type: 'link', href: '/jUsage', label: 'J Gene Usage' }, | ||
| { type: 'link', href: '/vjUsage', label: 'V/J Gene Usage' }, | ||
| .sections(() => [ | ||
| { type: "link" as const, href: "/" as const, label: "V Gene Usage" }, | ||
| { type: "link" as const, href: "/jUsage" as const, label: "J Gene Usage" }, | ||
| { type: "link" as const, href: "/vjUsage" as const, label: "V/J Gene Usage" }, | ||
| ]) | ||
|
|
||
| .done(2); | ||
|
|
||
| export type BlockOutputs = InferOutputsType<typeof model>; | ||
| .done(); | ||
|
|
||
| export { getDefaultBlockLabel } from './label'; | ||
| export type Platforma = typeof platforma; | ||
| export type BlockOutputs = InferOutputsType<typeof platforma>; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.