Skip to content

Commit

Permalink
running first example
Browse files Browse the repository at this point in the history
  • Loading branch information
Mustafa Kerem Kurban committed Sep 27, 2024
1 parent 40a5a02 commit af28eb5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/neuroagent/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from dotenv import dotenv_values
from fastapi.openapi.models import OAuthFlowPassword, OAuthFlows
from pydantic import BaseModel, ConfigDict, SecretStr, model_validator
from pydantic import BaseModel, ConfigDict, SecretStr, model_validator, Field
from pydantic_settings import BaseSettings, SettingsConfigDict


Expand Down Expand Up @@ -121,14 +121,13 @@ class SettingsGetMEModel(BaseModel):

model_config = ConfigDict(frozen=True)


class SettingsBlueNaaS(BaseModel):
"""BlueNaaS settings."""

url: str

url: str = "https://openbluebrain.com/api/bluenaas/single-neuron/run" #TODO: move to .env
model_config = ConfigDict(frozen=True)


class SettingsKnowledgeGraph(BaseModel):
"""Knowledge graph API settings."""

Expand Down Expand Up @@ -223,6 +222,7 @@ class Settings(BaseSettings):
keycloak: SettingsKeycloak = SettingsKeycloak() # has no required
misc: SettingsMisc = SettingsMisc() # has no required


model_config = SettingsConfigDict(
env_file=".env",
env_prefix="NEUROAGENT_",
Expand Down
43 changes: 21 additions & 22 deletions src/neuroagent/tools/bluenaas_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
logger = logging.getLogger(__name__)

#TODO : since bluenaaas has multiple endpoints for synapse generation ,nexus query, simulation, how should we handle those?
class SynapseSimulationConfig(BaseModel):
id: str
delay: int
duration: int
frequency: PositiveInt
weightScalar: int
# class SynapseSimulationConfig(BaseModel):
# id: str
# delay: int
# duration: int
# frequency: PositiveInt
# weightScalar: int

class SimulationStimulusConfig(BaseModel):
stimulusType: Literal["current_clamp", "voltage_clamp", "conductance"]
Expand All @@ -40,9 +40,9 @@ class SimulationConditionsConfig(BaseModel):
time_step: float # usually 0.025 ms
seed: int # can be any nubmer

class SimulationWithSynapseBody(BaseModel):
directCurrentConfig: CurrentInjectionConfig
synapseConfigs: list[SynapseSimulationConfig]
# class SimulationWithSynapseBody(BaseModel):
# directCurrentConfig: CurrentInjectionConfig
# synapseConfigs: list[SynapseSimulationConfig]


class InputBlueNaaS(BaseModel):
Expand All @@ -54,12 +54,12 @@ class InputBlueNaaS(BaseModel):
" fetched using the 'get-me-model-tool'."
)
)
synapses: list[SynapseSimulationConfig] = Field(
description=(
"List of synapse configurations. Each synapse configuration includes the"
" synapse ID, delay, duration, frequency, and weight scalar."
)
)
# synapses: list[SynapseSimulationConfig] = Field(
# description=(
# "List of synapse configurations. Each synapse configuration includes the"
# " synapse ID, delay, duration, frequency, and weight scalar."
# )
# )
currentInjection: CurrentInjectionConfig = Field(
description=(
"Configuration for current injection. Includes the target section to inject"
Expand All @@ -79,10 +79,9 @@ class InputBlueNaaS(BaseModel):
" (max_time, in ms), time step (time_step, in ms), and random seed (seed)."
)
)
simulationType: Literal["single-neuron-simulation","synaptome-simulation"] = Field(
simulationType: Literal["single-neuron-simulation"] = Field(
description=(
"Type of the simulation. it can be single neuron simulation for simulation"
" without synapse placement or synaptome-simulation to put synapses on the morphology."
"Type of the simulation. For now , its set to only single-neuron-simulation"
)
)
simulationDuration: int = Field(
Expand All @@ -109,19 +108,19 @@ class BlueNaaSTool(BasicTool):

async def _arun(self,
me_model_id: str,
synapses: List[SynapseSimulationConfig],
# synapses: List[SynapseSimulationConfig],
currentInjection: CurrentInjectionConfig,
recordFrom: List[RecordingLocation],
conditions: SimulationConditionsConfig,
simulationType: Literal["single-neuron-simulation","synaptome-simulation"],
simulationType: Literal["single-neuron-simulation"],
simulationDuration: int
) -> BaseToolOutput:
"""
Run the BlueNaaS tool.
Args:
me_model_id: ID of the neuron model to be used in the simulation.
synapses: List of synapse configurations.
# synapses: List of synapse configurations.
currentInjection: Configuration for current injection.
recordFrom: List of sections to record from during the simulation.
conditions: Simulation conditions.
Expand All @@ -138,7 +137,7 @@ async def _arun(self,
headers={"Authorization": f"Bearer {self.metadata['token']}"},
json={
"model_id": me_model_id,
"synapses": [synapse.dict() for synapse in synapses],
# "synapses": [synapse.dict() for synapse in synapses],
"currentInjection": currentInjection.dict(),
"recordFrom": [record.dict() for record in recordFrom],
"conditions": conditions.dict(),
Expand Down

0 comments on commit af28eb5

Please sign in to comment.