diff --git a/docs/source/tutorial.rst b/docs/source/tutorial.rst index 1b0473a..43d1d73 100644 --- a/docs/source/tutorial.rst +++ b/docs/source/tutorial.rst @@ -156,7 +156,7 @@ datastream schemas. A TimeSchema is required to be the first field in the DataRecordSchema for OSH. Inserting an Observation into and OpenSensorHub Node ------------------------------------------ +----------------------------------------------------- Upon successfully adding a new datastream to a system, it is now possible to send observation data to the node. .. code-block:: python diff --git a/oshconnect/core_datamodels.py b/oshconnect/core_datamodels.py index f070316..1a05072 100644 --- a/oshconnect/core_datamodels.py +++ b/oshconnect/core_datamodels.py @@ -8,7 +8,8 @@ from typing import List -from conSys4Py import DatastreamSchema, Geometry +from conSys4Py.datamodels.swe_components import Geometry +from conSys4Py.datamodels.datastreams import DatastreamSchema from conSys4Py.datamodels.api_utils import Link from pydantic import BaseModel, ConfigDict, Field, SerializeAsAny from shapely import Point diff --git a/oshconnect/datasource.py b/oshconnect/datasource.py index 6ac802c..e937b3b 100644 --- a/oshconnect/datasource.py +++ b/oshconnect/datasource.py @@ -16,7 +16,7 @@ import requests import websockets -from conSys4Py import APIResourceTypes +from conSys4Py.constants import APIResourceTypes from conSys4Py.datamodels.observations import ObservationOMJSONInline from conSys4Py.datamodels.swe_components import DataRecordSchema diff --git a/oshconnect/osh_connect_datamodels.py b/oshconnect/osh_connect_datamodels.py index 4a3f9c9..e89dda6 100644 --- a/oshconnect/osh_connect_datamodels.py +++ b/oshconnect/osh_connect_datamodels.py @@ -10,10 +10,11 @@ import uuid from dataclasses import dataclass, field -from conSys4Py import APIResourceTypes, DataRecordSchema +from conSys4Py.constants import APIResourceTypes from conSys4Py.core.default_api_helpers import APIHelper from conSys4Py.datamodels.datastreams import SWEDatastreamSchema from conSys4Py.datamodels.encoding import JSONEncoding +from conSys4Py.datamodels.swe_components import DataRecordSchema from .core_datamodels import DatastreamResource, ObservationResource, SystemResource from .timemanagement import TimeInstant, TimePeriod, TimeUtils @@ -188,7 +189,9 @@ def from_system_resource(system_resource: SystemResource): # case 1: has properties a la geojson if 'properties' in other_props: new_system = System(name=other_props['properties']['name'], - label=other_props['properties']['name']) + label=other_props['properties']['name'], + urn=other_props['properties']['uid'], + resource_id=system_resource.system_id) else: new_system = System(name=system_resource.name, label=system_resource.label, urn=system_resource.urn, diff --git a/pyproject.toml b/pyproject.toml index e1e3d89..bd50c03 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ readme = "README.md" [tool.poetry.dependencies] python = "^3.12" -consys4py = { git = "https://github.com/Botts-Innovative-Research/CSAPI4Py.git", branch = "dev" } +conSys4Py = { git = "https://github.com/Botts-Innovative-Research/CSAPI4Py.git", branch = "dev" } swecommondm = { git = "https://github.com/ChainReaction31/SWECommonDMPython.git", branch = "master" } pydantic = "^2.7.4" shapely = "^2.0.4" diff --git a/tests/test_oshconnect.py b/tests/test_oshconnect.py index d3b664c..29013e4 100644 --- a/tests/test_oshconnect.py +++ b/tests/test_oshconnect.py @@ -14,6 +14,7 @@ class TestOSHConnect: + TEST_PORT = 8282 def test_time_period(self): tp = TimePeriod(start="2024-06-18T15:46:32Z", end="2024-06-18T20:00:00Z") @@ -44,7 +45,7 @@ def test_oshconnect_create(self): def test_oshconnect_add_node(self): app = OSHConnect(name="Test OSH Connect") - node = Node(address="http://localhost", port=8585) + node = Node(address="http://localhost", port=self.TEST_PORT, protocol="http", username="admin", password="admin") # node.add_basicauth("admin", "admin") app.add_node(node) assert len(app._nodes) == 1 @@ -52,7 +53,7 @@ def test_oshconnect_add_node(self): def test_find_systems(self): app = OSHConnect(name="Test OSH Connect") - node = Node(address="localhost", port=8585, username="admin", password="admin", protocol="http") + node = Node(address="localhost", port=self.TEST_PORT, username="admin", password="admin", protocol="http") # node.add_basicauth("admin", "admin") app.add_node(node) app.discover_systems() @@ -62,7 +63,7 @@ def test_find_systems(self): def test_oshconnect_find_datastreams(self): app = OSHConnect(name="Test OSH Connect") - node = Node(address="localhost", port=8585, username="admin", password="admin", protocol="http") + node = Node(address="localhost", port=self.TEST_PORT, username="admin", password="admin", protocol="http") app.add_node(node) app.discover_systems()