NSLS-II / Bug-Reports

Unified issue-tracker for bugs in the data acquisition, management, and analysis software at NSLS-II
BSD 3-Clause "New" or "Revised" License
2 stars 5 forks source link

Can't load data by using channelarchiver.Archiver #170

Open yugangzhang opened 7 years ago

yugangzhang commented 7 years ago

Here is my code:

from channelarchiver import Archiver
start_time, end_time = '2017-06-04 09:00', '2017-06-04 9:20'  
pv  = 'SR:C03-BI{DCCT:1}I:Real-I'  #test pv for accelerator
pv ='XF:11IDA-UT{Cryo:1}T:05-I'    #test pv for xf11id
### xf11id data archiver
archiver =  Archiver('http://xf11id-ca.cs.nsls2.local/cgi-bin/ArchiveDataServer.cgi')  
# accelerator server
#archiver = Archiver('http://xf11id-ca.cs.nsls2.local:17668/retrieval/bpl')

When do

res = archiver.get(pv, start_time, end_time, scan_archives= True, limit=None, interpolation='raw')

I got


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-20-e4b84f6afa43> in <module>()
----> 1 res = archiver.get(pv, start_time, end_time, scan_archives= True, limit=None, interpolation='raw')

/opt/conda_envs/analysis/lib/python3.5/site-packages/channelarchiver/channelarchiver.py in get(self, channels, start, end, limit, interpolation, scan_archives, archive_keys, tz)
    213                                         start_sec, start_nano,
    214                                         end_sec, end_nano,
--> 215                                         limit, interpolation)
    216             for archive_data in data:
    217                 channel_data = self._parse_values(archive_data, tz)

/opt/conda_envs/analysis/lib/python3.5/xmlrpc/client.py in __call__(self, *args)
   1090         return _Method(self.__send, "%s.%s" % (self.__name, name))
   1091     def __call__(self, *args):
-> 1092         return self.__send(self.__name, args)
   1093 
   1094 ##

/opt/conda_envs/analysis/lib/python3.5/xmlrpc/client.py in __request(self, methodname, params)
   1424 
   1425         request = dumps(params, methodname, encoding=self.__encoding,
-> 1426                         allow_none=self.__allow_none).encode(self.__encoding, 'xmlcharrefreplace')
   1427 
   1428         response = self.__transport.request(

/opt/conda_envs/analysis/lib/python3.5/xmlrpc/client.py in dumps(params, methodname, methodresponse, encoding, allow_none)
    949         m = Marshaller(encoding, allow_none)
    950 
--> 951     data = m.dumps(params)
    952 
    953     if encoding != "utf-8":

/opt/conda_envs/analysis/lib/python3.5/xmlrpc/client.py in dumps(self, values)
    499             for v in values:
    500                 write("<param>\n")
--> 501                 dump(v, write)
    502                 write("</param>\n")
    503             write("</params>\n")

/opt/conda_envs/analysis/lib/python3.5/xmlrpc/client.py in __dump(self, value, write)
    521             # for the p3yk merge, this should probably be fixed more neatly.
    522             f = self.dispatch["_arbitrary_instance"]
--> 523         f(self, value, write)
    524 
    525     def dump_nil (self, value, write):

/opt/conda_envs/analysis/lib/python3.5/xmlrpc/client.py in dump_nil(self, value, write)
    525     def dump_nil (self, value, write):
    526         if not self.allow_none:
--> 527             raise TypeError("cannot marshal None unless allow_none is enabled")
    528         write("<value><nil/></value>")
    529     dispatch[type(None)] = dump_nil

TypeError: cannot marshal None unless allow_none is enabled

My questions are that is this a bug in channelarchiver.py? Or I did not use the correct server for xf11id data achiever? Also, can someone tell me the server for accelerator data achiever? We also want to know the beam current.

Thanks!

ghost commented 7 years ago

channelarchiver uses XMLRPC to communicate. You need to add allow_none=True in the xmlrpc client archiver uses, I don't think channelarchiver exposes this feature ( I might be wrong, I didn't look into the api in depth). Your issue seems like you're getting None as a response. This can mean your archiver might not be responsive or you are searching for something that doesn't exist. I would talk to someone from accelerator controls and your beamline's control engineer to find out the addresses for both archivers you'd like to access. Once you verify all the addresses+your query params and the issue persists, we can look into it as a software related bug.

klauer commented 7 years ago

What happens if you remove limit=None from the parameters you're sending?

yugangzhang commented 7 years ago

@arkilic The function doesn't have allow_none option

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-23-7ee841f76089> in <module>()
      1 res = archiver.get(pv, start_time, end_time, scan_archives= True, limit= None, 
----> 2                    allow_none=True, interpolation='raw')

TypeError: get() got an unexpected keyword argument 'allow_none'
ghost commented 7 years ago

Yes that's not what I meant. Did you try what @klauer ask you to do?

yugangzhang commented 7 years ago

@klauer when remove limit= None, the function doesn't raise error, but the output is wrong


pv = 'XF:11IDA-OP{Mir:HDM-Ax:P}Pos-I'
res = archiver.get(pv, start_time, end_time, scan_archives= True, interpolation='raw')

I got


Out[35]:
ChannelData(
    values=[-28],
    times=[datetime.datetime(2017, 4, 24, 2, 0, 41, 717345, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>)],
    statuses=[0],
    severities=[0],
    units='urad',
    data_type=3,
    elements=1,
    display_limits=Limits(low=0.0, high=0.0),
    warn_limits=Limits(low=0.0, high=0.0),
    alarm_limits=Limits(low=0.0, high=0.0),
    display_precision=2,
    archive_key=47418,
    interpolation=0
)

We know that the values of that PV (mirror pitch encoder) should change a lot in range of (-1820~-1850)and should not be that only one value (-28).

ghost commented 7 years ago

Are you sure the PV is what you think it is or is there an offset somewhere? Try to get a different time range.

yugangzhang commented 7 years ago

Yes. I tried different time and got the same one value (-28). Actually, I also tried different PV, and it always gave me one value.

ghost commented 7 years ago

Are you sure you have the right address for the archiver? Can you try it with a different address (even a bogus one)?

ghost commented 7 years ago

bump @yugangzhang