simphony / simphony-osp

A framework that aims to achieve interoperability between software such as simulation engines, databases and data repositories using a knowledge graph as the common language.
https://simphony.readthedocs.io
Other
16 stars 12 forks source link

Errror at server side while accessing cuds object #701

Closed kmajeshkrishnan closed 3 years ago

kmajeshkrishnan commented 3 years ago
 app.logger.info(' **************** Info level log started  ****************')
    try:
        with TransportWrapperCls(*conn_args, **conn_kwargs) as session:
            wrapper = cuba.Wrapper(session=session)
            all_proposals = wrapper.session.load_by_oclass(
                oclass=mt.cottbus_iteration_id)
        all_proposals.sort(key=lambda obj: obj.value)

        arr =[]

        proposal = all_proposals[0]
        temperature = proposal.get(
            oclass=mt.temperature, rel=mt.is_part_of)[0]
        strain_rate = proposal.get(
            oclass=mt.strain_rate, rel=mt.is_part_of)[0]

        # temp, strain = _get_temp_strain_tuple_from_id_cuds(proposal)

        app.logger.info(str(temperature))

        app.logger.info("===========" + str(pretty_print(temperature)) + "============")
Traceback (most recent call last):
  File "simple-backend.py", line 73, in <module>
    wanted_function()
  File "simple-backend.py", line 39, in wanted_function
    app.logger.info("===========" + str(pretty_print(temperature)) + "============")
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/site-packages/osp_core-3.5.5-py3.8.egg/osp/core/utils/pretty_print.py", line 27, in pretty_print
    pp += _pp_subelements(cuds_object)
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/site-packages/osp_core-3.5.5-py3.8.egg/osp/core/utils/pretty_print.py", line 72, in _pp_subelements
    sorted_elements = sorted(
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/site-packages/osp_core-3.5.5-py3.8.egg/osp/core/cuds.py", line 414, in iter
    for r in result:
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/site-packages/osp_core-3.5.5-py3.8.egg/osp/core/cuds.py", line 821, in _load_cuds_objects
    yield next(cuds_objects)
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/site-packages/osp_core-3.5.5-py3.8.egg/osp/core/session/result.py", line 51, in __next__
    x = next(self._iterator)
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/site-packages/osp_core-3.5.5-py3.8.egg/osp/core/session/buffers.py", line 104, in __next__
    return next(self._iterator)
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/site-packages/osp_core-3.5.5-py3.8.egg/osp/core/session/wrapper_session.py", line 107, in load
    new_cuds_object = self._get_next_missing(missing)
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/site-packages/osp_core-3.5.5-py3.8.egg/osp/core/session/wrapper_session.py", line 390, in _get_next_missing
    cuds_object = next(missing)
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/site-packages/osp_core-3.5.5-py3.8.egg/osp/core/session/transport/transport_session_client.py", line 118, in _load_from_backend
    yield from self._engine.send(LOAD_COMMAND, data, files)
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/site-packages/osp_core-3.5.5-py3.8.egg/osp/core/session/transport/communication_engine.py", line 179, in send
    return event_loop.run_until_complete(
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/site-packages/osp_core-3.5.5-py3.8.egg/osp/core/session/transport/communication_engine.py", line 224, in _request
    return self.handle_response(
  File "/home/ajesh/anaconda3/envs/gui-python/lib/python3.8/site-packages/osp_core-3.5.5-py3.8.egg/osp/core/session/transport/transport_session_client.py", line 153, in _receive
    raise RuntimeError("Error on Server side: %s" % data[7:])
RuntimeError: Error on Server side: KeyError: UUID('fb39647e-e70c-440f-a5c9-2c6fa740a5ce')

osp-core version 3.5.5 installed on both client and server side throws a server error exception while accessing a cuds object. The server already contains the values and connection is established via DataspaceSession

kysrpex commented 3 years ago

One thing, have you tried using the CUDS object inside the with statement instead of outside? Like this.

 app.logger.info(' **************** Info level log started  ****************')
    try:
        with TransportWrapperCls(*conn_args, **conn_kwargs) as session:
            wrapper = cuba.Wrapper(session=session)
            all_proposals = wrapper.session.load_by_oclass(
                oclass=mt.cottbus_iteration_id)
            all_proposals.sort(key=lambda obj: obj.value)

            arr =[]

            proposal = all_proposals[0]
            temperature = proposal.get(
                oclass=mt.temperature, rel=mt.is_part_of)[0]
            strain_rate = proposal.get(
                oclass=mt.strain_rate, rel=mt.is_part_of)[0]

            # temp, strain = _get_temp_strain_tuple_from_id_cuds(proposal)

            app.logger.info(str(temperature))

            app.logger.info("===========" + str(pretty_print(temperature)) + "============")
kmajeshkrishnan commented 3 years ago

Worked like a chram :)