Skip to content

Commit 78371d0

Browse files
Fix noted bugs from out-of-date imports
1 parent 87c9ebf commit 78371d0

File tree

11 files changed

+56
-30
lines changed

11 files changed

+56
-30
lines changed

oshconnect/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
# Contact Email: [email protected]
66
# ==============================================================================
77

8-
class Example:
9-
pass
8+
from .oshconnectapi import OSHConnect, Node
9+
from .osh_connect_datamodels import System, Node, Datastream, Observation, ControlChannel
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# import commands
2+
# import control_channels
3+
# import datastreams
4+
# import observations
5+
# import system_events
6+
# import system_history

oshconnect/datamodels/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# import api_utils
2+
# import commands
3+
# import control_streams
4+
# import datastreams
5+
# import encoding
6+
# import geometry
7+
# import network_properties
8+
# import observations
9+
# import swe_components
10+
# import system_events_and_history

oshconnect/datamodels/geometry.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from pydantic import BaseModel, Field
22

33
from oshconnect.csapi4py.constants import GeometryTypes
4+
from shapely import Geometry
45

56

67
# TODO: Add specific validations for each type
7-
# TODO: update to either use third party Geometry definitions or create a more robust definition
8+
# TODO: determine if serializing 'shapely' objects gives valid JSON structures from our own serialization
89
class Geometry(BaseModel):
910
"""
1011
A class to represent the geometry of a feature

oshconnect/datasource.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from oshconnect.datamodels.swe_components import DataRecordSchema
2222

2323
from .core_datamodels import DatastreamResource, SystemResource, TimePeriod
24-
from .timemanagement import TemporalModes
24+
from .timemanagement import TemporalModes, Synchronizer
2525

2626

2727
# from swecommondm.component_implementations import DataRecord
@@ -48,6 +48,7 @@ class DataStream:
4848
_playback_websocket: websockets.WebSocketClientProtocol = None
4949
_extra_headers: dict = None
5050
_result_schema: DataRecordSchema = None
51+
_synchronizer: Synchronizer = None
5152

5253
def __init__(self, name: str, datastream: DatastreamResource,
5354
parent_system: SystemResource):

oshconnect/oshconnectapi.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import shelve
99

1010
from oshconnect.csapi4py.core.default_api_helpers import APIHelper
11-
1211
from .core_datamodels import DatastreamResource, TimePeriod
1312
from .datasource import DataStream, DataStreamHandler, MessageWrapper
1413
from .datastore import DataStore
@@ -26,7 +25,7 @@ class OSHConnect:
2625
_systems: list[System] = []
2726
_cs_api_builder: APIHelper = None
2827
_datasource_handler: DataStreamHandler = None
29-
_datafeeds: list[DataStream] = []
28+
_datastreams: list[DataStream] = []
3029
_datataskers: list[DataStore] = []
3130
_datagroups: list = []
3231
_tasks: list = []
@@ -150,7 +149,7 @@ def discover_datastreams(self):
150149
DataStream(name=ds.name, datastream=ds, parent_system=system)
151150
for ds in
152151
res_datastreams]
153-
self._datafeeds.extend(new_datasource)
152+
self._datastreams.extend(new_datasource)
154153
list(map(self._datasource_handler.add_datasource, new_datasource))
155154

156155
def discover_systems(self, nodes: list[str] = None):
@@ -199,7 +198,7 @@ def get_message_list(self) -> list[MessageWrapper]:
199198
"""
200199
return self._datasource_handler.get_messages()
201200

202-
def insert_system(self, system: System, target_node: Node):
201+
def _insert_system(self, system: System, target_node: Node):
203202
"""
204203
Create a system on the target node.
205204
:param system: System object
@@ -227,7 +226,7 @@ def insert_datastream(self, datastream: DatastreamResource, system: str | System
227226

228227
sys_obj.add_insert_datastream(datastream)
229228

230-
self._datafeeds.append(datastream)
229+
self._datastreams.append(datastream)
231230

232231
def find_system(self, system_id: str) -> System | None:
233232
"""
@@ -270,3 +269,7 @@ def create_and_insert_system(self, system_opts: dict, target_node: Node):
270269

271270
def remove_system(self, system_id: str):
272271
pass
272+
273+
# DataStream Helpers
274+
def get_datastreams(self) -> list[DataStream]:
275+
return self._datastreams

oshconnect/timemanagement.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,6 @@ def does_timeperiod_overlap(self, checked_timeperiod: TimePeriod) -> bool:
299299
return True
300300

301301

302-
class Utilities:
303-
pass
304-
# @staticmethod
305-
# def parse_systems_result(result) -> System:
306-
307-
308302
class TimeManagement:
309303
time_range: TimePeriod
310304
time_controller: TimeController
@@ -329,6 +323,7 @@ class TimeController:
329323
_timeline_begin: TimeInstant
330324
_timeline_end: TimeInstant
331325
_current_time: TimeInstant
326+
_synchronizer: Synchronizer
332327

333328
def __new__(cls, *args, **kwargs):
334329
if cls._instance is None:
@@ -420,6 +415,10 @@ def _compute_time_range(self):
420415

421416
class Synchronizer:
422417
_buffer: any
418+
_buffering_time: int
423419

424420
def synchronize(self, systems: list):
425421
pass
422+
423+
def check_in_sync(self):
424+
pass

pyproject.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "oshconnect"
3-
version = "0.2.4-1"
3+
version = "0.3.0a1"
44
description = "Library for interfacing with OSH, helping guide visualization efforts, and providing a place to store configurations."
55
readme = "README.md"
66
authors = [
@@ -9,17 +9,17 @@ authors = [
99
requires-python = "<4.0,>=3.12"
1010
dependencies = [
1111
"paho-mqtt>=2.1.0",
12-
"pydantic<3.0.0,>=2.7.4",
13-
"shapely<3.0.0,>=2.0.4",
14-
"websockets<13.0,>=12.0",
12+
"pydantic>=2.7.4,<3.0.0",
13+
"shapely>=2.0.4,<3.0.0",
14+
"websockets>=12.0,<16.0",
1515
]
1616

1717
[dependency-groups]
1818
dev = [
19-
"pytest<9.0.0,>=8.2.2",
20-
"sphinx<8.0.0,>=7.3.7",
21-
"flake8<8.0.0,>=7.1.0",
22-
"sphinx-rtd-theme<3.0.0,>=2.0.0",
19+
"flake8>=7.2.0",
20+
"pytest>=8.3.5",
21+
"sphinx>=7.4.7",
22+
"sphinx-rtd-theme>=2.0.0",
2323
]
2424

2525
[tool.setuptools]

tests/test_api_update.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import pytest
2+
3+
from oshconnect import OSHConnect, System, Node, Datastream
4+
5+
node = Node()
6+
app = OSHConnect()

tests/test_oshconnect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_oshconnect_find_datastreams(self):
6868
app.discover_systems()
6969

7070
app.discover_datastreams()
71-
assert len(app._datafeeds) > 0
71+
assert len(app._datastreams) > 0
7272

7373
async def test_obs_ws_stream(self):
7474
ds_url = ("ws://localhost:8585/sensorhub/api/datastreams/e07n5sbjqvalm/observations?f=application%2Fjson"

0 commit comments

Comments
 (0)