mxbiflow 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl

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.
mxbiflow/__init__.py CHANGED
@@ -1,3 +1,12 @@
1
+ from .mxbi import build_mxbi
1
2
  from .mxbiflow import MXBIFlow, get_mxbiflow
3
+ from .ui.utils import config_wizard
4
+ from .utils.init_session import init_session
2
5
 
3
- __all__ = ["MXBIFlow", "get_mxbiflow"]
6
+ __all__ = [
7
+ "MXBIFlow",
8
+ "get_mxbiflow",
9
+ "config_wizard",
10
+ "build_mxbi",
11
+ "init_session",
12
+ ]
@@ -1,4 +1,3 @@
1
- from .habituation.habituarion import Habituarion
2
1
  from .idle.idle import IDLE
3
2
 
4
- __all__ = ["Habituarion", "IDLE"]
3
+ __all__ = ["IDLE"]
@@ -5,7 +5,6 @@ from random import choice
5
5
  from pygame import Event, Rect, Surface, image, transform
6
6
 
7
7
  from mxbiflow import get_mxbiflow
8
- from mxbiflow.scene.scene_protocol import SceneProtocol
9
8
 
10
9
  ASSETS_PATH = Path(__file__).parent / "assets"
11
10
 
@@ -143,3 +143,4 @@ class Options(BaseModel):
143
143
  mxbis: list[str] = Field(default_factory=list, frozen=True)
144
144
  experimenter: list[str] = Field(default_factory=list, frozen=True)
145
145
  animals: dict[str, str] = Field(default_factory=dict, frozen=True)
146
+ stages: list[str] = Field(default_factory=list)
mxbiflow/mxbi.py ADDED
@@ -0,0 +1,19 @@
1
+ import pymxbi
2
+ from loguru import logger
3
+ from pymxbi import MXBI, MXBIModel
4
+
5
+ from .config_store import ConfigStore
6
+ from .models.session import SessionConfig
7
+
8
+
9
+ def build_mxbi(mxbi_config_path, session_config_path) -> MXBI:
10
+
11
+ mxbi_config = ConfigStore(mxbi_config_path, MXBIModel).value
12
+ session_config = ConfigStore(session_config_path, SessionConfig).value
13
+
14
+ mxbi = pymxbi.build_mxbi(mxbi_config, logger)
15
+ mxbi.register_animal(
16
+ {animal.rfid_id: animal.name for animal in session_config.animals}
17
+ )
18
+
19
+ return mxbi
mxbiflow/path.py CHANGED
@@ -31,10 +31,6 @@ MOUNT_SERVICE_PATH = SERVICE_DIR_PATH / MOUNT_SERVICE_NAME
31
31
  SYNC_SERVICE_NAME = "sync.service"
32
32
  SYNC_SERVICE_PATH = SERVICE_DIR_PATH / SYNC_SERVICE_NAME
33
33
 
34
- MXBI_CONFIG_PATH = CONFIG_DIR_PATH / "mxbi.json"
35
- SESSION_CONFIG_PATH = CONFIG_DIR_PATH / "session.json"
36
- OPTIONS_PATH = CONFIG_DIR_PATH / "options.json"
37
- STAGE_PATH = CONFIG_DIR_PATH / "stage.json"
38
34
  SESSION_COUNTER_PATH = CONFIG_DIR_PATH / "session_counter.json"
39
35
 
40
36
  ASSETS_DIR_PATH = ROOT_DIR_PATH / "assets"
@@ -1,8 +1,7 @@
1
- from .scene_manager import SceneManager, Scenes
1
+ from .scene_manager import SceneManager
2
2
  from .scene_protocol import SceneProtocol
3
3
 
4
4
  __all__ = [
5
5
  "SceneManager",
6
- "Scenes",
7
6
  "SceneProtocol",
8
7
  ]
@@ -1,34 +1,39 @@
1
1
  from pathlib import Path
2
2
 
3
- from pydantic import RootModel
4
3
  from pygame import Event, Surface
5
4
 
5
+ from ..config_store import ConfigStore
6
+ from ..models.session import Options
6
7
  from .scene_protocol import SceneProtocol
7
8
 
8
9
 
9
- class Scenes(RootModel):
10
- root: list[str]
11
-
12
-
13
10
  class SceneManager:
14
- scenes: dict[str, type[SceneProtocol]] = {}
11
+ _scenes: dict[str, type[SceneProtocol]] = {}
15
12
 
16
13
  def __init__(self) -> None:
17
14
  self.current: SceneProtocol | None = None
18
15
  self._pending: SceneProtocol | None = None
19
16
 
20
17
  def persist(self, path: Path) -> None:
21
- scenes = Scenes(root=list(self.scenes.keys()))
22
- json_data = scenes.model_dump_json()
23
-
24
- with path.open("w") as f:
25
- f.write(json_data)
26
-
27
- def register(self, scene: type[SceneProtocol], name: str | None = None) -> None:
28
- if name is None:
29
- name = scene.__name__.lower()
18
+ options_store = ConfigStore(path, Options)
19
+
20
+ options_store.value.stages = list(self._scenes.keys())
21
+ options_store.save()
22
+
23
+ def register(
24
+ self, scene: dict[str, type[SceneProtocol]] | list[type[SceneProtocol]]
25
+ ) -> None:
26
+ if isinstance(scene, dict):
27
+ self._scenes.update(scene)
28
+ elif isinstance(scene, list):
29
+ for s in scene:
30
+ self._scenes[s.__name__.lower()] = s
31
+ else:
32
+ raise ValueError("Invalid scene type")
30
33
 
31
- self.scenes[name] = scene
34
+ @property
35
+ def scenes(self) -> dict[str, type[SceneProtocol]]:
36
+ return self._scenes
32
37
 
33
38
  def switch(self, scene: type[SceneProtocol], defer: bool = True) -> None:
34
39
  if defer:
@@ -1,17 +1,15 @@
1
1
  from PySide6.QtCore import Qt, Signal
2
2
  from PySide6.QtWidgets import QComboBox, QFormLayout, QLabel, QLineEdit, QMenu
3
3
 
4
- from ...config_store import ConfigStore
5
4
  from ...models.animal import AnimalConfig
6
- from ...path import STAGE_PATH
7
- from ...scene import Scenes
5
+ from ...models.session import Options
8
6
  from .card import CardFrame
9
7
 
10
8
 
11
9
  class AnimalCard(CardFrame):
12
10
  remove_requested = Signal()
13
11
 
14
- def __init__(self, parent, animals: dict[str, str]):
12
+ def __init__(self, parent, animals: dict[str, str], options: Options):
15
13
  super().__init__(parent=parent, object_name="card")
16
14
  self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
17
15
  self.customContextMenuRequested.connect(self._on_context_menu)
@@ -36,9 +34,9 @@ class AnimalCard(CardFrame):
36
34
  layout.addRow(lable_animal_id, self.line_animal_id)
37
35
 
38
36
  label_stage = QLabel("stage", self)
39
- items = ConfigStore(STAGE_PATH, Scenes).value
37
+ items = options.stages
40
38
  self.combo_stage = QComboBox(self)
41
- self.combo_stage.addItems([i for i in items.root])
39
+ self.combo_stage.addItems(items)
42
40
  self.combo_stage.setCurrentText("idle")
43
41
  layout.addRow(label_stage, self.combo_stage)
44
42
 
@@ -1,5 +1,3 @@
1
- from __future__ import annotations
2
-
3
1
  from PySide6.QtCore import Qt
4
2
  from PySide6.QtWidgets import (
5
3
  QComboBox,
@@ -12,7 +10,7 @@ from PySide6.QtWidgets import (
12
10
  )
13
11
 
14
12
  from ...models.animal import AnimalConfig
15
- from ...models.session import RewardEnum, SessionConfig
13
+ from ...models.session import Options, RewardEnum, SessionConfig
16
14
  from .animal import AnimalCard
17
15
 
18
16
 
@@ -51,10 +49,11 @@ class ExperimentConfigGroup(QGroupBox):
51
49
 
52
50
 
53
51
  class ExperimentAnimalsGroup(QGroupBox):
54
- def __init__(self, parent=None, *, animals: dict[str, str]):
52
+ def __init__(self, parent=None, *, animals: dict[str, str], options: Options):
55
53
  super().__init__("Animals", parent)
56
54
 
57
55
  self._animals = animals
56
+ self._options = options
58
57
  self.layout_animals = QGridLayout(self)
59
58
  self.setLayout(self.layout_animals)
60
59
 
@@ -68,7 +67,7 @@ class ExperimentAnimalsGroup(QGroupBox):
68
67
  menu.exec(self.mapToGlobal(pos))
69
68
 
70
69
  def _on_add_animal(self):
71
- animal_card = AnimalCard(self, self._animals)
70
+ animal_card = AnimalCard(self, self._animals, self._options)
72
71
  animal_card.remove_requested.connect(
73
72
  lambda _card=animal_card: self._on_remove_animal(_card)
74
73
  )
@@ -103,7 +102,7 @@ class ExperimentAnimalsGroup(QGroupBox):
103
102
 
104
103
  def load_config(self, config: SessionConfig):
105
104
  for animal_configs in config.animals:
106
- animal_card = AnimalCard(self, self._animals)
105
+ animal_card = AnimalCard(self, self._animals, self._options)
107
106
  animal_card.load_config(animal_configs)
108
107
  animal_card.remove_requested.connect(
109
108
  lambda _card=animal_card: self._on_remove_animal(_card)
@@ -1,6 +1,7 @@
1
+ from pathlib import Path
2
+
1
3
  from PySide6.QtCore import Signal
2
4
  from PySide6.QtWidgets import (
3
- QApplication,
4
5
  QHBoxLayout,
5
6
  QMainWindow,
6
7
  QPushButton,
@@ -10,17 +11,16 @@ from PySide6.QtWidgets import (
10
11
 
11
12
  from ..config_store import ConfigStore
12
13
  from ..models.session import Options, SessionConfig
13
- from ..path import OPTIONS_PATH, SESSION_CONFIG_PATH
14
14
  from .components.experiment_groups import ExperimentAnimalsGroup, ExperimentConfigGroup
15
15
 
16
16
 
17
17
  class ExperimentPanel(QMainWindow):
18
18
  accepted = Signal()
19
19
 
20
- def __init__(self, parent=None):
21
- super().__init__(parent)
22
- self._config = ConfigStore(SESSION_CONFIG_PATH, SessionConfig)
23
- self._options = ConfigStore(OPTIONS_PATH, Options)
20
+ def __init__(self, session_config_path: Path, options_path: Path):
21
+ super().__init__()
22
+ self._config = ConfigStore(session_config_path, SessionConfig)
23
+ self._options = ConfigStore(options_path, Options)
24
24
 
25
25
  self.setWindowTitle("Experiment Panel")
26
26
 
@@ -36,7 +36,7 @@ class ExperimentPanel(QMainWindow):
36
36
  layout_main.addWidget(self.group_config)
37
37
 
38
38
  self.group_animals = ExperimentAnimalsGroup(
39
- self, animals=self._options.value.animals
39
+ self, animals=self._options.value.animals, options=self._options.value
40
40
  )
41
41
  layout_main.addWidget(self.group_animals)
42
42
 
@@ -80,12 +80,3 @@ class ExperimentPanel(QMainWindow):
80
80
  self._on_save()
81
81
  self.close()
82
82
  self.accepted.emit()
83
-
84
-
85
- if __name__ == "__main__":
86
- import sys
87
-
88
- app = QApplication(sys.argv)
89
- experiment_panel = ExperimentPanel()
90
- experiment_panel.show()
91
- sys.exit(app.exec())
mxbiflow/ui/mxbi_panel.py CHANGED
@@ -1,9 +1,10 @@
1
+ from pathlib import Path
2
+
1
3
  from pymxbi import MXBIModel
2
4
  from pymxbi.detector import DetectorEnum, DetectorModel
3
5
  from pymxbi.rewarder import RewarderEnum, RewarderModel
4
6
  from PySide6.QtCore import Signal
5
7
  from PySide6.QtWidgets import (
6
- QApplication,
7
8
  QHBoxLayout,
8
9
  QMainWindow,
9
10
  QPushButton,
@@ -13,7 +14,6 @@ from PySide6.QtWidgets import (
13
14
 
14
15
  from ..config_store import ConfigStore
15
16
  from ..models.session import Options
16
- from ..path import MXBI_CONFIG_PATH, OPTIONS_PATH
17
17
  from .components.baseconfig import BaseConfig
18
18
  from .components.device_card import (
19
19
  BeambreakDetectorCard,
@@ -44,10 +44,10 @@ class MXBIPanel(QMainWindow):
44
44
  # Lifecycle / Init
45
45
  # -----------------------------
46
46
 
47
- def __init__(self):
47
+ def __init__(self, mxbi_config_path: Path, options_path: Path):
48
48
  super().__init__()
49
- self._config = ConfigStore(MXBI_CONFIG_PATH, MXBIModel)
50
- self._options = ConfigStore(OPTIONS_PATH, Options)
49
+ self._config = ConfigStore(mxbi_config_path, MXBIModel)
50
+ self._options = ConfigStore(options_path, Options)
51
51
 
52
52
  self._build_ui()
53
53
  self._load_from_config()
@@ -141,12 +141,3 @@ class MXBIPanel(QMainWindow):
141
141
 
142
142
  def _on_cancel(self) -> None:
143
143
  self.close()
144
-
145
-
146
- if __name__ == "__main__":
147
- import sys
148
-
149
- app = QApplication(sys.argv)
150
- window = MXBIPanel()
151
- window.show()
152
- sys.exit(app.exec())
mxbiflow/ui/utils.py ADDED
@@ -0,0 +1,25 @@
1
+ from pathlib import Path
2
+
3
+ from .experiment_panel import ExperimentPanel
4
+ from .mxbi_panel import MXBIPanel
5
+
6
+
7
+ def config_wizard(
8
+ mxbi_config_path: Path,
9
+ session_config_path: Path,
10
+ options_path: Path,
11
+ ):
12
+ import sys
13
+
14
+ from PySide6.QtWidgets import QApplication
15
+
16
+ app = QApplication(sys.argv)
17
+
18
+ mxbi_panel = MXBIPanel(mxbi_config_path, options_path)
19
+ experiment_panel = ExperimentPanel(session_config_path, options_path)
20
+ mxbi_panel.accepted.connect(experiment_panel.show)
21
+ experiment_panel.accepted.connect(app.quit)
22
+
23
+ mxbi_panel.show()
24
+
25
+ app.exec()
@@ -0,0 +1,35 @@
1
+ from pathlib import Path
2
+
3
+ from ..config_store import ConfigStore
4
+ from ..models.animal import Animal, StageState
5
+ from ..models.session import DailySessionIdStore, Session, SessionConfig
6
+
7
+
8
+ def init_session(session_config_path: Path, session_counter_path: Path) -> Session:
9
+ session_config = ConfigStore(session_config_path, SessionConfig).value
10
+ store = DailySessionIdStore(session_counter_path)
11
+
12
+ animal_dict: dict[str, Animal] = {}
13
+ for animal_config in session_config.animals:
14
+ train_state = StageState(
15
+ stage_name=animal_config.stage, level=animal_config.level
16
+ )
17
+ animal_state = Animal(
18
+ rfid_id=animal_config.rfid_id,
19
+ name=animal_config.name,
20
+ )
21
+ animal_state.set_current_stage(train_state)
22
+ animal_dict[animal_config.name] = animal_state
23
+
24
+ session = Session(
25
+ session_id=store.session_id,
26
+ experimenter=session_config.experimenter,
27
+ reward_type=session_config.reward_type,
28
+ send_email=False,
29
+ sync_data=False,
30
+ note=session_config.note,
31
+ animals=animal_dict,
32
+ )
33
+ session.start()
34
+
35
+ return session
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mxbiflow
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: mxbiflow is a toolkit based on pygame and pymxbi
5
5
  Author: HuYang
6
6
  Author-email: HuYang <huyangcommit@gmail.com>
@@ -1,22 +1,22 @@
1
- mxbiflow/__init__.py,sha256=ozmSVFtsr5ddD7pThZNi_guF59SjTpumU1AuvAWbJK0,85
1
+ mxbiflow/__init__.py,sha256=uCZLH2fpbumtpSogT9a7xVMaQiwOvc4y1Upo_qxQpIw,265
2
2
  mxbiflow/assets/__init__.py,sha256=q4EMjlEE0iRc5LGRC-ecFfHcZVgDZTpcHFvpEv5LpSg,98
3
3
  mxbiflow/assets/clicker.wav,sha256=EigwY1fa3iwx4JEsnur1PUIZBndrwaLCUv7C5FlSOD8,176582
4
4
  mxbiflow/config_store.py,sha256=vVQI4Jv_DTwXL5wg2dvdmzaLuC1OcGDEZjC-GyQ5PW0,2134
5
5
  mxbiflow/data_logger.py,sha256=01LtrBMYcm2zqASXdQJzmwRs6HNUCvtHK6S7TspgFOE,3619
6
- mxbiflow/default/__init__.py,sha256=m4mByPSQBoqPot0ynQcUgK6PiPaCNuWEYQOdnWmkq4U,112
6
+ mxbiflow/default/__init__.py,sha256=Zwt42U7TTqCuxisn8uNgBoSa0UHo8quNKEVxl4xFvpE,48
7
7
  mxbiflow/default/idle/assets/apple_v1.png,sha256=bKrntrgfA82A2vgS5XLL3DEpC7NtY4kYCDoriG9q5Ko,2185277
8
- mxbiflow/default/idle/idle.py,sha256=ZhDzXqmExsTXNuE7GncbNXmj8_VF0XdXsvYvXqJa_Nw,1470
8
+ mxbiflow/default/idle/idle.py,sha256=b409vCjW7YMJ2yTkjA6ReqIw1HpAevd5MiduKDBDREw,1414
9
9
  mxbiflow/detector_bridge.py,sha256=D5hOCt7CgeZ5oReJql588nR-Va2wDMqnFxWieC_EvgU,2840
10
10
  mxbiflow/game.py,sha256=pvsvSt_mfiGloJk-nQB7fDNzS48yOxz6_Ww8hTBcCwk,2439
11
11
  mxbiflow/infra/eventbus.py,sha256=DnAHmRW13Emp6zfeZDJUwbiypHAzPKK62IpuUFOZguo,751
12
- mxbiflow/main.py,sha256=aYvknPr68ZDc-Y-eJi-OfEkA-D9TQPCP5yK80aR1DAw,2935
13
12
  mxbiflow/models/animal.py,sha256=3alb7ZUT-cmGFYE23oVVIAlTV6ye7Es1pRmE62VfH_E,3881
14
13
  mxbiflow/models/reward.py,sha256=gmy6Cb-BPCpYvFmSPBJXUCJKIJQPp5BCJsWv-q0pt2A,138
15
- mxbiflow/models/session.py,sha256=LKTTZ9bpONbsY4oG9MvlvMO2JOjY3-Klc0_KybWvN8Q,4188
14
+ mxbiflow/models/session.py,sha256=6nN9uVZnW9FZfRNobkhFzc32Is4YpPA3FfvWrKsARpY,4240
15
+ mxbiflow/mxbi.py,sha256=_5eAJTKe__gLCCJSuRogyEdUFy7bJHGguZsopVufe1Y,537
16
16
  mxbiflow/mxbiflow.py,sha256=zhkdhlFcpy-1lqH-gHU3QajW5bazf6BeLJtwbqSxKFs,980
17
- mxbiflow/path.py,sha256=UD4FEew3QK6ni6PBiuZ67kyY1wUF2SQyAo_7lMhAGFA,1455
18
- mxbiflow/scene/__init__.py,sha256=PpsHr3KKReFsc-MN3Gj1OmqvCCCQornT0mfdkxRqJtA,160
19
- mxbiflow/scene/scene_manager.py,sha256=D1TN9T-SSeUu33fulTexx6hy0OS4zFuxu8SAUX41blg,1708
17
+ mxbiflow/path.py,sha256=0T2KGlT3ldPLeM0l_UxmnmpMVAoIhvxnlaI6tc2FInk,1259
18
+ mxbiflow/scene/__init__.py,sha256=K9IVRr4pu5IwfU-K6ec7_jidUV31epGPtctI3PxwJMg,138
19
+ mxbiflow/scene/scene_manager.py,sha256=1aNkSXxrXxHtXDU_TgVHevC434TSfOQ9xTTV68Xv3O0,1969
20
20
  mxbiflow/scene/scene_protocol.py,sha256=U3SXoAAues5H8qIeQwY29PRRYAoUhPZMgoC6KDQtK2I,455
21
21
  mxbiflow/scheduler.py,sha256=58lOoqiqpjhciIAyhcC9mTR_LtxwAdBuVUl7Dci3pCk,2536
22
22
  mxbiflow/tasks/GNGSiD/models.py,sha256=cUZMIHRy-fIlA0vxkTObMRfDKsQtsQz2JL54Z9rXcl0,1209
@@ -68,7 +68,7 @@ mxbiflow/timer/__init__.py,sha256=lABOmME2FSR0EHGe-lz4p-d_PCBamZCjPQx0Mr1jwmE,62
68
68
  mxbiflow/timer/frame_timer.py,sha256=Yfx-u_-Qe-HxODVIQYNtA-iwGd0dWckTx_lhaShdZY8,1331
69
69
  mxbiflow/timer/realtime_timer.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
70
70
  mxbiflow/tmp_email.py,sha256=A7GpHoMIi9JjoKD10z4ohD6Mz-2D9lMLQvuP08H9zys,448
71
- mxbiflow/ui/components/animal.py,sha256=4YQ6VF5ts1u96wmux_Kn3JLAhjJ9_s7nMtgtqXOy6LY,3269
71
+ mxbiflow/ui/components/animal.py,sha256=Qh8ui3dlCJLk7Fh3cBIyBTZTWYaAigxpiBfzYc0Awxg,3185
72
72
  mxbiflow/ui/components/baseconfig.py,sha256=rjsErRi7NZAO3Yb_5l8YCd1g7bPDyb0R85FaJoXvi-c,2297
73
73
  mxbiflow/ui/components/card.py,sha256=LdI99dL3S21y72KOkbFD0ByiDuMk4ptuST3m5q2OOcc,484
74
74
  mxbiflow/ui/components/device_card/__init__.py,sha256=m6cwCdcppCEXTBRa0VQXG1HtgkYNrusQKoUgO1_IkI4,569
@@ -82,12 +82,14 @@ mxbiflow/ui/components/device_card/rewarder/rpi_gpio_rewarder.py,sha256=lf18Oqx7
82
82
  mxbiflow/ui/components/devices.py,sha256=1r8D0OBBdyXEBkkmd96Ir6OqarRSxzWiq8ZJgdGMOfY,5351
83
83
  mxbiflow/ui/components/dialog/__init__.py,sha256=N_P4NFqf7H10XbWV6tkc5PJR-aT-huXFfD9D2eUCpv0,79
84
84
  mxbiflow/ui/components/dialog/add_devices_dialog.py,sha256=DrcDfBOQZzjARlj-K9kSFQGriOdo6Q7oIf2Zr1SNX-s,1737
85
- mxbiflow/ui/components/experiment_groups.py,sha256=9CwJ4g4cfhKv3-JO5y9Qv-HlJfGB_gcBQEtNola2zdM,4258
86
- mxbiflow/ui/experiment_panel.py,sha256=LOsOsYT7GwOEl0p6XXWvYoF-ugua6QySB8maXTnjNRw,2824
87
- mxbiflow/ui/mxbi_panel.py,sha256=jLET_x2KGTo4Fr4XN0qo2mV7052QlD5M3Tzt1CKlNLk,4828
85
+ mxbiflow/ui/components/experiment_groups.py,sha256=S8XeKNW9okX98RwLKNdZfZmSa1SOaoK2hoRo69HYSVs,4311
86
+ mxbiflow/ui/experiment_panel.py,sha256=EzEuKZZht0cnJuW5ltswUIH9dl_p0q8cX9svRge5AUc,2664
87
+ mxbiflow/ui/mxbi_panel.py,sha256=b2f9hPbYJ3HLr2-17yssZJqSNuBfmBpylP9j5CMe2Vg,4684
88
+ mxbiflow/ui/utils.py,sha256=L5PgKQrKAKcwFqNFvCZtz5CBcwSKUL5Vk4v5NszJILM,586
89
+ mxbiflow/utils/init_session.py,sha256=orFr5R1c1Fe4ykUpF0OyvWH8tbtZcaXeH2V8M3kuGLM,1151
88
90
  mxbiflow/utils/logger.py,sha256=6pMngPkcs-TWfHbI3I75mNqvTXQCFEFjXL8t2DNhoNE,296
89
91
  mxbiflow/utils/serial.py,sha256=xAOymmyoU6JvOTC0HFL3DK1tVkTiXPLsC0plLZYMLKA,274
90
- mxbiflow-0.1.1.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
91
- mxbiflow-0.1.1.dist-info/entry_points.txt,sha256=cGSAdRH0zM2dvODbfV1or4Hdhxpq7j6eyEjnV2dYaeE,62
92
- mxbiflow-0.1.1.dist-info/METADATA,sha256=Ag6-jZjo4rVZmdzHcHMPziFtZ0NPrtwszbBPqu9er14,5869
93
- mxbiflow-0.1.1.dist-info/RECORD,,
92
+ mxbiflow-0.1.2.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
93
+ mxbiflow-0.1.2.dist-info/entry_points.txt,sha256=cGSAdRH0zM2dvODbfV1or4Hdhxpq7j6eyEjnV2dYaeE,62
94
+ mxbiflow-0.1.2.dist-info/METADATA,sha256=r3fRDEfY4hRYdTrPiSbvuin3r-R_CPokG2bu8L4TPAQ,5869
95
+ mxbiflow-0.1.2.dist-info/RECORD,,
mxbiflow/main.py DELETED
@@ -1,106 +0,0 @@
1
- from pymxbi import MXBI
2
-
3
- from .game import Game
4
- from .models.session import Session
5
-
6
-
7
- def main():
8
- run_config()
9
-
10
- mxbi = build_mxbi()
11
-
12
- session = init_session()
13
-
14
- game = init_mxbiflow(mxbi, session)
15
- game.play()
16
-
17
-
18
- def run_config():
19
- import sys
20
-
21
- from PySide6.QtWidgets import QApplication
22
-
23
- from .ui.experiment_panel import ExperimentPanel
24
- from .ui.mxbi_panel import MXBIPanel
25
-
26
- app = QApplication(sys.argv)
27
-
28
- mxbi_panel = MXBIPanel()
29
- experiment_panel = ExperimentPanel()
30
- mxbi_panel.accepted.connect(experiment_panel.show)
31
- experiment_panel.accepted.connect(app.quit)
32
-
33
- mxbi_panel.show()
34
-
35
- app.exec()
36
-
37
-
38
- def build_mxbi() -> MXBI:
39
- from loguru import logger
40
- from pymxbi import MXBIModel, build_mxbi
41
-
42
- from .config_store import ConfigStore
43
- from .models.session import SessionConfig
44
- from .path import MXBI_CONFIG_PATH, SESSION_CONFIG_PATH
45
-
46
- mxbi_config = ConfigStore(MXBI_CONFIG_PATH, MXBIModel).value
47
- session_config = ConfigStore(SESSION_CONFIG_PATH, SessionConfig).value
48
-
49
- mxbi = build_mxbi(mxbi_config, logger)
50
- mxbi.register_animal(
51
- {animal.rfid_id: animal.name for animal in session_config.animals}
52
- )
53
-
54
- return mxbi
55
-
56
-
57
- def init_session() -> Session:
58
- from .config_store import ConfigStore
59
- from .models.animal import Animal, StageState
60
- from .models.session import DailySessionIdStore, Session, SessionConfig
61
- from .path import SESSION_CONFIG_PATH, SESSION_COUNTER_PATH
62
-
63
- session_config = ConfigStore(SESSION_CONFIG_PATH, SessionConfig).value
64
- store = DailySessionIdStore(SESSION_COUNTER_PATH)
65
-
66
- animal_dict: dict[str, Animal] = {}
67
- for animal_config in session_config.animals:
68
- train_state = StageState(
69
- stage_name=animal_config.stage, level=animal_config.level
70
- )
71
- animal_state = Animal(
72
- rfid_id=animal_config.rfid_id,
73
- name=animal_config.name,
74
- )
75
- animal_state.set_current_stage(train_state)
76
- animal_dict[animal_config.name] = animal_state
77
-
78
- session = Session(
79
- session_id=store.session_id,
80
- experimenter=session_config.experimenter,
81
- reward_type=session_config.reward_type,
82
- send_email=False,
83
- sync_data=False,
84
- note=session_config.note,
85
- animals=animal_dict,
86
- )
87
- session.start()
88
- print(session.session_id)
89
-
90
- return session
91
-
92
-
93
- def init_mxbiflow(mxbi, session) -> Game:
94
- from .default import IDLE, Habituarion
95
- from .detector_bridge import DetectorBridge
96
- from .GNGSiD import SizeReduction
97
- from .path import STAGE_PATH
98
- from .scene import SceneManager
99
-
100
- scene_manager = SceneManager()
101
- scene_manager.register(Habituarion)
102
- scene_manager.register(IDLE)
103
- scene_manager.register(SizeReduction)
104
- scene_manager.persist(STAGE_PATH)
105
- detector_bridge = DetectorBridge(mxbi.detector)
106
- return Game(session, scene_manager, detector_bridge, mxbi)