@platforma-sdk/model 1.94.0 → 1.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -17,6 +17,7 @@ const require_service_bridge = require("./services/service_bridge.cjs");
17
17
  const require_get_services = require("./services/get_services.cjs");
18
18
  require("./services/index.cjs");
19
19
  const require_api = require("./render/api.cjs");
20
+ const require_experiment_design = require("./render/experiment_design.cjs");
20
21
  require("./render/index.cjs");
21
22
  const require_plugin_model = require("./plugin_model.cjs");
22
23
  const require_version = require("./version.cjs");
@@ -158,6 +159,7 @@ exports.deriveColumnValueOptions = require_column_values.deriveColumnValueOption
158
159
  exports.deriveDataFromStorage = require_block_storage.deriveDataFromStorage;
159
160
  exports.deriveDistinctLabels = require_derive_distinct_labels.deriveDistinctLabels;
160
161
  exports.deriveDistinctTooltips = require_derive_distinct_tooltips.deriveDistinctTooltips;
162
+ exports.deriveExperimentDesignOptions = require_experiment_design.deriveExperimentDesignOptions;
161
163
  exports.deriveLabelledColumnValueOptions = require_column_values.deriveLabelledColumnValueOptions;
162
164
  exports.deriveLabels = require_label.deriveLabels;
163
165
  exports.deriveRecipeOptions = require_utils.deriveRecipeOptions;
@@ -166,6 +168,7 @@ exports.discoverTableColumnSnaphots = require_discoverColumns.discoverTableColum
166
168
  exports.distillFilterSpec = require_distill.distillFilterSpec;
167
169
  exports.downgradeCfgOrLambda = require_normalization.downgradeCfgOrLambda;
168
170
  exports.enrichCompatible = require_axes.enrichCompatible;
171
+ exports.experimentDesign = require_experiment_design.experimentDesign;
169
172
  exports.extractConfig = require_normalization.extractConfig;
170
173
  exports.filterDataInfoEntries = require_axis_filtering.filterDataInfoEntries;
171
174
  exports.filterMatchesToOptions = require_filter_discovery.filterMatchesToOptions;
@@ -218,6 +221,7 @@ exports.isLeafColumn = require_utils.isLeafColumn;
218
221
  exports.isPColumnReady = require_pcolumn_data.isPColumnReady;
219
222
  exports.isPluginOutputKey = require_plugin_handle.isPluginOutputKey;
220
223
  exports.isSheetFixedToOneValue = require_tableParams.isSheetFixedToOneValue;
224
+ exports.listExperimentDesigns = require_experiment_design.listExperimentDesigns;
221
225
  exports.migrateBlockStorage = require_block_storage.migrateBlockStorage;
222
226
  exports.normalizeBlockStorage = require_block_storage.normalizeBlockStorage;
223
227
  exports.parsePColumnData = require_pcolumn_data.parsePColumnData;
package/dist/index.d.ts CHANGED
@@ -28,6 +28,7 @@ import { AxisLabelProvider, ColumnProvider, PColumnCollection, PColumnEntryUnive
28
28
  import { BlockRenderCtx, InferRenderFunctionReturn, PluginRenderCtx, RenderCtx, RenderCtxBase, RenderFunction, ResultPool, UniversalColumnOption, UnwrapFutureRef, finalizePColumnData } from "./render/api.js";
29
29
  import { PColumnKeyList, PColumnResourceMapData, PColumnResourceMapEntry, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, allPColumnsReady, convertOrParsePColumnData, getNumberOfRows, getPartitionKeysList, getUniquePartitionKeys, isPColumnReady, parsePColumnData, parseResourceMap } from "./render/util/pcolumn_data.js";
30
30
  import { filterDataInfoEntries } from "./render/util/axis_filtering.js";
31
+ import { ExperimentDesign, deriveExperimentDesignOptions, experimentDesign, listExperimentDesigns } from "./render/experiment_design.js";
31
32
  import "./render/index.js";
32
33
  import { PluginConfig, PluginData, PluginDataModel, PluginDataModelBuilder, PluginDataModelVersions, PluginFactory, PluginInstance, PluginModel, PluginOutputs, PluginParams, PluginPublicOutputs, PublicOutputFieldDef } from "./plugin_model.js";
33
34
  import { BlockModelInfo, InferArgsType, InferBlockState, InferBlockStatePatch, InferDataType, InferHrefType, InferOutputsType, InferPluginData, InferPluginNames, InferPluginUiEntries, InferUiState, Platforma, PlatformaApiVersion, PlatformaExtended, PlatformaFactory, PlatformaV1, PlatformaV2, PlatformaV3 } from "./platforma.js";
@@ -89,4 +90,4 @@ import "./services/index.js";
89
90
  import { getEnvironmentValue } from "./env_value.js";
90
91
  export * from "@milaboratories/pl-model-common";
91
92
  export * from "@milaboratories/pl-error-like";
92
- export { AccessorColumnsProvider, AccessorColumnsProviderImpl, type AccessorHandle, AndFilter, AnnotationFilter, AnnotationMode, AnnotationScript, AnnotationScript2, AnnotationScriptUi, AnnotationSpec, AnnotationSpecUi, AnnotationStep, AnnotationStepUi, AnyForm, ArrayColumnsProvider, type AxesVault, AxisLabelProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockApiV1, BlockApiV2, BlockConfig, BlockConfigV3, BlockConfigV4, BlockDefaultModelServices, BlockDefaultUiServices, BlockModelInfo, BlockModelV3, BlockRenderCtx, BlockServiceFlags, BlockStatePatch, type BlockStorage, BlockStorageFacade, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, type BlockStorageSchemaVersion, BuildDatasetOptions, CancelSubscription, Cfg, CfgAnd, CfgBlobContent, CfgBlobContentAsJson, CfgBlobContentAsString, CfgDownloadedBlobContent, CfgExtractArchiveAndGetURL, CfgFlatten, CfgGetFromCtx, CfgGetJsonField, CfgGetResourceField, CfgImmediate, CfgImportProgress, CfgIsEmpty, CfgIsolate, CfgLastLogs, CfgLogHandle, CfgMakeArray, CfgMakeObject, CfgMapArrayValues, CfgMapRecordValues, CfgMapResourceFields, CfgNot, CfgOnDemandBlobContent, CfgOr, CfgProgressLog, CfgProgressLogWithInfo, CfgResourceValueAsJson, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, type ColumnOrderRule, ColumnOverriddenRecipe, ColumnProvider, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, type ColumnVisibilityRule, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, type ColumnsDisplayOptions, ColumnsProvider, type ColumnsSelectorConfig, ColumnsSource, ColumnsSourceShorthand, CommonFieldTraverseOps, CommonTraversalOps, ConfigRenderLambda, ConfigRenderLambdaFlags, CurrentSdkInfo, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DataModel, DataModelBuilder, DatasetAxes, DatasetEnrichment, DatasetOption, DatasetSelection, DeriveHref, DeriveLabelsFormatters, DeriveLabelsOptions, DiscoveredRoot, Entry, ExpressionSpec, ExtractFunctionHandleReturn, type ExtractFutureRefType, FieldTraversalStep, FieldType, FilterMatchOptions, type FilterSpec, type FilterSpecLeaf, type FilterSpecNode, type FilterSpecOfType, type FilterSpecType, FilterSpecUi, FilterUi, FilterUiOfType, FilterUiType, FindFilterColumnsOptions, FormField, FutureRef, GetFieldStep, InferArgsType, InferBlockState, InferBlockStatePatch, InferDataType, InferFactoryData, InferFactoryModelServices, InferFactoryOutputs, InferFactoryParams, InferFactoryUiServices, InferHrefType, InferOutputsFromLambdas, InferOutputsType, InferPluginData, InferPluginHandle, InferPluginNames, InferPluginUiEntries, InferRenderFunctionReturn, InferUiState, IsNA, internal_d_exports as JsRenderInternal, type DeriveLabelsOptions as LabelDerivationOps, LinkerStep, Log10, MainAccessorName, type MigrateBlockStorageConfig, type MigrationFailure, type MigrationResult, type MigrationSuccess, type ModelServices, type MutateStoragePayload, NotFilter, NumericalComparisonFilter, OptionalPlResourceEntry, OrFilter, OutputError, PColumnCollection, type PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, PColumnKeyList, PColumnPredicate, PColumnResourceMapData, PColumnResourceMapEntry, PColumnUniversal, PColumnWithLabel, PFrameImpl, PTableKey, type PTableParamsV2, type ParamsInput, Patch, PatternFilter, PatternPredicate, PatternPredicateContainSubsequence, PatternPredicateEquals, type PlDataTableAxisMeta, type PlDataTableColumnMeta, type PlDataTableColumnsMeta, type PlDataTableFilterMeta, type PlDataTableFilterSpecLeaf, type PlDataTableFilters, type PlDataTableFiltersWithMeta, type PlDataTableGridStateCore, type PlDataTableModel, type PlDataTableSheet, type PlDataTableSheetState, type PlDataTableStateV2, type PlDataTableStateV2CacheEntry, type PlDataTableStateV2Normalized, PlMultiSequenceAlignmentColorSchemeOption, PlMultiSequenceAlignmentModel, PlMultiSequenceAlignmentSettings, PlMultiSequenceAlignmentWidget, PlResourceEntry, PlSelectionModel, type PlTableColumnIdJson, Platforma, PlatformaApiVersion, PlatformaExtended, PlatformaFactory, PlatformaSDKVersion, PlatformaV1, PlatformaV2, PlatformaV3, type PluginConfig, type PluginData, PluginDataModel, PluginDataModelBuilder, type PluginDataModelVersions, type PluginFactory, PluginFactoryLike, PluginHandle, PluginInstance, PluginModel, type PluginName, type PluginOutputs, type PluginParams, type PluginPublicOutputs, type PluginRecord, type PluginRegistry, PluginRenderCtx, PresentColumnValueOptionsModel, type PublicOutputFieldDef, QueryColumnId, QueryColumnIdAxis, QueryColumnIdColumn, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtx, RenderCtxBase, RenderFunction, ResolveModelServices, ResolveUiServices, ResourceTraversalOps, ResourceType, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, SdkInfo, ServiceProxy, SimplifiedPColumnSpec, SimplifiedUniversalPColumnEntry, SortedCumulativeSum, type Entry as SpecExtractorResult, type SpecQuery, SplitAxis, SplitByAxesOpts, StagingAccessorName, StdCtx, StdCtxArgsOnly, TooltipEntry, type Trace, type TraceEntry, TransformedColumn, TreeNodeAccessor, TypeField, TypeFieldRecord, TypeForm, TypeToLiteral, TypedConfig, TypedConfigOrConfigLambda, TypedConfigOrString, type UiServices, Unionize, UniversalColumnOption, UnwrapFutureRef, ValueRank, type VersionedData, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, type createPlDataTableOptionsV3, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, isSheetFixedToOneValue, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
93
+ export { AccessorColumnsProvider, AccessorColumnsProviderImpl, type AccessorHandle, AndFilter, AnnotationFilter, AnnotationMode, AnnotationScript, AnnotationScript2, AnnotationScriptUi, AnnotationSpec, AnnotationSpecUi, AnnotationStep, AnnotationStepUi, AnyForm, ArrayColumnsProvider, type AxesVault, AxisLabelProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockApiV1, BlockApiV2, BlockConfig, BlockConfigV3, BlockConfigV4, BlockDefaultModelServices, BlockDefaultUiServices, BlockModelInfo, BlockModelV3, BlockRenderCtx, BlockServiceFlags, BlockStatePatch, type BlockStorage, BlockStorageFacade, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, type BlockStorageSchemaVersion, BuildDatasetOptions, CancelSubscription, Cfg, CfgAnd, CfgBlobContent, CfgBlobContentAsJson, CfgBlobContentAsString, CfgDownloadedBlobContent, CfgExtractArchiveAndGetURL, CfgFlatten, CfgGetFromCtx, CfgGetJsonField, CfgGetResourceField, CfgImmediate, CfgImportProgress, CfgIsEmpty, CfgIsolate, CfgLastLogs, CfgLogHandle, CfgMakeArray, CfgMakeObject, CfgMapArrayValues, CfgMapRecordValues, CfgMapResourceFields, CfgNot, CfgOnDemandBlobContent, CfgOr, CfgProgressLog, CfgProgressLogWithInfo, CfgResourceValueAsJson, Column, ColumnData, ColumnDiscoveredRecipe, type ColumnFieldStatus, ColumnFilteredRecipe, ColumnOption, type ColumnOrderRule, ColumnOverriddenRecipe, ColumnProvider, ColumnRecipe, type ColumnRecipeId, type ColumnResolutionStatus, ColumnSource, ColumnValueOption, ColumnValueOptionsColumn, ColumnValueOptionsModel, type ColumnVisibilityRule, ColumnsCollection, ColumnsCollectionDeps, ColumnsCollectionImpl, type ColumnsDisplayOptions, ColumnsProvider, type ColumnsSelectorConfig, ColumnsSource, ColumnsSourceShorthand, CommonFieldTraverseOps, CommonTraversalOps, ConfigRenderLambda, ConfigRenderLambdaFlags, CurrentSdkInfo, DataColumn, DataColumnId, DataColumnImpl, DataColumnRecipe, DataColumnSource, DataModel, DataModelBuilder, DatasetAxes, DatasetEnrichment, DatasetOption, DatasetSelection, DeriveHref, DeriveLabelsFormatters, DeriveLabelsOptions, DiscoveredRoot, Entry, ExperimentDesign, ExpressionSpec, ExtractFunctionHandleReturn, type ExtractFutureRefType, FieldTraversalStep, FieldType, FilterMatchOptions, type FilterSpec, type FilterSpecLeaf, type FilterSpecNode, type FilterSpecOfType, type FilterSpecType, FilterSpecUi, FilterUi, FilterUiOfType, FilterUiType, FindFilterColumnsOptions, FormField, FutureRef, GetFieldStep, InferArgsType, InferBlockState, InferBlockStatePatch, InferDataType, InferFactoryData, InferFactoryModelServices, InferFactoryOutputs, InferFactoryParams, InferFactoryUiServices, InferHrefType, InferOutputsFromLambdas, InferOutputsType, InferPluginData, InferPluginHandle, InferPluginNames, InferPluginUiEntries, InferRenderFunctionReturn, InferUiState, IsNA, internal_d_exports as JsRenderInternal, type DeriveLabelsOptions as LabelDerivationOps, LinkerStep, Log10, MainAccessorName, type MigrateBlockStorageConfig, type MigrationFailure, type MigrationResult, type MigrationSuccess, type ModelServices, type MutateStoragePayload, NotFilter, NumericalComparisonFilter, OptionalPlResourceEntry, OrFilter, OutputError, PColumnCollection, type PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, PColumnKeyList, PColumnPredicate, PColumnResourceMapData, PColumnResourceMapEntry, PColumnUniversal, PColumnWithLabel, PFrameImpl, PTableKey, type PTableParamsV2, type ParamsInput, Patch, PatternFilter, PatternPredicate, PatternPredicateContainSubsequence, PatternPredicateEquals, type PlDataTableAxisMeta, type PlDataTableColumnMeta, type PlDataTableColumnsMeta, type PlDataTableFilterMeta, type PlDataTableFilterSpecLeaf, type PlDataTableFilters, type PlDataTableFiltersWithMeta, type PlDataTableGridStateCore, type PlDataTableModel, type PlDataTableSheet, type PlDataTableSheetState, type PlDataTableStateV2, type PlDataTableStateV2CacheEntry, type PlDataTableStateV2Normalized, PlMultiSequenceAlignmentColorSchemeOption, PlMultiSequenceAlignmentModel, PlMultiSequenceAlignmentSettings, PlMultiSequenceAlignmentWidget, PlResourceEntry, PlSelectionModel, type PlTableColumnIdJson, Platforma, PlatformaApiVersion, PlatformaExtended, PlatformaFactory, PlatformaSDKVersion, PlatformaV1, PlatformaV2, PlatformaV3, type PluginConfig, type PluginData, PluginDataModel, PluginDataModelBuilder, type PluginDataModelVersions, type PluginFactory, PluginFactoryLike, PluginHandle, PluginInstance, PluginModel, type PluginName, type PluginOutputs, type PluginParams, type PluginPublicOutputs, type PluginRecord, type PluginRegistry, PluginRenderCtx, PresentColumnValueOptionsModel, type PublicOutputFieldDef, QueryColumnId, QueryColumnIdAxis, QueryColumnIdColumn, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtx, RenderCtxBase, RenderFunction, ResolveModelServices, ResolveUiServices, ResourceTraversalOps, ResourceType, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, SdkInfo, ServiceProxy, SimplifiedPColumnSpec, SimplifiedUniversalPColumnEntry, SortedCumulativeSum, type Entry as SpecExtractorResult, type SpecQuery, SplitAxis, SplitByAxesOpts, StagingAccessorName, StdCtx, StdCtxArgsOnly, TooltipEntry, type Trace, type TraceEntry, TransformedColumn, TreeNodeAccessor, TypeField, TypeFieldRecord, TypeForm, TypeToLiteral, TypedConfig, TypedConfigOrConfigLambda, TypedConfigOrString, type UiServices, Unionize, UniversalColumnOption, UnwrapFutureRef, ValueRank, type VersionedData, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, type createPlDataTableOptionsV3, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveExperimentDesignOptions, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, experimentDesign, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, isSheetFixedToOneValue, listExperimentDesigns, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ import { buildServices, createServiceProxy } from "./services/service_bridge.js"
16
16
  import { getService } from "./services/get_services.js";
17
17
  import "./services/index.js";
18
18
  import { BlockRenderCtx, PluginRenderCtx, RenderCtxBase, ResultPool, finalizePColumnData } from "./render/api.js";
19
+ import { deriveExperimentDesignOptions, experimentDesign, listExperimentDesigns } from "./render/experiment_design.js";
19
20
  import "./render/index.js";
20
21
  import { PluginDataModel, PluginDataModelBuilder, PluginInstance, PluginModel } from "./plugin_model.js";
21
22
  import { CurrentSdkInfo, PlatformaSDKVersion } from "./version.js";
@@ -71,4 +72,4 @@ import { getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, g
71
72
  import { getEnvironmentValue } from "./env_value.js";
72
73
  export * from "@milaboratories/pl-model-common";
73
74
  export * from "@milaboratories/pl-error-like";
74
- export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockModelV3, BlockRenderCtx, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, Column, ColumnDiscoveredRecipe, ColumnFilteredRecipe, ColumnOverriddenRecipe, ColumnRecipe, ColumnsCollection, ColumnsCollectionImpl, ColumnsProvider, CurrentSdkInfo, DataColumn, DataColumnImpl, DataModel, DataModelBuilder, FutureRef, internal_exports as JsRenderInternal, MainAccessorName, OutputError, PColumnCollection, PFrameImpl, PlatformaSDKVersion, PluginDataModel, PluginDataModelBuilder, PluginInstance, PluginModel, PluginRenderCtx, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtxBase, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, StagingAccessorName, TreeNodeAccessor, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, isSheetFixedToOneValue, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
75
+ export { AccessorColumnsProvider, AccessorColumnsProviderImpl, ArrayColumnsProvider, BLOCK_SERVICE_FLAGS, BLOCK_STORAGE_FACADE_VERSION, BlockModelV3, BlockRenderCtx, BlockStorageFacadeCallbacks, BlockStorageFacadeHandles, Column, ColumnDiscoveredRecipe, ColumnFilteredRecipe, ColumnOverriddenRecipe, ColumnRecipe, ColumnsCollection, ColumnsCollectionImpl, ColumnsProvider, CurrentSdkInfo, DataColumn, DataColumnImpl, DataModel, DataModelBuilder, FutureRef, internal_exports as JsRenderInternal, MainAccessorName, OutputError, PColumnCollection, PFrameImpl, PlatformaSDKVersion, PluginDataModel, PluginDataModelBuilder, PluginInstance, PluginModel, PluginRenderCtx, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtxBase, ResultPool, ResultPoolColumnsProvider, ResultPoolColumnsProviderImpl, StagingAccessorName, TreeNodeAccessor, _ctxProvidersCache, allPColumnsReady, blockServiceNames, buildDatasetOptions, buildServices, collectDatasetAxes, collectLinkerColumns, collectLinkerIds, compileAnnotationScript, compileFilter, compileFilters, convertFilterSpecsToExpressionSpecs, convertFilterUiToExpressionImpl, convertFilterUiToExpressions, convertOrParsePColumnData, createBlockStorage, createColumnValueOptions, createDatasetSelection, createDefaultPTableParams, createPFrameForGraphs, createPeerLinkFinder, createPlDataTable, createPlDataTableSheet, createPlDataTableStateV2, createPlDataTableV2, createPlDataTableV3, createPlSelectionModel, createRowSelectionColumn, createServiceProxy, deriveAxisValuesLabels, deriveColumnOptions, deriveColumnValueOptions, deriveDataFromStorage, deriveDistinctLabels, deriveDistinctTooltips, deriveExperimentDesignOptions, deriveLabelledColumnValueOptions, deriveLabels, deriveRecipeOptions, describePeerLinks, discoverTableColumns as discoverTableColumnSnaphots, distillFilterSpec, downgradeCfgOrLambda, enrichCompatible, experimentDesign, extractConfig, filterDataInfoEntries, filterMatchesToOptions, filterSpecToSpecQueryExpr, finalizePColumnData, findFilterColumns, findPeerLinks, getAllRelatedColumns, getAvailableWithLinkersAxes, getAxisUniqueValues, getColumnOrAxisValueLabelsId, getColumnSpecById, getColumnUniqueValues, getColumnsFull, getCtxProviders, getEffectiveVisibility, getEnvironmentValue, getNumberOfRows, getOrderPriority, getPartitionKeysList, getPlatformaApiVersion, getPluginData, getRawPlatformaInstance, getRelatedColumns, getRequestColumnsFromSelectedSources, getResultPoolDatasetAxes, getService, getSingleColumnData, getStorageData, getUniqueAxisValuesWithLabels, getUniquePartitionKeys, getUniqueSourceValuesWithLabels, hasColumnData, hasReachableData, hasSingleDataColumn, hitQualifications, ifDef, isBlockStorage, isColumn, isColumnHidden, isColumnOptional, isColumnProvider, isColumnsCollection, isConfigLambda, isDataColumn, isDatasetSelection, isHiddenFromGraphColumn, isHiddenFromUIColumn, isLeafColumn, isPColumnReady, isPluginOutputKey, isSheetFixedToOneValue, listExperimentDesigns, migrateBlockStorage, normalizeBlockStorage, parsePColumnData, parseResourceMap, peerLinkedLast, pluginOutputKey, pluginOutputPrefix, queriesQualifications, readColumnValueOptions, readOutput, registerFacadeCallbacks, splitByAxes, toColumnProvider, unreachable, updateStorageData, upgradePlDataTableStateV2, wrapOutputs };
package/dist/package.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "1.94.0";
2
+ var version = "1.95.0";
3
3
  Object.defineProperty(exports, "version", {
4
4
  enumerable: true,
5
5
  get: function() {
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "1.94.0";
2
+ var version = "1.95.0";
3
3
  export { version };
4
4
 
5
5
  //# sourceMappingURL=package.js.map
@@ -0,0 +1,61 @@
1
+ const require_internal = require("../internal.cjs");
2
+ const require_accessor = require("./accessor.cjs");
3
+ const require_derive_distinct_labels = require("../labels/derive_distinct_labels.cjs");
4
+ let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
5
+ // src/render/experiment_design.ts
6
+ function readData(ref) {
7
+ const block = require_internal.getCfgRenderCtx().getUpstreamBlockCtx().find((b) => b.blockId === ref.blockId);
8
+ if (block === void 0) return void 0;
9
+ const prod = block.prodCtx === void 0 ? void 0 : new require_accessor.TreeNodeAccessor(block.prodCtx, [ref.blockId, "prodCtx"]);
10
+ const ctx = prod?.listInputFields().some((field) => field === `${ref.name}.spec` || field === `${ref.name}.data`) ? prod : block.stagingCtx === void 0 ? prod : new require_accessor.TreeNodeAccessor(block.stagingCtx, [ref.blockId, "stagingCtx"]);
11
+ if (ctx === void 0) return void 0;
12
+ const accessor = ctx.traverse({
13
+ field: `${ref.name}.data`,
14
+ assertFieldType: "Input",
15
+ allowPermanentAbsence: true
16
+ });
17
+ if (accessor === void 0) return void 0;
18
+ const data = accessor.getDataAsJsonOrUndefined();
19
+ if (data === void 0) return void 0;
20
+ if (data.schemaVersion !== _milaboratories_pl_model_common.EXPERIMENT_DESIGN_SCHEMA_VERSION) throw new Error(`experiment design ${ref.blockId}/${ref.name} has schema version ${String(data.schemaVersion)}, and this block understands ${_milaboratories_pl_model_common.EXPERIMENT_DESIGN_SCHEMA_VERSION}`);
21
+ return data;
22
+ }
23
+ function designOf(ref, spec) {
24
+ if (!(0, _milaboratories_pl_model_common.isExperimentDesignSpec)(spec)) return void 0;
25
+ return {
26
+ ref,
27
+ id: (0, _milaboratories_pl_model_common.createGlobalPObjectId)(ref.blockId, ref.name),
28
+ spec,
29
+ getData: () => readData(ref)
30
+ };
31
+ }
32
+ /**
33
+ * The design a ref points at, or undefined when the spec is not readable yet or the object is
34
+ * something else.
35
+ */
36
+ function experimentDesign(ref) {
37
+ const spec = require_internal.getCfgRenderCtx().getSpecFromResultPoolByRef(ref.blockId, ref.name);
38
+ return spec === void 0 ? void 0 : designOf(ref, spec);
39
+ }
40
+ /** Every experiment design in the result pool, in the order the pool lists them. */
41
+ function listExperimentDesigns() {
42
+ return require_internal.getCfgRenderCtx().getSpecsFromResultPool().entries.map((entry) => designOf(entry.ref, entry.obj)).filter((design) => design !== void 0);
43
+ }
44
+ /**
45
+ * Designs as a dropdown takes them, labelled from each object's own annotations.
46
+ *
47
+ * Two designs the user gave the same name get the same label: disambiguation here works off
48
+ * the trace, and a design carries none. Writing one in the export would fix it.
49
+ */
50
+ function deriveExperimentDesignOptions(designs, labelOptions = {}) {
51
+ const labels = require_derive_distinct_labels.deriveDistinctLabels(designs.map((design) => design.spec), labelOptions);
52
+ return designs.map((design, at) => ({
53
+ ref: design.ref,
54
+ label: labels[at]
55
+ }));
56
+ }
57
+ exports.deriveExperimentDesignOptions = deriveExperimentDesignOptions;
58
+ exports.experimentDesign = experimentDesign;
59
+ exports.listExperimentDesigns = listExperimentDesigns;
60
+
61
+ //# sourceMappingURL=experiment_design.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"experiment_design.cjs","names":["getCfgRenderCtx","TreeNodeAccessor","EXPERIMENT_DESIGN_SCHEMA_VERSION","isExperimentDesignSpec","createGlobalPObjectId","deriveDistinctLabels"],"sources":["../../src/render/experiment_design.ts"],"sourcesContent":["// Reading experiment designs out of the result pool from a block model.\n//\n// A design is published as one pool object per design, not as a column, so the column access\n// API does not see it: it drops exports that are not columns. These accessors therefore go to\n// the render ctx primitives directly rather than through `ResultPool`, whose class is\n// deprecated and whose `ctx.*` successors do not exist yet. Data is read one export at a time\n// off its block's ctx, as `columns/data_column.ts` reads `<name>.data`.\nimport type {\n ExperimentDesignData,\n ExperimentDesignSpec,\n GlobalPObjectId,\n Option,\n PObjectSpec,\n PlRef,\n} from \"@milaboratories/pl-model-common\";\nimport {\n EXPERIMENT_DESIGN_SCHEMA_VERSION,\n createGlobalPObjectId,\n isExperimentDesignSpec,\n} from \"@milaboratories/pl-model-common\";\nimport { getCfgRenderCtx } from \"../internal\";\nimport { deriveDistinctLabels, type DeriveLabelsOptions } from \"../labels/derive_distinct_labels\";\nimport { TreeNodeAccessor } from \"./accessor\";\n\n/** One experiment design in the result pool, and the way to read it. */\nexport type ExperimentDesign = {\n /** What a block stores to remember this choice. */\n readonly ref: PlRef;\n /** The same address as an id, which is what the design's tensor ids carry. */\n readonly id: GlobalPObjectId;\n readonly spec: ExperimentDesignSpec;\n /**\n * The design itself, or undefined while the object is still being computed. Throws when the\n * object errored, and when its content is not a design this SDK understands.\n */\n getData(): ExperimentDesignData | undefined;\n};\n\nfunction readData(ref: PlRef): ExperimentDesignData | undefined {\n // The by-ref pool read turns a failed export into undefined, which a caller cannot tell from\n // one still being computed. A traversal keeps the field's error and throws it.\n const block = getCfgRenderCtx()\n .getUpstreamBlockCtx()\n .find((b) => b.blockId === ref.blockId);\n if (block === undefined) return undefined;\n // As the pool does: production wins once it holds any field of the export, staging otherwise.\n const prod =\n block.prodCtx === undefined\n ? undefined\n : new TreeNodeAccessor(block.prodCtx, [ref.blockId, \"prodCtx\"]);\n const inProd = prod\n ?.listInputFields()\n .some((field) => field === `${ref.name}.spec` || field === `${ref.name}.data`);\n const ctx = inProd\n ? prod\n : block.stagingCtx === undefined\n ? prod\n : new TreeNodeAccessor(block.stagingCtx, [ref.blockId, \"stagingCtx\"]);\n if (ctx === undefined) return undefined;\n const accessor = ctx.traverse({\n field: `${ref.name}.data`,\n assertFieldType: \"Input\",\n allowPermanentAbsence: true,\n });\n if (accessor === undefined) return undefined;\n const data = accessor.getDataAsJsonOrUndefined<ExperimentDesignData>();\n if (data === undefined) return undefined;\n if (data.schemaVersion !== EXPERIMENT_DESIGN_SCHEMA_VERSION) {\n throw new Error(\n `experiment design ${ref.blockId}/${ref.name} has schema version ${String(\n data.schemaVersion,\n )}, and this block understands ${EXPERIMENT_DESIGN_SCHEMA_VERSION}`,\n );\n }\n return data;\n}\n\nfunction designOf(ref: PlRef, spec: PObjectSpec): ExperimentDesign | undefined {\n if (!isExperimentDesignSpec(spec)) return undefined;\n return {\n ref,\n id: createGlobalPObjectId(ref.blockId, ref.name),\n spec,\n getData: () => readData(ref),\n };\n}\n\n/**\n * The design a ref points at, or undefined when the spec is not readable yet or the object is\n * something else.\n */\nexport function experimentDesign(ref: PlRef): ExperimentDesign | undefined {\n const spec = getCfgRenderCtx().getSpecFromResultPoolByRef(ref.blockId, ref.name);\n return spec === undefined ? undefined : designOf(ref, spec);\n}\n\n/** Every experiment design in the result pool, in the order the pool lists them. */\nexport function listExperimentDesigns(): ExperimentDesign[] {\n return getCfgRenderCtx()\n .getSpecsFromResultPool()\n .entries.map((entry) => designOf(entry.ref, entry.obj))\n .filter((design): design is ExperimentDesign => design !== undefined);\n}\n\n/**\n * Designs as a dropdown takes them, labelled from each object's own annotations.\n *\n * Two designs the user gave the same name get the same label: disambiguation here works off\n * the trace, and a design carries none. Writing one in the export would fix it.\n */\nexport function deriveExperimentDesignOptions(\n designs: ExperimentDesign[],\n labelOptions: DeriveLabelsOptions = {},\n): Option[] {\n const labels = deriveDistinctLabels(\n designs.map((design) => design.spec),\n labelOptions,\n );\n return designs.map((design, at) => ({ ref: design.ref, label: labels[at]! }));\n}\n"],"mappings":";;;;;AAsCA,SAAS,SAAS,KAA8C;CAG9D,MAAM,QAAQA,iBAAAA,gBAAgB,CAAC,CAC5B,oBAAoB,CAAC,CACrB,MAAM,MAAM,EAAE,YAAY,IAAI,OAAO;CACxC,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAEhC,MAAM,OACJ,MAAM,YAAY,KAAA,IACd,KAAA,IACA,IAAIC,iBAAAA,iBAAiB,MAAM,SAAS,CAAC,IAAI,SAAS,SAAS,CAAC;CAIlE,MAAM,MAHS,MACX,gBAAgB,CAAC,CAClB,MAAM,UAAU,UAAU,GAAG,IAAI,KAAK,UAAU,UAAU,GAAG,IAAI,KAAK,MAAM,IAE3E,OACA,MAAM,eAAe,KAAA,IACnB,OACA,IAAIA,iBAAAA,iBAAiB,MAAM,YAAY,CAAC,IAAI,SAAS,YAAY,CAAC;CACxE,IAAI,QAAQ,KAAA,GAAW,OAAO,KAAA;CAC9B,MAAM,WAAW,IAAI,SAAS;EAC5B,OAAO,GAAG,IAAI,KAAK;EACnB,iBAAiB;EACjB,uBAAuB;CACzB,CAAC;CACD,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CACnC,MAAM,OAAO,SAAS,yBAA+C;CACrE,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;CAC/B,IAAI,KAAK,kBAAkBC,gCAAAA,kCACzB,MAAM,IAAI,MACR,qBAAqB,IAAI,QAAQ,GAAG,IAAI,KAAK,sBAAsB,OACjE,KAAK,aACP,EAAE,+BAA+BA,gCAAAA,kCACnC;CAEF,OAAO;AACT;AAEA,SAAS,SAAS,KAAY,MAAiD;CAC7E,IAAI,EAAA,GAACC,gCAAAA,uBAAAA,CAAuB,IAAI,GAAG,OAAO,KAAA;CAC1C,OAAO;EACL;EACA,KAAA,GAAIC,gCAAAA,sBAAAA,CAAsB,IAAI,SAAS,IAAI,IAAI;EAC/C;EACA,eAAe,SAAS,GAAG;CAC7B;AACF;;;;;AAMA,SAAgB,iBAAiB,KAA0C;CACzE,MAAM,OAAOJ,iBAAAA,gBAAgB,CAAC,CAAC,2BAA2B,IAAI,SAAS,IAAI,IAAI;CAC/E,OAAO,SAAS,KAAA,IAAY,KAAA,IAAY,SAAS,KAAK,IAAI;AAC5D;;AAGA,SAAgB,wBAA4C;CAC1D,OAAOA,iBAAAA,gBAAgB,CAAC,CACrB,uBAAuB,CAAC,CACxB,QAAQ,KAAK,UAAU,SAAS,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC,CACtD,QAAQ,WAAuC,WAAW,KAAA,CAAS;AACxE;;;;;;;AAQA,SAAgB,8BACd,SACA,eAAoC,CAAC,GAC3B;CACV,MAAM,SAASK,+BAAAA,qBACb,QAAQ,KAAK,WAAW,OAAO,IAAI,GACnC,YACF;CACA,OAAO,QAAQ,KAAK,QAAQ,QAAQ;EAAE,KAAK,OAAO;EAAK,OAAO,OAAO;CAAK,EAAE;AAC9E"}
@@ -0,0 +1,30 @@
1
+ import { DeriveLabelsOptions } from "../labels/derive_distinct_labels.js";
2
+ import { ExperimentDesignData, ExperimentDesignSpec, GlobalPObjectId, Option, PlRef } from "@milaboratories/pl-model-common";
3
+ /** One experiment design in the result pool, and the way to read it. */
4
+ export type ExperimentDesign = {
5
+ /** What a block stores to remember this choice. */
6
+ readonly ref: PlRef;
7
+ /** The same address as an id, which is what the design's tensor ids carry. */
8
+ readonly id: GlobalPObjectId;
9
+ readonly spec: ExperimentDesignSpec;
10
+ /**
11
+ * The design itself, or undefined while the object is still being computed. Throws when the
12
+ * object errored, and when its content is not a design this SDK understands.
13
+ */
14
+ getData(): ExperimentDesignData | undefined;
15
+ };
16
+ /**
17
+ * The design a ref points at, or undefined when the spec is not readable yet or the object is
18
+ * something else.
19
+ */
20
+ export declare function experimentDesign(ref: PlRef): ExperimentDesign | undefined;
21
+ /** Every experiment design in the result pool, in the order the pool lists them. */
22
+ export declare function listExperimentDesigns(): ExperimentDesign[];
23
+ /**
24
+ * Designs as a dropdown takes them, labelled from each object's own annotations.
25
+ *
26
+ * Two designs the user gave the same name get the same label: disambiguation here works off
27
+ * the trace, and a design carries none. Writing one in the export would fix it.
28
+ */
29
+ export declare function deriveExperimentDesignOptions(designs: ExperimentDesign[], labelOptions?: DeriveLabelsOptions): Option[];
30
+ //# sourceMappingURL=experiment_design.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"experiment_design.d.ts","names":[],"sources":["../../src/render/experiment_design.ts"],"mappings":";;;YAyBY;;WAED,KAAK;;WAEL,IAAI;WACJ,MAAM;;;;;EAKf,WAAW;;;;;;wBAwDG,iBAAiB,KAAK,QAAQ;;wBAM9B,yBAAyB;;;;;;;wBAazB,8BACd,SAAS,oBACT,eAAc,sBACb"}
@@ -0,0 +1,59 @@
1
+ import { getCfgRenderCtx } from "../internal.js";
2
+ import { TreeNodeAccessor } from "./accessor.js";
3
+ import { deriveDistinctLabels } from "../labels/derive_distinct_labels.js";
4
+ import { EXPERIMENT_DESIGN_SCHEMA_VERSION, createGlobalPObjectId, isExperimentDesignSpec } from "@milaboratories/pl-model-common";
5
+ // src/render/experiment_design.ts
6
+ function readData(ref) {
7
+ const block = getCfgRenderCtx().getUpstreamBlockCtx().find((b) => b.blockId === ref.blockId);
8
+ if (block === void 0) return void 0;
9
+ const prod = block.prodCtx === void 0 ? void 0 : new TreeNodeAccessor(block.prodCtx, [ref.blockId, "prodCtx"]);
10
+ const ctx = prod?.listInputFields().some((field) => field === `${ref.name}.spec` || field === `${ref.name}.data`) ? prod : block.stagingCtx === void 0 ? prod : new TreeNodeAccessor(block.stagingCtx, [ref.blockId, "stagingCtx"]);
11
+ if (ctx === void 0) return void 0;
12
+ const accessor = ctx.traverse({
13
+ field: `${ref.name}.data`,
14
+ assertFieldType: "Input",
15
+ allowPermanentAbsence: true
16
+ });
17
+ if (accessor === void 0) return void 0;
18
+ const data = accessor.getDataAsJsonOrUndefined();
19
+ if (data === void 0) return void 0;
20
+ if (data.schemaVersion !== EXPERIMENT_DESIGN_SCHEMA_VERSION) throw new Error(`experiment design ${ref.blockId}/${ref.name} has schema version ${String(data.schemaVersion)}, and this block understands ${EXPERIMENT_DESIGN_SCHEMA_VERSION}`);
21
+ return data;
22
+ }
23
+ function designOf(ref, spec) {
24
+ if (!isExperimentDesignSpec(spec)) return void 0;
25
+ return {
26
+ ref,
27
+ id: createGlobalPObjectId(ref.blockId, ref.name),
28
+ spec,
29
+ getData: () => readData(ref)
30
+ };
31
+ }
32
+ /**
33
+ * The design a ref points at, or undefined when the spec is not readable yet or the object is
34
+ * something else.
35
+ */
36
+ function experimentDesign(ref) {
37
+ const spec = getCfgRenderCtx().getSpecFromResultPoolByRef(ref.blockId, ref.name);
38
+ return spec === void 0 ? void 0 : designOf(ref, spec);
39
+ }
40
+ /** Every experiment design in the result pool, in the order the pool lists them. */
41
+ function listExperimentDesigns() {
42
+ return getCfgRenderCtx().getSpecsFromResultPool().entries.map((entry) => designOf(entry.ref, entry.obj)).filter((design) => design !== void 0);
43
+ }
44
+ /**
45
+ * Designs as a dropdown takes them, labelled from each object's own annotations.
46
+ *
47
+ * Two designs the user gave the same name get the same label: disambiguation here works off
48
+ * the trace, and a design carries none. Writing one in the export would fix it.
49
+ */
50
+ function deriveExperimentDesignOptions(designs, labelOptions = {}) {
51
+ const labels = deriveDistinctLabels(designs.map((design) => design.spec), labelOptions);
52
+ return designs.map((design, at) => ({
53
+ ref: design.ref,
54
+ label: labels[at]
55
+ }));
56
+ }
57
+ export { deriveExperimentDesignOptions, experimentDesign, listExperimentDesigns };
58
+
59
+ //# sourceMappingURL=experiment_design.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"experiment_design.js","names":[],"sources":["../../src/render/experiment_design.ts"],"sourcesContent":["// Reading experiment designs out of the result pool from a block model.\n//\n// A design is published as one pool object per design, not as a column, so the column access\n// API does not see it: it drops exports that are not columns. These accessors therefore go to\n// the render ctx primitives directly rather than through `ResultPool`, whose class is\n// deprecated and whose `ctx.*` successors do not exist yet. Data is read one export at a time\n// off its block's ctx, as `columns/data_column.ts` reads `<name>.data`.\nimport type {\n ExperimentDesignData,\n ExperimentDesignSpec,\n GlobalPObjectId,\n Option,\n PObjectSpec,\n PlRef,\n} from \"@milaboratories/pl-model-common\";\nimport {\n EXPERIMENT_DESIGN_SCHEMA_VERSION,\n createGlobalPObjectId,\n isExperimentDesignSpec,\n} from \"@milaboratories/pl-model-common\";\nimport { getCfgRenderCtx } from \"../internal\";\nimport { deriveDistinctLabels, type DeriveLabelsOptions } from \"../labels/derive_distinct_labels\";\nimport { TreeNodeAccessor } from \"./accessor\";\n\n/** One experiment design in the result pool, and the way to read it. */\nexport type ExperimentDesign = {\n /** What a block stores to remember this choice. */\n readonly ref: PlRef;\n /** The same address as an id, which is what the design's tensor ids carry. */\n readonly id: GlobalPObjectId;\n readonly spec: ExperimentDesignSpec;\n /**\n * The design itself, or undefined while the object is still being computed. Throws when the\n * object errored, and when its content is not a design this SDK understands.\n */\n getData(): ExperimentDesignData | undefined;\n};\n\nfunction readData(ref: PlRef): ExperimentDesignData | undefined {\n // The by-ref pool read turns a failed export into undefined, which a caller cannot tell from\n // one still being computed. A traversal keeps the field's error and throws it.\n const block = getCfgRenderCtx()\n .getUpstreamBlockCtx()\n .find((b) => b.blockId === ref.blockId);\n if (block === undefined) return undefined;\n // As the pool does: production wins once it holds any field of the export, staging otherwise.\n const prod =\n block.prodCtx === undefined\n ? undefined\n : new TreeNodeAccessor(block.prodCtx, [ref.blockId, \"prodCtx\"]);\n const inProd = prod\n ?.listInputFields()\n .some((field) => field === `${ref.name}.spec` || field === `${ref.name}.data`);\n const ctx = inProd\n ? prod\n : block.stagingCtx === undefined\n ? prod\n : new TreeNodeAccessor(block.stagingCtx, [ref.blockId, \"stagingCtx\"]);\n if (ctx === undefined) return undefined;\n const accessor = ctx.traverse({\n field: `${ref.name}.data`,\n assertFieldType: \"Input\",\n allowPermanentAbsence: true,\n });\n if (accessor === undefined) return undefined;\n const data = accessor.getDataAsJsonOrUndefined<ExperimentDesignData>();\n if (data === undefined) return undefined;\n if (data.schemaVersion !== EXPERIMENT_DESIGN_SCHEMA_VERSION) {\n throw new Error(\n `experiment design ${ref.blockId}/${ref.name} has schema version ${String(\n data.schemaVersion,\n )}, and this block understands ${EXPERIMENT_DESIGN_SCHEMA_VERSION}`,\n );\n }\n return data;\n}\n\nfunction designOf(ref: PlRef, spec: PObjectSpec): ExperimentDesign | undefined {\n if (!isExperimentDesignSpec(spec)) return undefined;\n return {\n ref,\n id: createGlobalPObjectId(ref.blockId, ref.name),\n spec,\n getData: () => readData(ref),\n };\n}\n\n/**\n * The design a ref points at, or undefined when the spec is not readable yet or the object is\n * something else.\n */\nexport function experimentDesign(ref: PlRef): ExperimentDesign | undefined {\n const spec = getCfgRenderCtx().getSpecFromResultPoolByRef(ref.blockId, ref.name);\n return spec === undefined ? undefined : designOf(ref, spec);\n}\n\n/** Every experiment design in the result pool, in the order the pool lists them. */\nexport function listExperimentDesigns(): ExperimentDesign[] {\n return getCfgRenderCtx()\n .getSpecsFromResultPool()\n .entries.map((entry) => designOf(entry.ref, entry.obj))\n .filter((design): design is ExperimentDesign => design !== undefined);\n}\n\n/**\n * Designs as a dropdown takes them, labelled from each object's own annotations.\n *\n * Two designs the user gave the same name get the same label: disambiguation here works off\n * the trace, and a design carries none. Writing one in the export would fix it.\n */\nexport function deriveExperimentDesignOptions(\n designs: ExperimentDesign[],\n labelOptions: DeriveLabelsOptions = {},\n): Option[] {\n const labels = deriveDistinctLabels(\n designs.map((design) => design.spec),\n labelOptions,\n );\n return designs.map((design, at) => ({ ref: design.ref, label: labels[at]! }));\n}\n"],"mappings":";;;;;AAsCA,SAAS,SAAS,KAA8C;CAG9D,MAAM,QAAQ,gBAAgB,CAAC,CAC5B,oBAAoB,CAAC,CACrB,MAAM,MAAM,EAAE,YAAY,IAAI,OAAO;CACxC,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAEhC,MAAM,OACJ,MAAM,YAAY,KAAA,IACd,KAAA,IACA,IAAI,iBAAiB,MAAM,SAAS,CAAC,IAAI,SAAS,SAAS,CAAC;CAIlE,MAAM,MAHS,MACX,gBAAgB,CAAC,CAClB,MAAM,UAAU,UAAU,GAAG,IAAI,KAAK,UAAU,UAAU,GAAG,IAAI,KAAK,MAAM,IAE3E,OACA,MAAM,eAAe,KAAA,IACnB,OACA,IAAI,iBAAiB,MAAM,YAAY,CAAC,IAAI,SAAS,YAAY,CAAC;CACxE,IAAI,QAAQ,KAAA,GAAW,OAAO,KAAA;CAC9B,MAAM,WAAW,IAAI,SAAS;EAC5B,OAAO,GAAG,IAAI,KAAK;EACnB,iBAAiB;EACjB,uBAAuB;CACzB,CAAC;CACD,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;CACnC,MAAM,OAAO,SAAS,yBAA+C;CACrE,IAAI,SAAS,KAAA,GAAW,OAAO,KAAA;CAC/B,IAAI,KAAK,kBAAkB,kCACzB,MAAM,IAAI,MACR,qBAAqB,IAAI,QAAQ,GAAG,IAAI,KAAK,sBAAsB,OACjE,KAAK,aACP,EAAE,+BAA+B,kCACnC;CAEF,OAAO;AACT;AAEA,SAAS,SAAS,KAAY,MAAiD;CAC7E,IAAI,CAAC,uBAAuB,IAAI,GAAG,OAAO,KAAA;CAC1C,OAAO;EACL;EACA,IAAI,sBAAsB,IAAI,SAAS,IAAI,IAAI;EAC/C;EACA,eAAe,SAAS,GAAG;CAC7B;AACF;;;;;AAMA,SAAgB,iBAAiB,KAA0C;CACzE,MAAM,OAAO,gBAAgB,CAAC,CAAC,2BAA2B,IAAI,SAAS,IAAI,IAAI;CAC/E,OAAO,SAAS,KAAA,IAAY,KAAA,IAAY,SAAS,KAAK,IAAI;AAC5D;;AAGA,SAAgB,wBAA4C;CAC1D,OAAO,gBAAgB,CAAC,CACrB,uBAAuB,CAAC,CACxB,QAAQ,KAAK,UAAU,SAAS,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC,CACtD,QAAQ,WAAuC,WAAW,KAAA,CAAS;AACxE;;;;;;;AAQA,SAAgB,8BACd,SACA,eAAoC,CAAC,GAC3B;CACV,MAAM,SAAS,qBACb,QAAQ,KAAK,WAAW,OAAO,IAAI,GACnC,YACF;CACA,OAAO,QAAQ,KAAK,QAAQ,QAAQ;EAAE,KAAK,OAAO;EAAK,OAAO,OAAO;CAAK,EAAE;AAC9E"}
@@ -7,6 +7,7 @@ const require_pcolumn_data = require("./util/pcolumn_data.cjs");
7
7
  const require_column_collection = require("./util/column_collection.cjs");
8
8
  require("./util/index.cjs");
9
9
  const require_api = require("./api.cjs");
10
+ const require_experiment_design = require("./experiment_design.cjs");
10
11
  exports.BlockRenderCtx = require_api.BlockRenderCtx;
11
12
  exports.FutureRef = require_future.FutureRef;
12
13
  exports.MainAccessorName = require_internal.MainAccessorName;
@@ -26,7 +27,9 @@ exports.StagingAccessorName = require_internal.StagingAccessorName;
26
27
  exports.TreeNodeAccessor = require_accessor.TreeNodeAccessor;
27
28
  exports.allPColumnsReady = require_pcolumn_data.allPColumnsReady;
28
29
  exports.convertOrParsePColumnData = require_pcolumn_data.convertOrParsePColumnData;
30
+ exports.deriveExperimentDesignOptions = require_experiment_design.deriveExperimentDesignOptions;
29
31
  exports.deriveLabels = require_label.deriveLabels;
32
+ exports.experimentDesign = require_experiment_design.experimentDesign;
30
33
  exports.filterDataInfoEntries = require_axis_filtering.filterDataInfoEntries;
31
34
  exports.finalizePColumnData = require_api.finalizePColumnData;
32
35
  exports.getNumberOfRows = require_pcolumn_data.getNumberOfRows;
@@ -34,5 +37,6 @@ exports.getPartitionKeysList = require_pcolumn_data.getPartitionKeysList;
34
37
  exports.getUniquePartitionKeys = require_pcolumn_data.getUniquePartitionKeys;
35
38
  exports.ifDef = require_accessor.ifDef;
36
39
  exports.isPColumnReady = require_pcolumn_data.isPColumnReady;
40
+ exports.listExperimentDesigns = require_experiment_design.listExperimentDesigns;
37
41
  exports.parsePColumnData = require_pcolumn_data.parsePColumnData;
38
42
  exports.parseResourceMap = require_pcolumn_data.parseResourceMap;
@@ -9,4 +9,5 @@ import { BlockRenderCtx, InferRenderFunctionReturn, PluginRenderCtx, RenderCtx,
9
9
  import { PColumnKeyList, PColumnResourceMapData, PColumnResourceMapEntry, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, allPColumnsReady, convertOrParsePColumnData, getNumberOfRows, getPartitionKeysList, getUniquePartitionKeys, isPColumnReady, parsePColumnData, parseResourceMap } from "./util/pcolumn_data.js";
10
10
  import { filterDataInfoEntries } from "./util/axis_filtering.js";
11
11
  import "./util/index.js";
12
- export { type AccessorHandle, AxisLabelProvider, BlockRenderCtx, ColumnProvider, CommonFieldTraverseOps, CommonTraversalOps, type ExtractFutureRefType, FieldTraversalStep, FieldType, FutureRef, GetFieldStep, InferRenderFunctionReturn, type DeriveLabelsOptions as LabelDerivationOps, MainAccessorName, PColumnCollection, type PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, PColumnKeyList, PColumnResourceMapData, PColumnResourceMapEntry, PColumnUniversal, PColumnWithLabel, PluginRenderCtx, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtx, RenderCtxBase, RenderFunction, ResourceTraversalOps, ResourceType, ResultPool, type Entry as SpecExtractorResult, StagingAccessorName, TreeNodeAccessor, UniversalColumnOption, UnwrapFutureRef, allPColumnsReady, convertOrParsePColumnData, deriveLabels, filterDataInfoEntries, finalizePColumnData, getNumberOfRows, getPartitionKeysList, getUniquePartitionKeys, ifDef, isPColumnReady, parsePColumnData, parseResourceMap };
12
+ import { ExperimentDesign, deriveExperimentDesignOptions, experimentDesign, listExperimentDesigns } from "./experiment_design.js";
13
+ export { type AccessorHandle, AxisLabelProvider, BlockRenderCtx, ColumnProvider, CommonFieldTraverseOps, CommonTraversalOps, ExperimentDesign, type ExtractFutureRefType, FieldTraversalStep, FieldType, FutureRef, GetFieldStep, InferRenderFunctionReturn, type DeriveLabelsOptions as LabelDerivationOps, MainAccessorName, PColumnCollection, type PColumnDataUniversal, PColumnEntryUniversal, PColumnEntryWithLabel, PColumnKeyList, PColumnResourceMapData, PColumnResourceMapEntry, PColumnUniversal, PColumnWithLabel, PluginRenderCtx, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtx, RenderCtxBase, RenderFunction, ResourceTraversalOps, ResourceType, ResultPool, type Entry as SpecExtractorResult, StagingAccessorName, TreeNodeAccessor, UniversalColumnOption, UnwrapFutureRef, allPColumnsReady, convertOrParsePColumnData, deriveExperimentDesignOptions, deriveLabels, experimentDesign, filterDataInfoEntries, finalizePColumnData, getNumberOfRows, getPartitionKeysList, getUniquePartitionKeys, ifDef, isPColumnReady, listExperimentDesigns, parsePColumnData, parseResourceMap };
@@ -7,4 +7,5 @@ import { RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED
7
7
  import { PColumnCollection } from "./util/column_collection.js";
8
8
  import "./util/index.js";
9
9
  import { BlockRenderCtx, PluginRenderCtx, RenderCtxBase, ResultPool, finalizePColumnData } from "./api.js";
10
- export { BlockRenderCtx, FutureRef, MainAccessorName, PColumnCollection, PluginRenderCtx, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtxBase, ResultPool, StagingAccessorName, TreeNodeAccessor, allPColumnsReady, convertOrParsePColumnData, deriveLabels, filterDataInfoEntries, finalizePColumnData, getNumberOfRows, getPartitionKeysList, getUniquePartitionKeys, ifDef, isPColumnReady, parsePColumnData, parseResourceMap };
10
+ import { deriveExperimentDesignOptions, experimentDesign, listExperimentDesigns } from "./experiment_design.js";
11
+ export { BlockRenderCtx, FutureRef, MainAccessorName, PColumnCollection, PluginRenderCtx, RT_BINARY_PARTITIONED, RT_BINARY_SUPER_PARTITIONED, RT_JSON_PARTITIONED, RT_JSON_SUPER_PARTITIONED, RT_PARQUET_PARTITIONED, RT_PARQUET_SUPER_PARTITIONED, RT_RESOURCE_MAP, RT_RESOURCE_MAP_PARTITIONED, RenderCtxBase, ResultPool, StagingAccessorName, TreeNodeAccessor, allPColumnsReady, convertOrParsePColumnData, deriveExperimentDesignOptions, deriveLabels, experimentDesign, filterDataInfoEntries, finalizePColumnData, getNumberOfRows, getPartitionKeysList, getUniquePartitionKeys, ifDef, isPColumnReady, listExperimentDesigns, parsePColumnData, parseResourceMap };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/model",
3
- "version": "1.94.0",
3
+ "version": "1.95.0",
4
4
  "description": "Platforma.bio SDK / Block Model",
5
5
  "files": [
6
6
  "./dist/**/*",
@@ -27,9 +27,9 @@
27
27
  "dependencies": {
28
28
  "@milaboratories/helpers": "1.14.7",
29
29
  "@milaboratories/pl-error-like": "1.12.11",
30
- "@milaboratories/pl-model-common": "1.58.0",
31
- "@milaboratories/pl-model-middle-layer": "1.41.2",
32
- "@milaboratories/ptabler-expression-js": "1.2.52",
30
+ "@milaboratories/pl-model-common": "1.59.0",
31
+ "@milaboratories/pl-model-middle-layer": "1.41.3",
32
+ "@milaboratories/ptabler-expression-js": "1.2.53",
33
33
  "canonicalize": "~2.1.0",
34
34
  "es-toolkit": "^1.39.10",
35
35
  "fast-json-patch": "^3.1.1",
@@ -39,9 +39,9 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@milaboratories/build-configs": "2.0.3",
42
- "@milaboratories/columns-collection-driver": "0.3.2",
43
- "@milaboratories/pf-driver": "1.9.22",
44
- "@milaboratories/pf-spec-driver": "1.6.4",
42
+ "@milaboratories/columns-collection-driver": "0.3.3",
43
+ "@milaboratories/pf-driver": "1.9.23",
44
+ "@milaboratories/pf-spec-driver": "1.6.5",
45
45
  "@milaboratories/ts-builder": "1.8.0",
46
46
  "@milaboratories/ts-configs": "1.4.1",
47
47
  "@platforma-sdk/block-kind": "1.1.1",
@@ -0,0 +1,196 @@
1
+ import type { ExperimentDesignData, PObjectSpec, PlRef } from "@milaboratories/pl-model-common";
2
+ import {
3
+ EXPERIMENT_DESIGN_SCHEMA_VERSION,
4
+ createGlobalPObjectId,
5
+ } from "@milaboratories/pl-model-common";
6
+ import { afterEach, describe, expect, test } from "vitest";
7
+ import {
8
+ deriveExperimentDesignOptions,
9
+ experimentDesign,
10
+ listExperimentDesigns,
11
+ } from "./experiment_design";
12
+
13
+ const ref = (name: string): PlRef => ({ __isRef: true, blockId: "b1", name });
14
+
15
+ /** As the workflow helper writes it: the design id is in the domain. */
16
+ const designSpec = (label: string, id = label): PObjectSpec => ({
17
+ kind: "ExperimentDesign",
18
+ name: "pl7.app/design",
19
+ domain: { "pl7.app/blockId": "b1", "pl7.app/design/designId": id },
20
+ annotations: { "pl7.app/label": label },
21
+ });
22
+
23
+ const columnSpec: PObjectSpec = { kind: "PColumn", name: "pl7.app/abundance" };
24
+
25
+ /**
26
+ * One pool entry: its spec, plus its content or the error its export failed with, and the ctx
27
+ * that holds it (production unless said otherwise).
28
+ */
29
+ type Entry = { ref: PlRef; obj: PObjectSpec; data?: unknown; ctx?: "prod" | "staging" };
30
+
31
+ /**
32
+ * The pool as a block model sees it: specs by ref and the whole list, and each block's ctx to
33
+ * read one export's data from. No pool-wide data read, so a call to one fails the test.
34
+ */
35
+ function pool(entries: Entry[]) {
36
+ (globalThis as { cfgRenderCtx?: unknown }).cfgRenderCtx = {
37
+ getSpecsFromResultPool: () => ({ entries, isComplete: true }),
38
+ getSpecFromResultPoolByRef: (blockId: string, name: string) =>
39
+ entries.find((entry) => entry.ref.blockId === blockId && entry.ref.name === name)?.obj,
40
+ // a ctx handle here is "<blockId>/<prod|staging>"
41
+ getUpstreamBlockCtx: () =>
42
+ [...new Set(entries.map((entry) => entry.ref.blockId))].map((blockId) => ({
43
+ blockId,
44
+ prodCtx: `${blockId}/prod`,
45
+ stagingCtx: `${blockId}/staging`,
46
+ })),
47
+ listInputFields: (handle: string) =>
48
+ entries
49
+ .filter((entry) => `${entry.ref.blockId}/${entry.ctx ?? "prod"}` === handle)
50
+ .flatMap((entry) => [`${entry.ref.name}.spec`, `${entry.ref.name}.data`]),
51
+ // a traversal throws a field's error and is undefined for a field not set yet
52
+ resolveWithCommon: (handle: string, _: unknown, step: { field: string }) => {
53
+ const data = entries.find(
54
+ (entry) =>
55
+ `${entry.ref.blockId}/${entry.ctx ?? "prod"}` === handle &&
56
+ `${entry.ref.name}.data` === step.field,
57
+ )?.data;
58
+ if (data instanceof Error) throw data;
59
+ return data === undefined ? undefined : JSON.stringify(data);
60
+ },
61
+ // the accessor over a ready export: its handle here is the JSON itself
62
+ getIsReadyOrError: () => true,
63
+ getError: () => undefined,
64
+ getDataAsString: (handle: string) => handle,
65
+ };
66
+ }
67
+
68
+ const emptyDesign: ExperimentDesignData = {
69
+ schemaVersion: EXPERIMENT_DESIGN_SCHEMA_VERSION,
70
+ trajectories: {},
71
+ partitions: {},
72
+ panels: {},
73
+ recurrence: null,
74
+ labels: { materials: {}, trajectories: {}, partitions: {}, panels: {} },
75
+ };
76
+
77
+ afterEach(() => {
78
+ delete (globalThis as { cfgRenderCtx?: unknown }).cfgRenderCtx;
79
+ });
80
+
81
+ describe("listExperimentDesigns", () => {
82
+ test("keeps the designs and drops everything else in the pool", () => {
83
+ pool([
84
+ { ref: ref("design.d1"), obj: designSpec("Campaign 1") },
85
+ { ref: ref("abundance"), obj: columnSpec },
86
+ { ref: ref("design.d2"), obj: designSpec("Campaign 2") },
87
+ ]);
88
+ expect(listExperimentDesigns().map((design) => design.ref.name)).toEqual([
89
+ "design.d1",
90
+ "design.d2",
91
+ ]);
92
+ });
93
+
94
+ test("an empty pool is no designs, not an error", () => {
95
+ pool([]);
96
+ expect(listExperimentDesigns()).toEqual([]);
97
+ });
98
+ });
99
+
100
+ describe("experimentDesign", () => {
101
+ test("reads the design a ref points at", () => {
102
+ pool([{ ref: ref("design.d1"), obj: designSpec("Campaign 1") }]);
103
+ expect(experimentDesign(ref("design.d1"))?.spec.kind).toBe("ExperimentDesign");
104
+ expect(experimentDesign(ref("design.d1"))?.id).toBe(createGlobalPObjectId("b1", "design.d1"));
105
+ });
106
+
107
+ test("is undefined for a ref to something that is not a design", () => {
108
+ pool([{ ref: ref("abundance"), obj: columnSpec }]);
109
+ expect(experimentDesign(ref("abundance"))).toBeUndefined();
110
+ });
111
+
112
+ test("is undefined for a ref the pool does not know", () => {
113
+ pool([]);
114
+ expect(experimentDesign(ref("design.gone"))).toBeUndefined();
115
+ });
116
+ });
117
+
118
+ describe("deriveExperimentDesignOptions", () => {
119
+ test("labels each design and keeps its ref", () => {
120
+ pool([
121
+ { ref: ref("design.d1"), obj: designSpec("Campaign 1") },
122
+ { ref: ref("design.d2"), obj: designSpec("Campaign 2") },
123
+ ]);
124
+ expect(deriveExperimentDesignOptions(listExperimentDesigns())).toEqual([
125
+ { ref: ref("design.d1"), label: "Campaign 1" },
126
+ { ref: ref("design.d2"), label: "Campaign 2" },
127
+ ]);
128
+ });
129
+
130
+ test("gives two designs of the same name the same label", () => {
131
+ // Known limit, pinned here so a fix is a deliberate change: labels are made distinct from
132
+ // the trace, and a design carries none, so the domain's design id does not separate these.
133
+ pool([
134
+ { ref: ref("design.d1"), obj: designSpec("Campaign", "d1") },
135
+ { ref: ref("design.d2"), obj: designSpec("Campaign", "d2") },
136
+ ]);
137
+ const labels = deriveExperimentDesignOptions(listExperimentDesigns()).map(
138
+ (option) => option.label,
139
+ );
140
+ expect(labels).toEqual(["Campaign", "Campaign"]);
141
+ });
142
+ });
143
+
144
+ describe("ExperimentDesign.getData", () => {
145
+ const read = () => experimentDesign(ref("design.d1"))?.getData();
146
+
147
+ test("reads the design a ready export carries", () => {
148
+ pool([{ ref: ref("design.d1"), obj: designSpec("Campaign 1"), data: emptyDesign }]);
149
+ expect(read()).toEqual(emptyDesign);
150
+ });
151
+
152
+ test("is undefined while the export has no data yet", () => {
153
+ pool([{ ref: ref("design.d1"), obj: designSpec("Campaign 1") }]);
154
+ expect(read()).toBeUndefined();
155
+ });
156
+
157
+ test("throws the error a failed export carries instead of reading as still loading", () => {
158
+ pool([
159
+ { ref: ref("design.d1"), obj: designSpec("Campaign 1"), data: new Error("export failed") },
160
+ ]);
161
+ expect(read).toThrow("export failed");
162
+ });
163
+
164
+ test("reads a design published only in staging", () => {
165
+ pool([
166
+ {
167
+ ref: ref("design.d1"),
168
+ obj: designSpec("Campaign 1"),
169
+ data: emptyDesign,
170
+ ctx: "staging",
171
+ },
172
+ ]);
173
+ expect(read()).toEqual(emptyDesign);
174
+ });
175
+
176
+ test("reads production over staging once production has the export", () => {
177
+ pool([
178
+ { ref: ref("design.d1"), obj: designSpec("Campaign 1"), ctx: "staging", data: { x: 1 } },
179
+ { ref: ref("design.d1"), obj: designSpec("Campaign 1"), data: emptyDesign },
180
+ ]);
181
+ expect(read()).toEqual(emptyDesign);
182
+ });
183
+
184
+ test("is undefined while the publishing block has no ctx yet", () => {
185
+ pool([{ ref: ref("design.d1"), obj: designSpec("Campaign 1"), data: emptyDesign }]);
186
+ const ctx = (globalThis as { cfgRenderCtx: { getUpstreamBlockCtx: () => unknown[] } })
187
+ .cfgRenderCtx;
188
+ ctx.getUpstreamBlockCtx = () => [{ blockId: "b1" }];
189
+ expect(read()).toBeUndefined();
190
+ });
191
+
192
+ test("throws when the content is a design of a schema version this SDK does not know", () => {
193
+ pool([{ ref: ref("design.d1"), obj: designSpec("Campaign 1"), data: { schemaVersion: 99 } }]);
194
+ expect(read).toThrow(/schema version 99/);
195
+ });
196
+ });
@@ -0,0 +1,120 @@
1
+ // Reading experiment designs out of the result pool from a block model.
2
+ //
3
+ // A design is published as one pool object per design, not as a column, so the column access
4
+ // API does not see it: it drops exports that are not columns. These accessors therefore go to
5
+ // the render ctx primitives directly rather than through `ResultPool`, whose class is
6
+ // deprecated and whose `ctx.*` successors do not exist yet. Data is read one export at a time
7
+ // off its block's ctx, as `columns/data_column.ts` reads `<name>.data`.
8
+ import type {
9
+ ExperimentDesignData,
10
+ ExperimentDesignSpec,
11
+ GlobalPObjectId,
12
+ Option,
13
+ PObjectSpec,
14
+ PlRef,
15
+ } from "@milaboratories/pl-model-common";
16
+ import {
17
+ EXPERIMENT_DESIGN_SCHEMA_VERSION,
18
+ createGlobalPObjectId,
19
+ isExperimentDesignSpec,
20
+ } from "@milaboratories/pl-model-common";
21
+ import { getCfgRenderCtx } from "../internal";
22
+ import { deriveDistinctLabels, type DeriveLabelsOptions } from "../labels/derive_distinct_labels";
23
+ import { TreeNodeAccessor } from "./accessor";
24
+
25
+ /** One experiment design in the result pool, and the way to read it. */
26
+ export type ExperimentDesign = {
27
+ /** What a block stores to remember this choice. */
28
+ readonly ref: PlRef;
29
+ /** The same address as an id, which is what the design's tensor ids carry. */
30
+ readonly id: GlobalPObjectId;
31
+ readonly spec: ExperimentDesignSpec;
32
+ /**
33
+ * The design itself, or undefined while the object is still being computed. Throws when the
34
+ * object errored, and when its content is not a design this SDK understands.
35
+ */
36
+ getData(): ExperimentDesignData | undefined;
37
+ };
38
+
39
+ function readData(ref: PlRef): ExperimentDesignData | undefined {
40
+ // The by-ref pool read turns a failed export into undefined, which a caller cannot tell from
41
+ // one still being computed. A traversal keeps the field's error and throws it.
42
+ const block = getCfgRenderCtx()
43
+ .getUpstreamBlockCtx()
44
+ .find((b) => b.blockId === ref.blockId);
45
+ if (block === undefined) return undefined;
46
+ // As the pool does: production wins once it holds any field of the export, staging otherwise.
47
+ const prod =
48
+ block.prodCtx === undefined
49
+ ? undefined
50
+ : new TreeNodeAccessor(block.prodCtx, [ref.blockId, "prodCtx"]);
51
+ const inProd = prod
52
+ ?.listInputFields()
53
+ .some((field) => field === `${ref.name}.spec` || field === `${ref.name}.data`);
54
+ const ctx = inProd
55
+ ? prod
56
+ : block.stagingCtx === undefined
57
+ ? prod
58
+ : new TreeNodeAccessor(block.stagingCtx, [ref.blockId, "stagingCtx"]);
59
+ if (ctx === undefined) return undefined;
60
+ const accessor = ctx.traverse({
61
+ field: `${ref.name}.data`,
62
+ assertFieldType: "Input",
63
+ allowPermanentAbsence: true,
64
+ });
65
+ if (accessor === undefined) return undefined;
66
+ const data = accessor.getDataAsJsonOrUndefined<ExperimentDesignData>();
67
+ if (data === undefined) return undefined;
68
+ if (data.schemaVersion !== EXPERIMENT_DESIGN_SCHEMA_VERSION) {
69
+ throw new Error(
70
+ `experiment design ${ref.blockId}/${ref.name} has schema version ${String(
71
+ data.schemaVersion,
72
+ )}, and this block understands ${EXPERIMENT_DESIGN_SCHEMA_VERSION}`,
73
+ );
74
+ }
75
+ return data;
76
+ }
77
+
78
+ function designOf(ref: PlRef, spec: PObjectSpec): ExperimentDesign | undefined {
79
+ if (!isExperimentDesignSpec(spec)) return undefined;
80
+ return {
81
+ ref,
82
+ id: createGlobalPObjectId(ref.blockId, ref.name),
83
+ spec,
84
+ getData: () => readData(ref),
85
+ };
86
+ }
87
+
88
+ /**
89
+ * The design a ref points at, or undefined when the spec is not readable yet or the object is
90
+ * something else.
91
+ */
92
+ export function experimentDesign(ref: PlRef): ExperimentDesign | undefined {
93
+ const spec = getCfgRenderCtx().getSpecFromResultPoolByRef(ref.blockId, ref.name);
94
+ return spec === undefined ? undefined : designOf(ref, spec);
95
+ }
96
+
97
+ /** Every experiment design in the result pool, in the order the pool lists them. */
98
+ export function listExperimentDesigns(): ExperimentDesign[] {
99
+ return getCfgRenderCtx()
100
+ .getSpecsFromResultPool()
101
+ .entries.map((entry) => designOf(entry.ref, entry.obj))
102
+ .filter((design): design is ExperimentDesign => design !== undefined);
103
+ }
104
+
105
+ /**
106
+ * Designs as a dropdown takes them, labelled from each object's own annotations.
107
+ *
108
+ * Two designs the user gave the same name get the same label: disambiguation here works off
109
+ * the trace, and a design carries none. Writing one in the export would fix it.
110
+ */
111
+ export function deriveExperimentDesignOptions(
112
+ designs: ExperimentDesign[],
113
+ labelOptions: DeriveLabelsOptions = {},
114
+ ): Option[] {
115
+ const labels = deriveDistinctLabels(
116
+ designs.map((design) => design.spec),
117
+ labelOptions,
118
+ );
119
+ return designs.map((design, at) => ({ ref: design.ref, label: labels[at]! }));
120
+ }
@@ -6,3 +6,4 @@ export { FutureRef } from "./future";
6
6
  export type { AccessorHandle, PColumnDataUniversal } from "./internal";
7
7
  export { MainAccessorName, StagingAccessorName } from "./internal";
8
8
  export type { ExtractFutureRefType } from "./future";
9
+ export * from "./experiment_design";