-
Notifications
You must be signed in to change notification settings - Fork 0
update: save kgird data to context #151
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
Open
VsevolodX
wants to merge
7
commits into
main
Choose a base branch
from
feature/SOF-7918
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d2e16be
update: save kgird data to context
VsevolodX 6a429c3
update: show real grid metric used
VsevolodX 51d246a
Merge branch 'main' into feature/SOF-7918
VsevolodX 0db2a4b
chore: lint
VsevolodX 99769bb
chore: lint
VsevolodX bd551b7
update: test for what we fixed
VsevolodX cb4dabc
chore: adjust types
VsevolodX 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
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,12 @@ | ||
| import type { PointsGridDataProviderSchema } from "@mat3ra/esse/dist/js/types"; | ||
| import type { MaterialExternalContext } from "../../mixins/MaterialContextMixin"; | ||
| type UnitContext = Array<{ | ||
| name?: string; | ||
| data?: PointsGridDataProviderSchema; | ||
| }> | unknown; | ||
| export declare function getKgridDataFromUnitContext(context: UnitContext): PointsGridDataProviderSchema | undefined; | ||
| export declare function getEffectiveKgridPrecision(kgridData: PointsGridDataProviderSchema, externalContext: MaterialExternalContext): { | ||
| value: number; | ||
| metric: NonNullable<PointsGridDataProviderSchema["gridMetricType"]>; | ||
| }; | ||
| export {}; |
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,31 @@ | ||
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getKgridDataFromUnitContext = getKgridDataFromUnitContext; | ||
| exports.getEffectiveKgridPrecision = getEffectiveKgridPrecision; | ||
| const KGridFormDataManager_1 = __importDefault(require("./KGridFormDataManager")); | ||
| function getKgridDataFromUnitContext(context) { | ||
| if (!context) { | ||
| return undefined; | ||
| } | ||
| if (Array.isArray(context)) { | ||
| const item = context.find((entry) => (entry === null || entry === void 0 ? void 0 : entry.name) === "kgrid"); | ||
| return item === null || item === void 0 ? void 0 : item.data; | ||
| } | ||
| if (typeof context === "object" && context !== null && "kgrid" in context) { | ||
| return context.kgrid; | ||
| } | ||
| return undefined; | ||
| } | ||
| function getEffectiveKgridPrecision(kgridData, externalContext) { | ||
| var _a, _b; | ||
| const provider = new KGridFormDataManager_1.default({ name: "kgrid", data: kgridData }, externalContext); | ||
| provider.setData(provider.getData()); | ||
| const normalized = provider.getData(); | ||
| return { | ||
| value: (_a = normalized.gridMetricValue) !== null && _a !== void 0 ? _a : -1, | ||
| metric: (_b = normalized.gridMetricType) !== null && _b !== void 0 ? _b : "KPPRA", | ||
| }; | ||
| } |
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
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
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 |
|---|---|---|
|
|
@@ -34,6 +34,9 @@ type SetExecutableProps = { | |
| flavorName?: string; | ||
| }; | ||
|
|
||
| // Context items always serialized on the unit so rupy can store them in scope after execution. | ||
| const CONTEXT_SCOPE_ITEMS = new Set(["kgrid"]); | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No premature optimization. Either storing full contexts on each unit -- which will be too much, or specifying those that are actually needed during the job running |
||
| class ExecutionUnit extends (BaseUnit as Base) implements Schema { | ||
| inputInstances: ExecutionUnitInput[] = []; | ||
|
|
||
|
|
@@ -228,8 +231,12 @@ class ExecutionUnit extends (BaseUnit as Base) implements Schema { | |
| } | ||
|
|
||
| savePersistentContext() { | ||
| this.contextProvidersInstances | ||
| .filter((p) => CONTEXT_SCOPE_ITEMS.has(p.name)) | ||
| .forEach((p) => p.syncPersistentData()); | ||
|
|
||
| const persistentItems = this.contextProvidersInstances.map((p) => p.getContextItemData()); | ||
| this.context = persistentItems.filter((c) => c.isEdited); | ||
| this.context = persistentItems.filter((c) => c.isEdited || CONTEXT_SCOPE_ITEMS.has(c.name)); | ||
| } | ||
|
|
||
| saveRenderingContext(externalContext: ExternalContext) { | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now for example if we use (2 2 2) kgrid on Si2, then the gridMetricValue is still shown "5" by default in UI -- which is not true, the "16" value is used in calculations.
Not
isEdited=True-- thus it is not updated, while it would be if it was edited.