Skip to content

pass workspace context to synapses places and simulations #397

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 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/api/bluenaas/getSynaptomePlacement.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { blueNaasUrl } from '@/config';
import { SingleSynaptomeConfig } from '@/types/synaptome';
import { VirtualLabInfo } from '@/types/virtual-lab/common';
import { createHeaders } from '@/util/utils';

export default async function getSynapsesPlacement({
context,
modelId,
seed,
config,
token,
signal,
}: {
context: VirtualLabInfo;
token: string;
modelId: string;
seed: number;
Expand All @@ -19,7 +22,12 @@ export default async function getSynapsesPlacement({
`${blueNaasUrl}/synaptome/generate-placement?model_id=${encodeURIComponent(modelId)}`,
{
method: 'post',
headers: createHeaders(token),
headers: createHeaders(token, {
'Content-Type': 'application/json',
accept: 'application/json',
'virtual-lab-id': context.virtualLabId,
'project-id': context.projectId,
}),
body: JSON.stringify({
seed,
config,
Expand Down
2 changes: 2 additions & 0 deletions src/api/bluenaas/runSimulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export const runGenericSingleNeuronSimulation = async ({
accept: 'application/octet-stream',
authorization: `bearer ${token}`,
'Content-Type': 'application/json',
'virtual-lab-id': vlabId,
'project-id': projectId,
},
body: JSON.stringify(formattedConfig),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
PlusCircleOutlined,
} from '@ant-design/icons';
import { Color } from 'three';
import { useParams } from 'next/navigation';

import isEqual from 'lodash/isEqual';
import groupBy from 'lodash/groupBy';
Expand All @@ -30,9 +31,10 @@ import { SettingAdjustment } from '@/components/icons/SettingAdjustment';
import { secNamesAtom } from '@/state/simulate/single-neuron';
import { getSynaptomePlacement } from '@/api/bluenaas';
import { getSession } from '@/authFetch';

import useNotification from '@/hooks/notifications';

import type { VirtualLabInfo } from '@/types/virtual-lab/common';

type Props = {
modelId: string;
index: number;
Expand All @@ -52,6 +54,7 @@ export default function SynapseSet({
removeGroup,
disableApplyChanges,
}: Props) {
const { virtualLabId, projectId } = useParams<VirtualLabInfo>();
const { error: notifyError } = useNotification();
const form = Form.useFormInstance();
const secNames = useAtomValue(secNamesAtom);
Expand Down Expand Up @@ -199,6 +202,7 @@ export default function SynapseSet({
throw new Error('No session found');
}
const response = await getSynaptomePlacement({
context: { virtualLabId, projectId },
modelId,
seed,
config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '@ant-design/icons';
import { Button, Form, InputNumber, Select, SelectProps } from 'antd';
import { useAtom, useAtomValue } from 'jotai';
import { useParams } from 'next/navigation';
import { Color } from 'three';

import ConfigInputList from './ConfigInput';
Expand All @@ -32,6 +33,7 @@ import { calculateRangeOutput } from '@/constants/simulate/single-neuron';
import { Switch } from '@/components/common/Switch';
import { UpdateSynapseSimulationProperty } from '@/types/simulation/single-neuron';
import { synaptomeSimulationConfigAtom } from '@/state/simulate/categories/synaptome-simulation-config';
import type { VirtualLabInfo } from '@/types/virtual-lab/common';

type Props = {
index: number;
Expand All @@ -50,6 +52,7 @@ export default function SynapticInputItem({
synaptomeModelConfig,
selectedSynapticInputPlacementConfig,
}: Props) {
const { virtualLabId, projectId } = useParams<VirtualLabInfo>();
const { error: notifyError } = useNotification();
const [synapticInputOpened, setSynapticInputOpened] = useState(false);
const [synapseDisplayed, setSynapseDisplayed] = useState(false);
Expand Down Expand Up @@ -108,6 +111,7 @@ export default function SynapticInputItem({

abortController.current = new AbortController();
const response = await getSynaptomePlacement({
context: { virtualLabId, projectId },
modelId: synaptomeModelConfig.meModelSelf,
seed: selectedSynapticInputPlacementConfig?.seed!,
config: selectedSynapticInputPlacementConfig!,
Expand Down Expand Up @@ -193,7 +197,7 @@ export default function SynapticInputItem({
{synapseDisplayed ? (
<EyeInvisibleOutlined className="h-8 w-8 px-2 text-primary-8" />
) : visualizeLoading ? (
<LoadingOutlined className="h-8 w-8 px-2 text-primary-8" />
<LoadingOutlined className="h-8 w-8 px-2 text-primary-8" />
) : (
<EyeOutlined className="h-8 w-8 px-2 text-primary-8" />
)}
Expand Down Expand Up @@ -345,7 +349,7 @@ function FrequencyFormItem({
<div className="flex">
{disableFrequencyStepper && (
<CustomPopover message={disableStepperContent} when="hover">
<div className="mr-2 text-sm text-primary-9">
<div className="mr-2 text-sm text-primary-9">
<WarningFilled className="mr-2" />
Stepper already assigned
</div>
Expand Down Expand Up @@ -453,7 +457,7 @@ function FrequencyFormItem({
</div>

{calculatedFrequencies.map((f) => (
<span className="mx-2 text-sm " key={f}>
<span className="mx-2 text-sm" key={f}>
{f}
</span>
))}
Expand Down