Skip to content

Commit

Permalink
import changes from nv-morpheus#445
Browse files Browse the repository at this point in the history
  • Loading branch information
AjayThorve committed Feb 14, 2024
1 parent ada2183 commit 70f08c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
segmentInstanceDecRefCount,
segmentInstancesSelectById,
segmentInstancesSelectByNameAndPipelineDef,
segmentInstancesSelectBySegmentAddress,
segmentInstancesSelectByAddress,
} from "@mrc/server/store/slices/segmentInstancesSlice";
import { startAppListening } from "@mrc/server/store/listener_middleware";
import { createWatcher } from "@mrc/server/store/resourceStateWatcher";
Expand Down Expand Up @@ -323,11 +323,11 @@ function syncSegmentNameForManifold(
// Determine any that need to be removed
const toRemove = currentSegmentIds.filter((s) => !activeSegments.map((s) => s.segmentAddress).includes(s));

toRemove.forEach((segId) => {
const seg = segmentInstancesSelectById(state, segId);
toRemove.forEach((segAddress) => {
const seg = segmentInstancesSelectByAddress(state, segAddress);

if (!seg) {
throw new Error(`Could not find segment with ID: ${segId}`);
throw new Error(`Could not find segment with address: ${segAddress}`);
}

// Dispatch the attach action
Expand Down Expand Up @@ -427,9 +427,9 @@ function manifoldInstanceUpdateActualSegment(
segmentAddress: string,
isLocal: boolean
) {
const segment = segmentInstancesSelectBySegmentAddress(state, segmentAddress)[0];
const segment = segmentInstancesSelectByAddress(state, segmentAddress);
if (!segment) {
throw new Error(`Could not find segment with segment address: ${segmentAddress}`);
throw new Error(`Could not find segment with address: ${segmentAddress}`);
}

const requestedMapping: { [key: string]: boolean } = isInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@ const selectByPipelineId = createSelector(
export const segmentInstancesSelectByPipelineId = (state: RootState, pipeline_id: string) =>
selectByPipelineId(state.segmentInstances, pipeline_id);

const selectByAddress = createSelector(
[segmentInstancesAdapter.getAll, (state: SegmentInstancesStateType, segmentAddress: string) => segmentAddress],
(segmentInstances, segmentAddress) => segmentInstances.find((x) => x.segmentAddress === segmentAddress)
);

export const segmentInstancesSelectByAddress = (state: RootState, segmentAddress: string) =>
selectByAddress(state.segmentInstances, segmentAddress);

const selectByNameAndPipelineDef = createSelector(
[
segmentInstancesAdapter.getAll,
Expand Down

0 comments on commit 70f08c8

Please sign in to comment.