diff --git a/README.md b/README.md index 689839eb40f343e1816d9eacac27486de9d7cec6..2bb78a81fe33cb4d5c298687c3df13378348310e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ #### Versions -```0.0.1``` : Intial version with only the API for insertion and query. +```0.0.16``` : Intial version with only the API for insertion and query. | Element | Status | Comment | |:--- |:--- |:--- | @@ -15,7 +15,7 @@ | chain tools | ⌠| in-process | -#### 1 [Python API](src/doc/python-api.md#python-api-concept) +#### 1 [Python API](src/doc/python-api.md) #### 2 [Background](src/doc/background.md) diff --git a/pyproject.toml b/pyproject.toml index 01d9883c01804f6512d48d000ac0828496e1cbe0..660d82c18863f9de3b0805909a1f2c86258707fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "semantic-api" -version = "0.0.1" +version = "0.0.16" dependencies = [ "behave == 1.2.6", "paho-mqtt == 2.1.0", @@ -17,7 +17,25 @@ authors = [ { name="William A Coolidge", email="wac@mmmi.sdu.dk" }, ] description = "A simple python API for creating, inserting, querying, and processing semantic data. This requires semantic services that are not included here" -readme = "README.md" +dynamic = ["readme"] + +[build-system] +requires = ["hatchling", "hatch-fancy-pypi-readme"] +build-backend = "hatchling.build" + +[tool.hatch.metadata.hooks.fancy-pypi-readme] +content-type = "text/markdown" + +[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]] +path = "README.md" + +[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]] +# replace relative links with absolute links +pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)' +replacement = '[\1](https://source.coderefinery.org/wac/semantic-api/src/doc/\g<2>)' + + + requires-python = ">=3.8" classifiers = [ "Programming Language :: Python :: 3", @@ -25,14 +43,41 @@ classifiers = [ ] license = {text="Apache Licenses 2.0"} license-files = ["LICEN[CS]E*"] -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" + + + +[tool.hatch.build.targets.wheel] +only-include = ["src"] + +[tool.hatch.build.targets.wheel.sources] +"src/semantic" = "semantic" + +[tool.hatch.build.targets.sdist] +# Basically everything except hidden files/directories (such as .github, .devcontainers, .python-version, etc) +include = [ + "/*.toml", + "/*.json", + "/*.lock", + "/*.md", + "/*.svg", + "/mypy.ini", + "/noxfile.py", + "bin/*", + "examples/*", + "src/*", + "tests/*" +] [project.urls] -Homepage = "https://github.com/pypa/sampleproject" -Issues = "https://github.com/pypa/sampleproject/issues" +Homepage = "https://source.coderefinery.org/wac/semantic-api" +Issues = "https://source.coderefinery.org/wac/semantic-api/-/issues" + +[tool.behave] +stderr_capture=false +stdout_capture=false +log_capture=false +paths=["tests"] diff --git a/src/doc/background.md b/src/doc/background.md index f3872aa083d4c593e9e7126126f8d422495e1d7a..4e83e1ad0d1e3a5d6d4a4630a4336c857603146d 100644 --- a/src/doc/background.md +++ b/src/doc/background.md @@ -65,6 +65,3 @@ System wide ontologies and local programming with types are expeced to be exploi - reasoning: exploit reasoning on types and type properties to create knowledge bases - empirical models: use bottom up techniques, both classical and machine learning techniques to validate if not inform symbolic types -[NEXT](rdf-and-types.md) - -[HOME](../../README.md) \ No newline at end of file diff --git a/src/doc/editing-ontologies.md b/src/doc/editing-ontologies.md index 34fbc20ecbc3e4263b5aaeaa63939c6fa68e835b..5c3838e5c3074b75782e1861ff7a4ddaa3e4fd50 100644 --- a/src/doc/editing-ontologies.md +++ b/src/doc/editing-ontologies.md @@ -153,9 +153,4 @@ The format shall follow ```<schema name><schema version>-<instance name>``` wher (***) generated .svg files are placed in ```/srv/workspace/artifacts``` - - - -[NEXT](python-api.md) - -[BACK](rdf-and-types.md) \ No newline at end of file + \ No newline at end of file diff --git a/src/ontologies/clusters/core/facilityCobot-v022-core-cluster.svg b/src/doc/facilityCobot-v022-core-cluster.svg similarity index 100% rename from src/ontologies/clusters/core/facilityCobot-v022-core-cluster.svg rename to src/doc/facilityCobot-v022-core-cluster.svg diff --git a/src/doc/ontologies.md b/src/doc/ontologies.md deleted file mode 100644 index 1bc9b8bdc3a061d3c75b032e1c12f5af388b86f7..0000000000000000000000000000000000000000 --- a/src/doc/ontologies.md +++ /dev/null @@ -1,82 +0,0 @@ - -## 3 Ontologies - -This [curated list](https://github.com/ozekik/awesome-ontology?tab=readme-ov-file) is a reasonable listing of ontology related items. - -We are following a subset of the [SOMA Ontology](https://ease-crc.github.io/soma/) in the FERA project. The OWL for SOMA can be found [here](https://github.com/ease-crc/soma/tree/master/owl). The related research articles out of M Beetz's Bremman group can be found [here](https://ease-crc.org/publications/). - -The [NEEM Handbood](https://ease-crc.org/publications/) is recommended reading as it does a good job of addressing issues concerning the design and use of the ontology. - -Most ontologies are defined in OWL and a parser to generate a schema of types (not triples) is in progress. The current DUL ontology that follows was translated manually from [SOMA DUL](https://github.com/ease-crc/soma/blob/master/owl/DUL.owl) - -With the excpetion of FFU and the initial I4 effort which were defined in one monolithic schema, ontologies are defined here by an ordered array of clusters, each cluster containing one or more type definitions. - -Types (and hence its cluster) may inherit from another cluster or contain a predicate where the object type is defined in another cluster. - -Clusters are a convenient way of layering and partioning concerns. - -Care should be made to try and avoid blurring horizontal sibling or parallel concerns, nor mixing in the vertical layers and placing an abstraction at the wrong level. - -***Postulate***: Each cluster level should use abstract types from parent layers to create either abstract, or concrete types for the specialized layer, only adding abstract types to the parent layer if the generalization belongs there. - -In the following we use the term ***schema*** to refer to a specific ontology that defines a database schema. - -A schema is an ontology built as original types, or an edited set of types from other ontologies, that targets a specific use-case or world model. - -Each schema is identified by a schema name, a schema version and a set a clusters, each with one or more types. - -A database instance is created and populated with the clusters corresponding to the this schema's name and version. - -A database instance includes and extra database instance identifier `schemaName-schemaVersion-instanceName` to handle multiple database instances for the same `schemaName-SchemaVersion` ontology. - -The following sub-sections name the current schemas that have been developed, followed by sub-sections on the clusters that make up these schemas. - -#### 3.1 FFU -The first project was the FFU (BioBanking) where ontologies were targeted for: - - safety critical system (for FDA device approval), both developmental and operational - - ontologically defined authorization policies securing various levels of access to biobank resources - - medical ontologies defiing biobank content - -The FFU was based on the core [IHMC Ontologies](https://ontology.ihmc.us/ontology.html) - -The FFU project demonstrated the need for maintainable and lightweight middleware (KaOS was neither). - -#### 3.2 FERA - -The FERA schema is defined in 7 clusters [base](#51-base), [dul](#52-dul), [usd](#53-usd), [usdvalue](#54-usd-value), [fera](#55-fera), [assembly](#56-assembly), and [machine-tending](#57-machine-tending). - -The clusters are layered: - -**base** → **usd** → **dul** → **fera** → [**assembly**, **machine-tending**]; - -where **usd** has a local dependency on **usd-value** - -The cluster for **assembly** and **machine-tending** are layered under **fera** and can either be used in one **fera** schema assuming no type collisions, or split into two schemas **fera-assembly**, and **fera-machine-tending** - - -#### 3.3 Facility Cobot - -Prior to FERA the root cluster was the [core](#61-core) cluster such that all clusters prior to FERA are interoperable. - -The equivalents in DUL to core are conceptually similar such the non FERA clusters can be ported to use under DUL and USD. - -The Facility Cobot schema is defined in 5 clusters [core](#61-core), [vision](#v62-vision), [policy](#63-policy), [ros](#64-ros), and [fc](#65-facility-cobot). - - - -#### 3.4 Digitech - -The Digitech schema is defined in 5 clusters [core](#71-core), [product](#v72-product), [i4](#73-i4), [ros](#74-ros), [urdf](#75-urdf), [plant](#76-plant), and [digitech](#77-digitech). - -#### 3.3 All: Additional Core based Clusters - -In addition to the clusters of the schemas `Facility Cobot` and `Digitech`, there are 6 other clusters that can be mixed in. - -[srdf](#81-srdf), [plant](#v82-plant), [bdd](#83-bdd), [sw](#84-sw), [metric](#85-metric), and [otlp](#86-otlp) - - - -[NEXT](clusters.md) - -[BACK](../README.md) - diff --git a/src/doc/python-api.md b/src/doc/python-api.md index 2965dc204505a40e6e7bea4acc6f2ebe95a37e13..4f27a02b7fc0c9d87e4ee6528038af54f600af23 100755 --- a/src/doc/python-api.md +++ b/src/doc/python-api.md @@ -390,7 +390,3 @@ User: Were the in-hand pose differs with the expected grasp pose with more than ``` --> - -[NEXT](usd-framing.md) - -[HOME](../../README.md) \ No newline at end of file diff --git a/src/doc/rdf-and-types.md b/src/doc/rdf-and-types.md index 94db489295ae8aa835427027d87c14139ea0df40..21d9593dbbc3cc0df542f2de740f44c4709afb2a 100644 --- a/src/doc/rdf-and-types.md +++ b/src/doc/rdf-and-types.md @@ -55,7 +55,7 @@ The outer scope defines the schema and version where the cluster is used. The cl | solid arrow | predicate | - + ### 2.5 Dimensions @@ -105,6 +105,3 @@ The issue of providing parent and neighboring `URI`s in creating a semantic data A link failure means that the object does not exist (closed world assumption), not that this object may exist but that we just do not know about it (open world assumption). -[NEXT](editing-ontologies.md) - -[HOME](../../README.md) \ No newline at end of file diff --git a/src/doc/usd-framing.md b/src/doc/usd-framing.md index 62fa6a18c3588c40f127d3ed6e770fbae8a2e2d6..e5d13beb54e6fc61fda74af2431f1d8179cba974 100644 --- a/src/doc/usd-framing.md +++ b/src/doc/usd-framing.md @@ -167,6 +167,3 @@ To get the attributes on the second level } } ``` -[NEXT](playground.md) - -[HOME](../../README.md) \ No newline at end of file diff --git a/src/ontologies/clusters/core/core.md b/src/ontologies/clusters/core/core.md deleted file mode 100644 index 5ef37951cbe513c18a90a88036cb470a12b99523..0000000000000000000000000000000000000000 --- a/src/ontologies/clusters/core/core.md +++ /dev/null @@ -1,9 +0,0 @@ -<a class="top-link hide" href="#top">↑</a> -<a name="top"></a> - -# Core Cluster - - - - -[BACK](../../../doc/clusters.md#421-core) \ No newline at end of file diff --git a/src/ontologies/clusters/core/coreSchema.ts b/src/ontologies/clusters/core/coreSchema.ts deleted file mode 120000 index c5e4022b6440b77efefa17523831d2e9559a7e8e..0000000000000000000000000000000000000000 --- a/src/ontologies/clusters/core/coreSchema.ts +++ /dev/null @@ -1 +0,0 @@ -/home/wac/working/workspace/facility-cobot/services/types/core-schema/src/coreSchema.ts \ No newline at end of file diff --git a/src/semantic_api/api_python/src/config.py b/src/semantic/api/config.py similarity index 86% rename from src/semantic_api/api_python/src/config.py rename to src/semantic/api/config.py index 313c327a446e8c83f7c46b7ef457565f53c8102f..239b4fe26549608cc7d8860fb1bf409de7f58e6a 100644 --- a/src/semantic_api/api_python/src/config.py +++ b/src/semantic/api/config.py @@ -1,6 +1,6 @@ from typing_extensions import Final import json -from semantic_api.common.src.utils import msg +from semantic.common.utils import msg ''' @@ -12,11 +12,10 @@ batch_size = 100 schemaName: str = 'fera' schemaVersion: str = 'v001' -instanceName: str = 'proto' +instanceName: str = 'jan2025' dbUri: str = 'http://127.0.0.1:6363/' brokerIp: Final = 'localhost' -#brokerIp: Final = "10.94.85.101" port: Final = 1883 username: Final = 'semantic' password: Final = 's3mant1c' diff --git a/src/semantic_api/api_python/src/semantic_api.py b/src/semantic/api/semantic_api.py similarity index 98% rename from src/semantic_api/api_python/src/semantic_api.py rename to src/semantic/api/semantic_api.py index 56964b277fbfa3afe63cd143d257b4483a41992a..b427181ccaf34e2fa90f5c673c999bce8d1c722d 100644 --- a/src/semantic_api/api_python/src/semantic_api.py +++ b/src/semantic/api/semantic_api.py @@ -8,9 +8,9 @@ from pyrsistent import m, pmap, PMap from pymonad.either import Either, Left, Right from pymonad.promise import Promise from pymonad.tools import curry -from semantic_api.common.src.utils import msg, err, redMsg, greenMsg, to_json_ld_type, resolve_either, reject_promised, reject_either, instance_count -from semantic_api.common.src.common_types import SchemaId, PipeArg -from semantic_api.api_python.src.semantic_client import semanticClient +from semantic.common.utils import msg, err, redMsg, greenMsg, to_json_ld_type, resolve_either, reject_promised, reject_either, instance_count +from semantic.common.common_types import SchemaId, PipeArg +from semantic.api.semantic_client import semanticClient diff --git a/src/semantic_api/api_python/src/semantic_client.py b/src/semantic/api/semantic_client.py similarity index 79% rename from src/semantic_api/api_python/src/semantic_client.py rename to src/semantic/api/semantic_client.py index f25680109bada030e145507133228958f98b2886..96c550d3d10b1f5699201135efc5e9bb694044e0 100644 --- a/src/semantic_api/api_python/src/semantic_client.py +++ b/src/semantic/api/semantic_client.py @@ -5,11 +5,11 @@ import re from pymonad.either import Either, Left, Right from typing_extensions import Final -from semantic_api.common.src.utils import msg, err, greenMsg, redMsg, custom_encoder -from semantic_api.common.src.common_types import PipeArg, SemanticConfig, SchemaId +from semantic.common.utils import msg, err, greenMsg, redMsg, custom_encoder +from semantic.common.common_types import PipeArg, SemanticConfig, SchemaId -from semantic_api.api_python.src.config import port, username, password, semanticConfigTopic, serviceRequestTopic, insertAcknowledgeTopic -from semantic_api.py_mqtt.src.py_mqtt import MQTTClient +from semantic.api.config import port, username, password, semanticConfigTopic, serviceRequestTopic, insertAcknowledgeTopic +from semantic.py_mqtt.py_mqtt import MQTTClient class semanticClient: @@ -77,17 +77,25 @@ class semanticClient: stringified= json.dumps(args) #query_result = self.mqtt.publish(args.get('topic'), stringified) - query_result = await asyncio.wrap_future(asyncio.run_coroutine_threadsafe(self.mqtt.publish_with_response(args.get('topic'), stringified), self.loop)) + query_result = {} + try: + query_result = await asyncio.wrap_future(asyncio.run_coroutine_threadsafe(self.mqtt.publish_with_response(args.get('topic'), stringified), self.loop)) + except Exception as e: + txt = f'semantic_client: insert_primitive : Exception: {e}' + redMsg(txt) + + #greenMsg('insert_primitive result: '+str(query_result)) return query_result async def query_primitive(self, args: PipeArg): stringified= json.dumps(args) - #msg('query_primitive args: '+stringified) + msg('query_primitive args: '+stringified) query_result = {} try: + redMsg('awaiting call ---------------------------------------------------------------------') query_result = await asyncio.wrap_future(asyncio.run_coroutine_threadsafe(self.mqtt.publish_with_response(args.get('topic'), stringified), self.loop)) #query_result = await self.mqtt.publish_with_response(args.get('topic'), stringified) except Exception as e: @@ -107,28 +115,29 @@ class semanticClient: "args": args } - redMsg('semantic_config body: '+json.dumps(body, indent=6)) + pipe_args: PipeArg = { "schema": self.schemaId, "topic": semanticConfigTopic, "doc": body, "frame": None } + redMsg('semantic_config pipe_args: '+json.dumps(pipe_args, indent=6)) return await self.query_primitive(pipe_args) - async def getSchemaIdInUse(self): - #msg('getSchemaIdInUse()') - #result = self.loop.run_until_complete(self.semantic_config('getSchemaIdInUse', None)) + async def getSchemaId(self): + #msg('getSchemaId()') + #result = self.loop.run_until_complete(self.semantic_config('getSchemaId', None)) result = await self.semantic_config('getSchemaIdInUse', None) - greenMsg('getSchemaIdInUse: '+json.dumps(result, indent=6)) + greenMsg('getSchemaId: '+json.dumps(result, indent=6)) return result.get('doc') - async def setCurrentSchemaId(self, args: SchemaId): - #msg('setCurrentSchemaId()') - #result = self.loop.run_until_complete(self.semantic_config('setCurrentSchemaId', args)) + async def setSchemaId(self, args: SchemaId): + #msg('setSchemaId()') + #result = self.loop.run_until_complete(self.semantic_config('setSchemaId', args)) result = await self.semantic_config('setCurrentSchemaId', args) - greenMsg('setCurrentSchemaId: '+json.dumps(result, indent=6)) + greenMsg('setSchemaId: '+json.dumps(result, indent=6)) return result.get('doc') diff --git a/src/semantic_api/common/src/common_types.py b/src/semantic/common/common_types.py similarity index 100% rename from src/semantic_api/common/src/common_types.py rename to src/semantic/common/common_types.py diff --git a/src/semantic_api/common/src/utils.py b/src/semantic/common/utils.py similarity index 98% rename from src/semantic_api/common/src/utils.py rename to src/semantic/common/utils.py index 6b8fa5fe573490fff90067f145d331bf16d90ed4..b99dbd55c517cc05ca7aa133c05c52c75467878a 100644 --- a/src/semantic_api/common/src/utils.py +++ b/src/semantic/common/utils.py @@ -15,7 +15,7 @@ from pymonad.either import Left, Right from pyrsistent import PMap from urllib.parse import unquote -from semantic_api.common.src.common_types import SchemaId +from semantic.common.common_types import SchemaId def typeName(elem): diff --git a/src/semantic_api/py_mqtt/src/py_mqtt.py b/src/semantic/py_mqtt/py_mqtt.py similarity index 96% rename from src/semantic_api/py_mqtt/src/py_mqtt.py rename to src/semantic/py_mqtt/py_mqtt.py index e1090b1360cfe7da2ff301c2232437678e599401..1915bf6085d0f0231bf83ce991514194750447bd 100644 --- a/src/semantic_api/py_mqtt/src/py_mqtt.py +++ b/src/semantic/py_mqtt/py_mqtt.py @@ -7,7 +7,7 @@ import traceback from typing import Optional, Tuple, List import paho.mqtt.client as mqtt import paho.mqtt.enums as CallbackAPIVersion -from semantic_api.common.src.utils import msg, redMsg, greenMsg, custom_encoder +from semantic.common.utils import msg, redMsg, greenMsg, custom_encoder @@ -19,10 +19,10 @@ class MQTTClient: username: Optional[str] = None, password: Optional[str] = None, subscribe_topics: str | List[str] = None): - #msg('MQTTClient '+broker_address+' '+str(port)) + self.loop = loop self.mqtt_client_id =__name__+str(random.randrange(1, 100)) - greenMsg('mqtt client id '+self.mqtt_client_id) + greenMsg('MQTTClient '+broker_address+':'+str(port)+' mqtt_client_id '+self.mqtt_client_id) self.client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id= self.mqtt_client_id, clean_session=False, protocol=mqtt.MQTTv311,transport='tcp', reconnect_on_failure=False) self.disconnected = self.loop.create_future() self.got_message = None @@ -155,8 +155,9 @@ class MQTTClient: async def publish_with_response(self, topic: str, message: str): """ Will send a message to the broker, on the specified topic and wait for a response - ¨ to return. + ¨ to return.' """ + redMsg('>----------------------- pub w r') try: if self.loop is None or self.loop.is_running() == False: self.loop = asyncio.get_running_loop() @@ -174,12 +175,12 @@ class MQTTClient: self.got_message = future self.pending_queries[dict_key] = future ''' - + msg('pub w r'+message) msg_info = self.client.publish(topic, message, self.qos) msg_info.wait_for_publish() - + msg('pub awaiting') future_result = await self.got_message - + msg('pub got it') self.got_message = None except Exception as e: diff --git a/src/semantic_api/api_python/src/fera_types_ b/src/semantic_api/api_python/src/fera_types_ deleted file mode 100644 index c860c07ff4b6ba1c1aaa073286b655f9f1e07965..0000000000000000000000000000000000000000 --- a/src/semantic_api/api_python/src/fera_types_ +++ /dev/null @@ -1,195 +0,0 @@ -import json -from typing_extensions import Final -from pyrsistent import m, PMap -from pymonad.either import Either, Left, Right -from pydantic import ValidationError -from semantic_api.api_python.src.semantic_api import semantic -from semantic_api.common.src.utils import msg, redMsg, refForPath -from semantic_api.common.src.common_types import NamedType, TerminusRef - - - -class pathMap: - def __init__(self, semantic): - self.usdPathMap: PMap = m() - self.semantic = semantic - - def get(self, segment): - return self.usdPathMap.get(segment) - - - async def refForSegment(self, segmentName: str): - path = self.usdPathMap.get(segmentName) - if path is None: - path_either : Either = await self.pathForSegment(segmentName) - path = path_either.either(lambda e: f'refForSegment: Error: querying for segmentName: {segmentName}: {e}', lambda x: x) - - if path_either.is_right() and path is not None: - ref = refForPath("UsdPrim", path, "SpecifierDef") - #greenMsg('refForSegment: '+json.dumps(ref, indent=6)) - return Right(ref) - else: - return Left(ref) - else: - ref = refForPath("UsdPrim", path, "SpecifierDef") - #greenMsg(f'refForSegment {ref}') - return Right(ref) - - - async def setPathForSegment(self, segmentName: str): - key = segmentName - either_path: Either = await self.pathForSegment(segmentName) - - if either_path.is_right(): - path = either_path.either(lambda e: f'Error: shoulder_pan_name: {e}', lambda x: x) - self.usdPathMap = self.usdPathMap.update({ key: path}) - #greenMsg(f'setPathForSegment: segmentName: {key} path: {path}') - else: - redMsg(f'pathForSegment: Prim with {key} not found in db') - return self - - async def pathForSegment(self, segmentName: str) -> Either: - result: Either - frame = { - "@type": "UsdPrim", - "segmentName": segmentName - } - - prim_either = await self.semantic.client.frame(frame) - - if (prim_either is None or prim_either.is_left()): - txt = f'failure in query (not empty query) for frame @type: UsdPrim segmentName: {segmentName} ' - result = Left(txt) - redMsg('pathForSegment: '+txt) - else: - prim = prim_either.either(lambda e: f'Error: pathForSegment: {e}', lambda x: x) - ''' - an empty query will have a context object and nothing else in it - so we have naught yet caught an empty query - ''' - name = prim.get('name') - if name is not None: - result = Right(name) - #greenMsg('pathForSegment: '+name) - else: - txt = f'frame @type: UsdPrim segmentName: {segmentName} returned empty' - result = Left(txt) - redMsg('pathForSegment: '+txt) - - return result - - ''' - def primUri(self, segmentName: str) -> str: - key = segmentName - path = self.usdPathMap.get(key) - if path is None: - redMsg(f' primUri: {key} is not found in usdPathMap') - else: - joint_uri = refForPath("UsdPrim", path, "SpecifierDef") - greenMsg(f'primUri {joint_uri}') - return joint_uri - ''' - - -class JointState(NamedType): - ''' - "@key": { "@type": "Lexical", "@fields": ["name", "first"] }, - "@inherits": ["TaskState", "ProfiledState"], - ''' - #type: str - #name: str - first: str - last: str - count: int - parentObject: TerminusRef - hasJointEffort: float - hasJointPosition: float - hasJointVelocity: float - - -def joint_state(name:str, first:str, last:str, count:int, parent: TerminusRef, joint_effort:float, joint_position:float, joint_velocity:float) -> JointState: - #todo make the following JointState (not dict) and validate_type_object generic - js: JointState = { - "type" : 'JointState', - "name" : name, - "first" : first, - "last" : last, - "count" : count, - "parentObject" : parent, - "hasJointEffort" : joint_effort, - "hasJointPosition" : joint_position, - "hasJointVelocity" : joint_velocity - } - try: - JointState(**js) - result = Right(js) - except ValidationError as e: - txt = 'Error: ' + str(e) - redMsg("joint_state "+txt) - result = Left(txt) - ''' - NB: on use in chain/pipeline: - for the partial function version required for use in a chain where the pipe arg - is the input to the lambda function: - shift the validation above into the lambda body - the whole point of the partial function is that in a pipe, data arrives as input - i.e. the data is late and the validation will then also have to be late - - return lambda arg: - for key in arg: - js[key] = arg[key] - try: - JointState(**js) - return Right(js) - except ValidationError as e: - txt = txt + 'Error: ' + str(e) - redMsg("joint_state "+txt) - return Left(txt) - ''' - return lambda *arg: result - - -class ToolCenterPointState(NamedType): - ''' - "@key": { "@type": "Lexical", "@fields": ["name", "first"] }, - "@inherits": ["TaskState", "ProfiledState"], - ''' - - ''' - The speed of the TCP retuned in a pose structure. The first three values - are the cartesian speeds along x,y,z, and the last three define the - current rotation axis, rx,ry,rz, and the length |rz,ry,rz| defines the angular - velocity in radians/s - ''' - first: str - last: str - count: int - parentObject: TerminusRef - hasTCPSpeed: list[float] - hasTCPPose: list[float] - hasTCPForce: list[float] - - -def tool_center_point_state(name:str, first:str, last:str, count:int, parent: TerminusRef, speed_f6 :list[float], pose_f6: list[float], force_f6: list[float]) -> ToolCenterPointState: - tcps: ToolCenterPointState = { - "type" : 'ToolCenterPointState', - "name" : name, - "first" : first, - "last" : last, - "count" : count, - "parentObject" : parent, - "hasTCPSpeed": speed_f6, - "hasTCPPose": pose_f6, - "hasTCPForce": force_f6 - } - try: - ToolCenterPointState(**tcps) - result = Right(tcps) - except ValidationError as e: - txt = 'Error: ' + str(e) - redMsg("tool_center_point_state "+txt) - result = Left(txt) - return lambda *arg: result - - - \ No newline at end of file diff --git a/tests/behave.ini b/tests/behave.ini deleted file mode 100644 index 56bc521281eef8c03ecc185c768694b2e1d3b0b5..0000000000000000000000000000000000000000 --- a/tests/behave.ini +++ /dev/null @@ -1,4 +0,0 @@ -[behave] -stderr_capture=False -stdout_capture=False -log_capture=False \ No newline at end of file diff --git a/tests/environment.py b/tests/environment.py index 42fa2fe4eb06e7d6222272057d7f17df8350d395..d955191a89e6d833de0b2163b7e7b039e16bed54 100644 --- a/tests/environment.py +++ b/tests/environment.py @@ -2,13 +2,12 @@ import asyncio #import sys #sys.path.append("../src") - from typing_extensions import Final -from semantic_api.api_python.src.semantic_api import semantic +from semantic.api.semantic_api import semantic #from semantic_api.api_python.src.semantic_api import semanticClient -from semantic_api.api_python.src.config import brokerIp, schemaName, schemaVersion, instanceName, dbUri, batch_size, topics -from semantic_api.common.src.utils import msg, defineSchemaId -from semantic_fera.fera_types.src.type_constructors import pathMap +from semantic.api.config import brokerIp, schemaName, schemaVersion, instanceName, dbUri, batch_size, topics +from semantic.common.utils import msg, defineSchemaId +from semantic.fera.fera_types.type_constructors import pathMap diff --git a/tests/steps/api_insert.py b/tests/steps/api_insert.py index e6f9690df62aff25ea16a1cc4aacdd2c0df08f52..0c1707b98be2e2bdd9af33067418cc791f9ad5dc 100644 --- a/tests/steps/api_insert.py +++ b/tests/steps/api_insert.py @@ -8,11 +8,11 @@ from pymonad.promise import Promise from pymonad.tools import curry import json, re -from semantic_api.common.src.utils import msg, redMsg, greenMsg, sort_by_instance, refForPath, defineSchemaId, out_either, resolve_promised, chain_out, resolve_either, reject_either +from semantic.common.utils import msg, redMsg, greenMsg, sort_by_instance, refForPath, defineSchemaId, out_either, resolve_promised, chain_out, resolve_either, reject_either #from semantic_api.api_python.src.semantic_api import flatPMap -from semantic_fera.fera_types.src.type_constructors import joint_state, tool_center_point_state +from semantic.fera.fera_types.type_constructors import joint_state, tool_center_point_state #from semantic_api.api_python.src.test_data import type1, name1, name2, shoulder_pan_name, joint_state_test1, joint_state_test2, parent, shoulder_pan_path, float6 -from semantic_api.api_python.src.semantic_api import frame_constructor, flatten, function_constructor +from semantic.api.semantic_api import frame_constructor, flatten, function_constructor from test_data import type1, name1, name2, shoulder_pan_name, joint_state_test1, joint_state_test2, parent, shoulder_pan_path, float6 @@ -111,16 +111,16 @@ async def step_impl(context): ''' get current schema in service ''' - currentSchemaId = await context.semantic.client.getSchemaIdInUse() + currentSchemaId = await context.semantic.client.getSchemaId() ''' define a schema id, set that in service, and get the service definition ''' testSchemaId = defineSchemaId('someschema', 'v000', 'someinstance','somedbip') - testSchemaIdInUse = await context.semantic.client.setCurrentSchemaId(testSchemaId) + testSchemaIdInUse = await context.semantic.client.setSchemaId(testSchemaId) ''' set back the original schema def ''' - await context.semantic.client.setCurrentSchemaId(currentSchemaId) + await context.semantic.client.setSchemaId(currentSchemaId) ''' assert that the schema was set in the service as intended ''' diff --git a/tests/steps/test_data.py b/tests/steps/test_data.py index 58a29b813ccff288004bc65f07dcc7d6bf9a4c74..a516b23b4b05ad3810559cefffa850a8acb02428 100644 --- a/tests/steps/test_data.py +++ b/tests/steps/test_data.py @@ -1,6 +1,6 @@ from typing_extensions import Final -from semantic_api.common.src.common_types import TerminusRef -from semantic_fera.fera_types.src.type_constructors import JointState, joint_state +from semantic.common.common_types import TerminusRef +from semantic.fera.fera_types.type_constructors import JointState, joint_state type1: str = 'JointState' typeFail:Final = 'notfoundtype'