Ejemplo n.º 1
0
def test_client_add_dataset():
    client.requests = test_add  # OMG more monkey patching
    ec = Client('localhost:6363')
    ec.add('iris', example('iris.csv'))
    assert 'iris' in ec.dshape.measure.dict
    iris_data = bz_data(example('iris.csv'))
    assert ec.dshape.measure.dict['iris'] == iris_data.dshape
Ejemplo n.º 2
0
def test_client_add_dataset():
    client.requests = test_add  # OMG more monkey patching
    ec = Client('localhost:6363')
    ec.add('iris', example('iris.csv'))
    assert 'iris' in ec.dshape.measure.dict
    iris_data = bz_data(example('iris.csv'))
    assert ec.dshape.measure.dict['iris'] == iris_data.dshape
Ejemplo n.º 3
0
def test_client_add_dataset_with_args():
    client.requests = test_add  # OMG more monkey patching
    ec = Client('localhost:6363')
    ec.add('teams', 'sqlite:///' + example('teams.db'), 'teams',
           primary_key='teamID')
    assert 'teams' in ec.dshape.measure.dict
    teams_data = bz_data('sqlite:///' + example('teams.db') + '::teams')
    assert ec.dshape.measure.dict['teams'] == teams_data.dshape
Ejemplo n.º 4
0
def test_client_add_dataset_with_args():
    client.requests = test_add  # OMG more monkey patching
    ec = Client('localhost:6363')
    ec.add('teams',
           'sqlite:///' + example('teams.db'),
           'teams',
           primary_key='teamID')
    assert 'teams' in ec.dshape.measure.dict
    teams_data = bz_data('sqlite:///' + example('teams.db') + '::teams')
    assert ec.dshape.measure.dict['teams'] == teams_data.dshape
Ejemplo n.º 5
0
def test_expr_client_interactive():
    ec = Client('localhost:6363', 'accounts')
    t = Table(ec)

    assert compute(t.name) == ['Alice', 'Bob']
    assert (into(set, compute(by(t.name, min=t.amount.min(),
                                         max=t.amount.max()))) ==
            set([('Alice', 100, 100), ('Bob', 200, 200)]))
Ejemplo n.º 6
0
 def to_blaze(self):
     from blaze.server.client import Client
     from blaze.server import from_tree
     from blaze import Data
     # hacky - blaze urls have `compute.json` in it, but we need to strip it off
     # to feed it into the blaze client lib
     c = Client(self.data_url.rsplit('compute.json', 1)[0])
     d = Data(c)
     return from_tree(self.expr, {':leaf': d})
Ejemplo n.º 7
0
def test_expr_client():
    ec = Client('localhost:6363', 'accounts')
    assert discover(ec) == discover(df)

    t = TableSymbol('t', discover(ec))
    expr = t.amount.sum()

    assert compute(expr, ec) == 300
    assert 'name' in t.fields
    assert isinstance(t.name, Field)
    assert compute(t.name, ec) == ['Alice', 'Bob']
Ejemplo n.º 8
0
def test_client():
    c = Client('localhost:6363')
    assert str(discover(c)) == str(discover(data))

    t = symbol('t', discover(c))
    expr = t.accounts.amount.sum()

    assert compute(expr, c) == 300
    assert 'name' in t.accounts.fields
    assert isinstance(t.accounts.name, Field)
    assert compute(t.accounts.name, c) == ['Alice', 'Bob']
Ejemplo n.º 9
0
import numpy as np
from bokeh.plotting import figure, show, output_server
from bokeh.transforms import image_downsample
from blaze.server.client import Client
from blaze import Data

N = 1000

x = np.linspace(0, 10, N)
y = np.linspace(0, 10, N)
xx, yy = np.meshgrid(x, y)
d = np.sin(xx) * np.cos(yy)

output_server("remote_image")

c = Client('http://localhost:5006')
d = Data(c)
source = image_downsample.source()
source.from_blaze(d.array, local=True)

plot = figure(
    x_range=[0, 10],
    y_range=[0, 10],
)
plot.image(source=source,
           image="image",
           x="x",
           y="y",
           dw="dw",
           dh="dh",
           palette="Spectral11",
Ejemplo n.º 10
0
def test_custom_expressions():
    ec = Client('localhost:6363', 'accounts')
    t = TableSymbol('t', discover(ec))

    assert list(map(tuple, compute(CustomExpr(t), ec))) == into(list, df)
Ejemplo n.º 11
0
def test_client_add_dataset_failure():
    client.requests = test_add  # OMG more monkey patching
    ec = Client('localhost:6363')
    with pytest.raises(ValueError) as exc:
        ec.add('iris2', example('iris.csv'), -1, bad_arg='value')
    assert '422 UNPROCESSABLE ENTITY' in str(exc.value)
Ejemplo n.º 12
0
def test_client_cant_add_dataset():
    ec = Client('localhost:6363')
    with pytest.raises(ValueError) as excinfo:
        ec.add('iris', example('iris.csv'))
    assert "Server does not support" in str(excinfo.value)
Ejemplo n.º 13
0
def test_client_add_dataset_failure():
    client.requests = test_add  # OMG more monkey patching
    ec = Client('localhost:6363')
    with pytest.raises(ValueError) as exc:
        ec.add('iris2', example('iris.csv'), -1, bad_arg='value')
    assert '422 UNPROCESSABLE ENTITY' in str(exc.value)
Ejemplo n.º 14
0
def test_client_cant_add_dataset():
    ec = Client('localhost:6363')
    with pytest.raises(ValueError) as excinfo:
        ec.add('iris', example('iris.csv'))
    assert "Server does not support" in str(excinfo.value)