RFC: first draft of insertion API - #3
Conversation
ca0f770 to
491f63d
Compare
|
So, this works: In [54]: ac = AnalysisClient()
In [55]: a = ac.create_header('foobar', baz=123)
In [56]: a.add_result(dd=dd)
Out[56]:
{'data': {'dd': '/home/tcaswell/.cache/ab/7c117203-0397-488d-a4cd-019ee9e9246e.csv'},
'descriptor': {'auto_gen': True,
'data_keys': {'dd': {'columns': ['bar', 'foo'],
'dtype': 'table',
'external': 'FILEPATH:csv',
'shape': (5, 2)}},
'header': {'baz': 123,
'date': 1450925755.5471232,
'name': 'foobar',
'uid': '1f5bd54c-0589-4d31-8f2b-aca289638dc8'},
'uid': '9c1ec35b-385d-4758-8202-89b9a4dcb956'},
'uid': '788f21bd-486b-4a03-ab5c-2ac1bc9724b4'}
In [57]: r = _
In [58]: open_file(r.data['dd'], r.descriptor.data_keys['dd'])
Out[62]:
bar foo
0 4 0
1 3 1
2 2 2
3 1 3
4 0 4
In [63]: dd
Out[63]:
bar foo
0 4 0
1 3 1
2 2 2
3 1 3
4 0 4
In [64]: That is pretty cool. |
|
Neat. I don't immediately see why open_file needs the second arg.
|
|
I agree with Dan Allan (@danielballan) if |
Over engineering
This depends on the stand-alone document package
We use the time convention everywhere else.
This is here for proof-of-concept testing the API, may not survive.
only deals with client.py right now
ad6581a to
3dff916
Compare
|
still todo (not all in this PR)
|
|
also use pip caching on travis (see https://github.com/matplotlib/basemap/pull/248/files) so we can get night running again. |
70cf4cd to
acec333
Compare
|
Look at https://github.com/NSLS-II/analysisstore/pull/3/files#diff-0d61030312bd6e18e7b51877ec248cf6R215 for how I imagine |
|
Why did this get renamed to analysisbucket? |
There was a problem hiding this comment.
Does assert res.data['arr'] == arr work with py.test and numpy arrays?
There was a problem hiding this comment.
No, you get an exception that the truth value of an array is ambiguous.
There was a problem hiding this comment.
You could use all(), I guess, but the advantage of numpy tests is it checks
dtype and so on.
On Sat, Dec 26, 2015 at 1:44 PM Thomas A Caswell notifications@github.com
wrote:
In analysisbucket/tests/test_client.py
#3 (comment):
- md = {k: ord(k) for k in 'abcdef'}
- h = ac.create_header('testing', uid='fixed', time=0, **md)
- h = h.Document()
- tab = pd.DataFrame({'a': range(15), 'b': 'a'*15})
- arr = np.arange(15)
- res = ac.add_result(h, tab=tab, arr=arr)
- for d in [res['data'], res.descriptor.data_keys]:
for k in ['tab', 'arr']:assert k in d- res = fill_result(res)
- assert_array_equal(res.data['arr'], arr)
No, you get an exception that the truth value of an array is ambiguous.
—
Reply to this email directly or view it on GitHub
https://github.com/NSLS-II/analysisstore/pull/3/files#r48448981.
|
Would it be possible to use these tests again? As with amostra, I really like the idea of having a 'trivial' reference implementation. |
|
Yes, when I separate the server/client. You beat me to asking you to open this PR when we have the asclient (or w/e we call it) repo |
DEV:Tons of fixes to insert and find.
Max Rakitin (mrakitin)
left a comment
There was a problem hiding this comment.
Thomas A Caswell (@tacaswell), do you think it can be reused? The PR is quite old (travis config should be switched to GHA, of course), but the rest can be potentially useful.
Don't merge this, I want to add a bit more before it goes in.