ChristianTremblay / pyhaystack

Pyhaystack is a module that allow python programs to connect to a haystack server project-haystack.org. Connection can be established with Niagara Platform running the nhaystack, Skyspark and Widesky. For this to work with Anaconda IPython Notebook in Windows, be sure to use "python setup.py install" using the Anaconda Command Prompt in Windows. If not, module will be installed for System path python but won't work in the environment of Anaconda IPython Notebook. You will need hszinc 1.3+ for this to work.
Apache License 2.0
74 stars 32 forks source link

HaystackError: java.lang.ClassCastExceptio #76

Closed bbartling closed 5 years ago

bbartling commented 5 years ago

Would there be anyway someone could give me a tip on if I am doing anything wrong? To make a long story short a customer is interested in reports above & beyond the Niagara reporting service capabilities but they are at an N4 revision too low to give them an example of pyhaystack/pandas/matplotlib... (4.2, non TLS)

So I am hoping to test this out/give them an example from a different job/server which is at revision 4.7 but also secure TLS.

Im experimenting in Jupyter lab notebooks on Python 3.7. I can print the NAV file of the N4 server: image

But attempting this code Ill get a long error:

# Retrieve some points
op = session.find_entity(filter_expr='hwst')
op.wait()
hwst = op.result
# Read today's history for all found points
op = session.his_read_frame(hwst, rng= 'today')
op.wait()
b = op.result
b

image

Full trace back:

---------------------------------------------------------------------------
HaystackError                             Traceback (most recent call last)
<ipython-input-5-f1f36714fb3f> in <module>
----> 1 hwst = op.result

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyhaystack\util\state.py in result(self)
     95 
     96         if self.is_failed:
---> 97             self._result.reraise()
     98 
     99         if not self._result_copy:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyhaystack\util\asyncexc.py in reraise(self)
     26 
     27     def reraise(self):
---> 28         reraise(*self._exc_info)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\six.py in reraise(tp, value, tb)
    691             if value.__traceback__ is not tb:
    692                 raise value.with_traceback(tb)
--> 693             raise value
    694         finally:
    695             value = None

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyhaystack\client\ops\entity.py in _on_read(self, operation, **kwargs)
     39         try:
     40             # See if the read succeeded.
---> 41             grid = operation.result
     42             self._log.debug('Received grid: %s', grid)
     43 

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyhaystack\util\state.py in result(self)
     95 
     96         if self.is_failed:
---> 97             self._result.reraise()
     98 
     99         if not self._result_copy:

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyhaystack\util\asyncexc.py in reraise(self)
     26 
     27     def reraise(self):
---> 28         reraise(*self._exc_info)

~\AppData\Local\Continuum\anaconda3\lib\site-packages\six.py in reraise(tp, value, tb)
    691             if value.__traceback__ is not tb:
    692                 raise value.with_traceback(tb)
--> 693             raise value
    694         finally:
    695             value = None

~\AppData\Local\Continuum\anaconda3\lib\site-packages\pyhaystack\client\ops\grid.py in _check_err(grid)
    296                         raise HaystackError(
    297                                 grid.metadata.get('dis', 'Unknown Error'),
--> 298                                 grid.metadata.get('traceback', None))
    299                     return grid
    300                 except:

HaystackError: java.lang.ClassCastException

Any tips greatly appreciated, as I mentioned this before its just to get sample of pyhaystack capabilities to use on a different site that is non TLS. (Get the customer to upgrade to 4.7). There is another group in house that does Skysparks that had this nHaystack service running already and I just added the hwst tag as a test trial.

image image image

ChristianTremblay commented 5 years ago

Have you tried "Rebuild Cache" on the nhaystack service ?

bbartling commented 5 years ago

In workbench, I did the right click command on the nhaystack service where it rebuilt the cache successfully... Still same issues tho when re-running the Jupyter lab code tho..

There is a different group in a different office (same company) that does Sky sparks... And I think they route points to a cloud based n4 server then to Sky Foundry somehow... Just FYI, it would be nice to try and connect to the Sky sparks server but I am not very involved with that group very much

image

bbartling commented 5 years ago

The nHaystack service was already running on this N4 server before me... Which I found sort of interesting

ChristianTremblay commented 5 years ago

Using the Query view of the nhaystack service module, can you find hswt ?

And also, be sure to select the equipment reference in the nhaystack property sheet. And be sure this equipment is referenced to the site.... And be sure there is a site :)

bbartling commented 5 years ago

Can you give me a tip on how to do that?

On Wed, Jul 3, 2019, 1:29 PM Christian Tremblay notifications@github.com wrote:

Using the Query view of the nhaystack service module, can you find hswt ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ChristianTremblay/pyhaystack/issues/76?email_source=notifications&email_token=AHC4BHLQYF7A5YG6DT3SSB3P5TVYHA5CNFSM4H5GIQJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZFJ74A#issuecomment-508207088, or mute the thread https://github.com/notifications/unsubscribe-auth/AHC4BHM7ZYBYMIYHVFUUNKDP5TVYHANCNFSM4H5GIQJA .

ChristianTremblay commented 5 years ago

Using the nhaystack palette... Under config, I usually put the site object (see palette)...and configure it. Under the controller (typically) I add a equip object (again see the palette)...and configure it. Be sure to reference the equipment to the site you created.

Once done, rebuild cache Every time you modify something, rebuild cache

The Query View is just another view on the service. You can write a filter expression hit enter and you'll get results.

bbartling commented 5 years ago

Would anyone be able to give me any tips if I am missing something? I did add the site and an equip tag. The HwsT point is where my point tag is implemented: image image

I can print the about & nav file just fine.. Also trying setting pint=True image image

But trying the site = session.site this also brings up the same exact Java error with full traceback I pasted in previously. image

You also mentioned previously about trying the query view... Can you give me a tip on how to try that? And any other tips? :) Thanks..

apigott commented 5 years ago

Was this ever resolved? I'm having the same trackback error using SkySpark...

sjlongland commented 5 years ago

@apigott Not sure… in this case it seems to be an nHaystack error that's causing the trace-back, and all pyhaystack does is throw a HaystackError which is basically saying "something went wrong server-side".

About the only thing in common is both nHaystack and SkySpark are (deep down beneath the "Fantom") Java based, hence why you get the ClassCastException error (which is a Java exception). On that basis, even if the stack trace looks the same, you're better off filing a new issue as the root cause is unlikely to be identical.

ChristianTremblay commented 5 years ago

I made many test without being able to reproduce the trouble. I believe it's related to the server itself. I will close the issue and please reopen if you find something.

bbartling commented 5 years ago

Any chance you would create a YouTube video on how to setup a haystack server on N4 secure and pull a trend thru Python? :)

In AX I could use pyhaystack with ease on a non secure station but it's been a dead end in N4 for me. :(

On Sun, Oct 13, 2019, 10:43 AM Christian Tremblay notifications@github.com wrote:

Closed #76 https://github.com/ChristianTremblay/pyhaystack/issues/76.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ChristianTremblay/pyhaystack/issues/76?email_source=notifications&email_token=AHC4BHPB47FYUCDX4KWM32DQOM62TA5CNFSM4H5GIQJKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOUFZ7DAI#event-2708730241, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHC4BHMK5OTBIFIDWCHIUCLQOM62TANCNFSM4H5GIQJA .