NSLS-II / wishlist

an issue tracker for the big picture
1 stars 0 forks source link

install carchive module on CHX #84

Closed yugangzhang closed 8 years ago

yugangzhang commented 8 years ago

I failed to install carchive on chx beamline under either collection or analysis environment months ago. I remembered that there was a compiling problem. carchive: https://github.com/NSLS-II/carchivetools.git

Anyone help to install it?

ghost commented 8 years ago

What is the error you are getting? Most likely because our environments are in python 3+ and carchivetools supports Python >=2.6, <3.0 (>= 2.7 required for Appliance). carchivetools uses twisted for its backend and twisted is not fully supported for python 3. Try this alternative if you absolutely need the archiver until we come up with a solution: https://github.com/NSLS-II/channelarchiver PS: This module only works with legacy archiver (not archiver appliance)

yugangzhang commented 8 years ago

@arkilic Thanks! That should be reason that I can't install on python 3+. I am trying to use channelarchiver.

ghost commented 8 years ago

Getting archiver appliance is already among our goals. Closing the duplicate request.

ghost commented 8 years ago

@yugangzhang take a look at this notebook. This will get you the data out of the archiver appliance without carchivetools.

http://nbviewer.ipython.org/gist/arkilic/a9a44272a72681b89e29

heroux commented 8 years ago

CHX doesn’t have archiver appliance installed yet. Leon is in the process of installing that at the beamlines. CSX and LIX have it , XPD and SRX are next in line. in doubt ask Leon. Annie

On Nov 16, 2015, at 5:43 PM, Arman Arkilic notifications@github.com<mailto:notifications@github.com> wrote:

@yugangzhanghttps://github.com/yugangzhang take a look at this notebook. This will get you the data out of the archiver appliance without carchivetools.

http://nbviewer.ipython.org/gist/arkilic/a9a44272a72681b89e29

— Reply to this email directly or view it on GitHubhttps://github.com/NSLS-II/wishlist/issues/84#issuecomment-157210745.

ghost commented 8 years ago

The archiver appliance installation is irrelevant. According to @klauer they are trying to access the accelerator archiver appliance for beam current. The method I showed in the notebook is the only way we have in to access archiver appliance data in Python 3.

yugangzhang commented 8 years ago

Thanks, @arkilic, but I can't open your http://nbviewer.ipython.org/gist/arkilic/a9a44272a72681b89e29

It says:

404 : Not Found

You are requesting a page that does not exist!

The remote resource was not found.
ghost commented 8 years ago

Pasted the wrong link, I was trying to catch the train :) : http://nbviewer.ipython.org/gist/arkilic/1d6bd9c1cbe3749de0cc

yugangzhang commented 8 years ago

Thanks @arkilic I can open your notebook now. But, by using your code,

import datetime
import simplejson as json
from urllib3.request import urlencode
import urllib3
import matplotlib.pyplot as plt
%matplotlib inline

ARCHIVER = 'http://xf11id-ca.cs.nsls2.local/cgi-bin/ArchiveDataServer.cgi'
dt1 = dict(year=2015, month=10,day=5, hour=10, minute=9, second=10)
dt2 = dict(year=2015, month=11,day=10, hour=10, minute=9, second=10)
params = urlencode({'pv':'XF:11IDA-UT{Cryo:1}T:05-I', 
                    'from': datetime.datetime(**dt1).isoformat()+str('Z'),
                    'to': datetime.datetime(**dt2).isoformat()+str('Z')})

http = urllib3.PoolManager()
url = ARCHIVER + 'retrieval/data/getData.json?' + params
req = http.request('GET', url)
data = json.loads(req.data)

I got:

---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
<ipython-input-15-d0f9f59816f7> in <module>()
     19 url = ARCHIVER + 'retrieval/data/getData.json?' + params
     20 req = http.request('GET', url)
---> 21 data = json.loads(req.data)

/home/yuzhang/Repos/simplejson/simplejson/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw)
    514             parse_constant is None and object_pairs_hook is None
    515             and not use_decimal and not kw):
--> 516         return _default_decoder.decode(s)
    517     if cls is None:
    518         cls = JSONDecoder

/home/yuzhang/Repos/simplejson/simplejson/decoder.py in decode(self, s, _w, _PY3)
    368         if _PY3 and isinstance(s, binary_type):
    369             s = s.decode(self.encoding)
--> 370         obj, end = self.raw_decode(s)
    371         end = _w(s, end).end()
    372         if end != len(s):

/home/yuzhang/Repos/simplejson/simplejson/decoder.py in raw_decode(self, s, idx, _w, _PY3)
    398             elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf':
    399                 idx += 3
--> 400         return self.scan_once(s, idx=_w(s, idx).end())

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

My json.version is '3.8.1'.

But anyway, I can use "from channelarchiver import Archiver; " to read our archive data. Our current problem is: https://github.com/NSLS-II/Bug-Reports/issues/60 .

ghost commented 8 years ago

The problem is not the code. The issue is you are trying to access the legacy archiver, not the archiver appliance. Your request returns no data, hence the Json error. In the bug report, you are trying to access the accelerator archiver. In your trial above, you are trying to access your local archiver. In order to get the ring current from the accelerator archiver appliance, you need the archiver appliance url(obv different than listed in that report). FYI, the issue in the bug report is not related to the Python library. It's due to the immense number of indexes on the server side. glad you can use the local archiver

yugangzhang commented 8 years ago

I got it. Thanks!