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
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
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
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'])
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())))
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())))
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'])
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"])
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"])
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)
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
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)