Beispiel #1
0
def test_python():
    from packtivity.asyncbackends import ForegroundProxy

    p = ForegroundProxy({'hello': 'world'}, None, True)
    p = load_proxy(p.json(),
                   {'proxy': 'py:packtivity.asyncbackends:ForegroundProxy'},
                   best_effort_backend=False)
    assert type(p) == ForegroundProxy
def test_env(monkeypatch):
    from packtivity.asyncbackends import ForegroundProxy

    monkeypatch.setenv('PACKTIVITY_ASYNCBACKEND','packtivity.asyncbackends:ForegroundBackend:ForegroundProxy')

    p = ForegroundProxy({'hello': 'world'}, None, True)
    p,_ = load_proxy(p.json())
    assert type(p) == ForegroundProxy
Beispiel #3
0
def test_env(monkeypatch):
    from packtivity.asyncbackends import ForegroundProxy

    monkeypatch.setenv(
        'PACKTIVITY_ASYNCBACKEND',
        'packtivity.asyncbackends:ForegroundBackend:ForegroundProxy')

    p = ForegroundProxy({'hello': 'world'}, None, True)
    p, _ = load_proxy(p.json())
    assert type(p) == ForegroundProxy
Beispiel #4
0
def test_celery():
    from packtivity.asyncbackends import CeleryProxy
    from celery.result import AsyncResult
    asyncresult = AsyncResult('1234')
    p = CeleryProxy(asyncresult)

    p, _ = load_proxy(p.json())
    assert type(p) == CeleryProxy

    p.details()['task_id'] == asyncresult.task_id
def test_celery():
    from packtivity.asyncbackends import CeleryProxy
    from celery.result import AsyncResult
    asyncresult = AsyncResult('1234')
    p = CeleryProxy(asyncresult)

    p,_ = load_proxy(p.json())
    assert type(p) == CeleryProxy

    p.details()['task_id'] == asyncresult.task_id
Beispiel #6
0
    def fromJSON(cls, data, deserialization_opts = None):
        if data['task']['type'] == 'packtivity_task':
            task   = packtivity_task.fromJSON(data['task'], deserialization_opts)
            result = datamodel.create(data['result'],getattr(task.state,'datamodel',{})) if data['result'] else None
            instance = cls(data['name'], task, data['id'],result)

            adage.serialize.set_generic_data(instance,data)
            instance.resultproxy = load_proxy(data['proxy'],deserialization_opts, best_effort_backend = False) if data['proxy'] else None
            return instance
        else:
            raise RuntimeError('unknown task type',data['task']['type'])
Beispiel #7
0
def checkproxy(jsonfile):
    proxydata = json.load(open(jsonfile))
    proxy, backend = bkutils.load_proxy(proxydata, best_effort_backend = True)

    ready = backend.ready(proxy)

    click.secho('ready: {}'.format(ready))
    if ready:
        successful = backend.successful(proxy)
        click.secho('successful: {}'.format(successful))
        if successful:
            result = backend.result(proxy)
            click.secho('result: {}'.format(json.dumps(result.json())))
Beispiel #8
0
def checkproxy(jsonfile):
    proxydata = json.load(open(jsonfile))
    proxy, backend = bkutils.load_proxy(proxydata, best_effort_backend=True)

    ready = backend.ready(proxy)

    click.secho("ready: {}".format(ready))
    if ready:
        successful = backend.successful(proxy)
        click.secho("successful: {}".format(successful))
        if successful:
            result = backend.result(proxy)
            click.secho("result: {}".format(json.dumps(result.json())))
Beispiel #9
0
    def fromJSON(cls, data, deserialization_opts=None):
        if data['task']['type'] == 'packtivity_task':
            task = packtivity_task.fromJSON(data['task'], deserialization_opts)
            result = TypedLeafs(data['result'],
                                getattr(task.state, 'datamodel',
                                        {})) if data['result'] else None
            instance = cls(data['name'], task, data['id'], result)

            adage.serialize.set_generic_data(instance, data)
            instance.resultproxy = load_proxy(
                data['proxy'], deserialization_opts,
                best_effort_backend=False) if data['proxy'] else None
            return instance
        else:
            raise RuntimeError('unknown task type', data['task']['type'])
Beispiel #10
0
    def fromJSON(cls, data, deserialization_opts=None):
        if data["task"]["type"] == "packtivity_task":
            task = packtivity_task.fromJSON(data["task"], deserialization_opts)
            result = (
                datamodel.create(data["result"], getattr(task.state, "datamodel", {}))
                if data["result"]
                else None
            )
            instance = cls(data["name"], task, data["id"], result)

            adage.serialize.set_generic_data(instance, data)
            instance.resultproxy = (
                load_proxy(
                    data["proxy"], deserialization_opts, best_effort_backend=False
                )
                if data["proxy"]
                else None
            )
            return instance
        else:
            raise RuntimeError("unknown task type", data["task"]["type"])
Beispiel #11
0
 def fromJSON(cls, data, deserialization_opts=None):
     deserialization_opts = deserialization_opts or {}
     p = load_proxy(data["proxy"],
                    deserialization_opts,
                    best_effort_backend=False)
     return cls(p, data["cacheid"])
Beispiel #12
0
 def fromJSON(cls, data, deserialization_opts=None):
     deserialization_opts = deserialization_opts or {}
     return cls(load_proxy(data['proxy'], deserialization_opts),
                data['cacheid'],
                best_effort_backend=False)
Beispiel #13
0
def test_foreground():
    from packtivity.asyncbackends import ForegroundProxy

    p = ForegroundProxy({'hello': 'world'}, None, True)
    p, _ = load_proxy(p.json())
    assert type(p) == ForegroundProxy
def test_python():
    from packtivity.asyncbackends import ForegroundProxy

    p = ForegroundProxy({'hello': 'world'}, None, True)
    p = load_proxy(p.json(), {'proxy': 'py:packtivity.asyncbackends:ForegroundProxy'}, best_effort_backend = False)
    assert type(p) == ForegroundProxy
def test_foreground():
    from packtivity.asyncbackends import ForegroundProxy

    p = ForegroundProxy({'hello': 'world'}, None, True)
    p,_ = load_proxy(p.json())
    assert type(p) == ForegroundProxy
Beispiel #16
0
 def fromJSON(cls,data,deserialization_opts = None):
     deserialization_opts = deserialization_opts or {}
     return cls(load_proxy(data['proxy'],deserialization_opts), data['cacheid'],best_effort_backend = False)