Skip to content

Commit 6e210c7

Browse files
authored
237 do all imports at the start (#284)
* Removed matrix versions * Removed usages of importlib * Load DLL in __init__ * Version bumpb * Updated README and security notice * Updated OSS note
1 parent 0ecb725 commit 6e210c7

File tree

7 files changed

+34
-35
lines changed

7 files changed

+34
-35
lines changed

.github/SECURITY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ This project is in its early stages, and we are open to suggestions and contribu
66

77
| Version | Supported |
88
|---------|--------------------|
9-
| 0.0.1 | :white_check_mark: |
9+
| 1.1.x | :white_check_mark: |
10+
| 1.0.x | :x: |
1011

1112
## Reporting a Vulnerability
1213

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ Socket.IO-compliant application (such
1414
as [Pinpoint](https://github.com/VirtualBrainLab/Pinpoint))
1515
to communicate with manipulators used in electrophysiology experiments.
1616

17-
Currently, Ephys Link only supports Sensapex uMp-4 and uMp-3 Micromanipulators and New Scale 3-axis
18-
manipulators. However, this platform is designed to be extensible to other
19-
manipulators and more may be added in the future.
17+
**Supported Manipulators:**
18+
19+
| Manufacturer | Model |
20+
|--------------|-------------------------------------------------------------------|
21+
| Sensapex | <ul> <li>uMp-4</li> <li>uMp-3</li> </ul> |
22+
| New Scale | <ul> <li>Pathfinder MPM Control</li> <li>M3-USB-3:1-EP</li> </ul> |
23+
24+
Ephys Link is an open and extensible platform. It is designed to easily support integration with other manipulators.
2025

2126
For more information regarding the server's implementation and how the code is organized, see
2227
the [package's development documentation](https://virtualbrainlab.org/ephys_link/development.html).
@@ -31,7 +36,8 @@ the [API reference](https://virtualbrainlab.org/api_reference_ephys_link.html).
3136
1. [Python ≥ 3.8, < 3.13](https://www.python.org/downloads/release/python-3116/)
3237
1. Python 3.12+ requires the latest version
3338
of Microsoft Visual C++ (MSVC v143+ x86/64) and the Windows SDK (10/11) to
34-
be installed. They can be acquired through the [Visual Studio Build Tools Installer](https://visualstudio.microsoft.com/visual-cpp-build-tools/).
39+
be installed. They can be acquired through
40+
the [Visual Studio Build Tools Installer](https://visualstudio.microsoft.com/visual-cpp-build-tools/).
3541
2. An **x86 Windows PC is required** to run the server.
3642
3. For Sensapex devices, the controller unit must be connected via an ethernet
3743
cable and powered. A USB-to-ethernet adapter is acceptable. For New Scale manipulators,
@@ -76,7 +82,7 @@ pip install --upgrade ephys-link
7682
```bash
7783
hatch shell
7884
```
79-
85+
8086
This will create a virtual environment and install the package in editable mode.
8187

8288
# Usage

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ cov = [
7272
"cov-report",
7373
]
7474

75-
[[tool.hatch.envs.all.matrix]]
76-
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
75+
#[[tool.hatch.envs.all.matrix]]
76+
#python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
7777

7878
[tool.hatch.envs.types]
7979
dependencies = [

src/ephys_link/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.1.0"
1+
__version__ = "1.1.1"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import clr
2+
3+
# Load New Scale API
4+
# noinspection PyUnresolvedReferences
5+
clr.AddReference("ephys_link/resources/NstMotorCtrl")

src/ephys_link/platforms/new_scale_handler.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
from __future__ import annotations
99

10-
import importlib
1110
from typing import TYPE_CHECKING
1211

13-
# noinspection PyPackageRequirements
14-
import clr
12+
# noinspection PyUnresolvedReferences
13+
from NstMotorCtrl import NstCtrlHostIntf
1514

1615
from ephys_link import common as com
1716
from ephys_link.platform_handler import PlatformHandler
17+
from ephys_link.platforms.new_scale_manipulator import NewScaleManipulator
1818

1919
if TYPE_CHECKING:
2020
import socketio
@@ -30,12 +30,6 @@ def __init__(self) -> None:
3030
self.num_axes = 3
3131
self.dimensions = [15, 15, 15]
3232

33-
# Load New Scale API
34-
# noinspection PyUnresolvedReferences
35-
clr.AddReference("ephys_link/resources/NstMotorCtrl")
36-
# noinspection PyUnresolvedReferences
37-
from NstMotorCtrl import NstCtrlHostIntf
38-
3933
self.ctrl = NstCtrlHostIntf()
4034

4135
# Connect manipulators and initialize
@@ -63,9 +57,7 @@ def _register_manipulator(self, manipulator_id: str) -> None:
6357

6458
# Register manipulator
6559
first_axis_index = int(manipulator_id) * 3
66-
self.manipulators[manipulator_id] = importlib.import_module(
67-
"ephys_link.platforms.new_scale_manipulator"
68-
).NewScaleManipulator(
60+
self.manipulators[manipulator_id] = NewScaleManipulator(
6961
manipulator_id,
7062
self.ctrl.GetAxis(first_axis_index),
7163
self.ctrl.GetAxis(first_axis_index + 1),

src/ephys_link/server.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,24 @@
99
4. Relay the response from :mod:`ephys_link.sensapex_handler` to the callback function
1010
"""
1111

12-
import importlib
1312
import json
1413
import sys
1514
from typing import TYPE_CHECKING, Any
1615

1716
import socketio
1817
from aiohttp import web
1918
from aiohttp.web_runner import GracefulExit
20-
from pythonnet import load
2119

2220
from ephys_link import common as com
2321
from ephys_link.__about__ import __version__ as version
22+
from ephys_link.platforms.new_scale_handler import NewScaleHandler
23+
from ephys_link.platforms.new_scale_pathfinder_handler import NewScalePathfinderHandler
24+
from ephys_link.platforms.sensapex_handler import SensapexHandler
25+
from ephys_link.platforms.ump3_handler import UMP3Handler
2426

2527
if TYPE_CHECKING:
2628
from ephys_link.platform_handler import PlatformHandler
2729

28-
# Setup server
29-
load("netfx")
30-
3130

3231
class Server:
3332
def __init__(self):
@@ -42,9 +41,7 @@ def __init__(self):
4241
self.is_running = False
4342

4443
# Current platform handler (defaults to Sensapex)
45-
self.platform: PlatformHandler = importlib.import_module(
46-
"ephys_link.platforms.sensapex_handler"
47-
).SensapexHandler()
44+
self.platform: PlatformHandler = SensapexHandler()
4845

4946
# Attach server to the web app
5047
self.sio.attach(self.app)
@@ -366,16 +363,14 @@ def launch_server(self, platform_type: str, server_port: int, pathfinder_port: i
366363

367364
# Import correct manipulator handler
368365
if platform_type == "sensapex":
369-
# Already imported (was the default)
366+
# Already assigned (was the default)
370367
pass
371368
elif platform_type == "ump3":
372-
self.platform = importlib.import_module("ephys_link.platforms.ump3_handler").UMP3Handler()
369+
self.platform = UMP3Handler()
373370
elif platform_type == "new_scale":
374-
self.platform = importlib.import_module("ephys_link.platforms.new_scale_handler").NewScaleHandler()
371+
self.platform = NewScaleHandler()
375372
elif platform_type == "new_scale_pathfinder":
376-
self.platform = importlib.import_module(
377-
"ephys_link.platforms.new_scale_pathfinder_handler"
378-
).NewScalePathfinderHandler(pathfinder_port)
373+
self.platform = NewScalePathfinderHandler(pathfinder_port)
379374
else:
380375
sys.exit(f"[ERROR]\t\t Invalid manipulator type: {platform_type}")
381376

0 commit comments

Comments
 (0)