How to use the vaex.promise.Promise function in vaex

To help you get started, we’ve selected a few vaex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vaexio / vaex / packages / vaex-ui / vaex / ui / main.py View on Github external
# import vaex.ipkernel_qtapp
    # ipython_window = vaex.ipkernel_qtapp.SimpleWindow(app)
    main_thread = QtCore.QThread.currentThread()

    # print select_many(None, "lala", ["aap", "noot"] + ["item-%d-%s" % (k, "-" * k) for k in range(30)])
    # sys.exit(0)

    # sys._excepthook = sys.excepthook
    def qt_exception_hook(exctype, value, traceback):
        print("qt hook in thread: %r" % threading.currentThread())
        sys.__excepthook__(exctype, value, traceback)
        qt_exception(None, exctype, value, traceback)
        # sys._excepthook(exctype, value, traceback)
        # sys.exit(1)
    sys.excepthook = qt_exception_hook
    vaex.promise.Promise.unhandled = staticmethod(qt_exception_hook)
    # raise RuntimeError, "blaat"

    vaex_app = VaexApp(argv, open_default=True)

    def plot(*args, **kwargs):
        vaex_app.plot(*args, **kwargs)

    def select(*args, **kwargs):
        vaex_app.select(*args, **kwargs)

    """if 1:
        #   app = guisupport.get_app_qt4()
        print_process_id()

        # Create an in-process kernel
        # >>> print_process_id( )
github vaexio / vaex / python / vaex / dataset.py View on Github external
class ColumnBase(object):
	def __init__(self, dataset, expression):
		self.dataset = dataset
		self.expression = expression

class Column(ColumnBase):
	def get(self, i1, i2):
		return self.dataset.columns[self.name][i1:i2]

class ColumnExpression(ColumnBase):
	def __init__(self, dataset, expression):
		super(ColumnExpression, self).__init__(dataset, expression)

#	def get(self, i1, i2):

class Task(vaex.promise.Promise):
	def __init__(self, dataset, expressions):
		vaex.promise.Promise.__init__(self)
		self.dataset = dataset
		self.expressions = expressions
		self.expressions_all = list(expressions)

	@property
	def dimension(self):
		return len(self.expressions)

class TaskMapReduce(Task):
	def __init__(self, dataset, expressions, map, reduce, converter=lambda x: x, info=False):
		Task.__init__(self, dataset, expressions)
		self._map = map
		self._reduce = reduce
		self.converter = converter
github vaexio / vaex / packages / vaex-core / vaex / remote.py View on Github external
def wrap_future_with_promise(future):
    if isinstance(future, vaex.promise.Promise):  # TODO: not so nice, sometimes we pass a promise
        return future
    promise = vaex.promise.Promise()

    def callback(future):
        # print(("callback", future, future.result()))
        e = future.exception()
        if e:
            # print(("reject", e))
            promise.reject(e)
        else:
            promise.fulfill(future.result())
    future.add_done_callback(callback)
    return promise
github vaexio / vaex / packages / vaex-core / vaex / remote.py View on Github external
def _websocket_connect(self):
        def connected(websocket):
            logger.debug("connected to websocket: %s" % self._build_url(""))

        def failed(reason):
            logger.error("failed to connect to %s" % self._build_url(""))
        self.websocket_connected = vaex.promise.Promise()
        self.websocket_connected.then(connected, failed)
        if 0:
            connected = wrap_future_with_promise(tornado.websocket.websocket_connect(self._build_url("websocket"), on_message_callback=self._on_websocket_message))
            connected.get()
            self.websocket_connected.fulfill(connected)

        def do():
            try:
                logger.debug("wrapping promise")
                logger.debug("connecting to: %s", self._build_url("websocket"))
                connected = wrap_future_with_promise(tornado.websocket.websocket_connect(self._build_url("websocket"), on_message_callback=self._on_websocket_message))
                logger.debug("continue")
                self.websocket_connected.fulfill(connected)
            except:
                logger.exception("error connecting")
                # raise
github vaexio / vaex / packages / vaex-ui / vaex / ui / layers.py View on Github external
if vmin is None or vmax is None:
					missing = True
		self.subspace = self.dataset(*self.state.expressions, delay=True)
		#subspace_ranges = self.subspace
		all_expressions = self.state.expressions
		if self.layer_slice_source:
			all_expressions = self.state.expressions + self.layer_slice_source.expressions
			#self.subspace = self.dataset(*all_expressions, delay=True)

		if missing:
			logger.debug("first we calculate min max for this layer")
			#return self.add_task(subspace_ranges.minmax()).then(self.got_limits, self.on_error).then(None, self.on_error)
			return self.dataset.minmax(all_expressions, delay=True, progress=self.progressbar.add(name="for minmaxes")).then(self.got_limits, self.on_error).then(None, self.on_error)
		else:
			#self.got_limits(self.state.ranges_grid)
			return vaex.promise.Promise.fulfilled(self)
github vaexio / vaex / packages / vaex-core / vaex / tasks.py View on Github external
def __init__(self, df=None, expressions=[], pre_filter=False, name="task"):
        vaex.promise.Promise.__init__(self)
        self.df = df
        self.expressions = expressions
        self.expressions_all = list(expressions)
        self.signal_progress = vaex.events.Signal("progress (float)")
        self.progress_fraction = 0
        self.signal_progress.connect(self._set_progress)
        self.cancelled = False
        self.name = name
        self.pre_filter = pre_filter
github vaexio / vaex / python / vaex / dataset.py View on Github external
def __init__(self, dataset, expressions):
		vaex.promise.Promise.__init__(self)
		self.dataset = dataset
		self.expressions = expressions
		self.expressions_all = list(expressions)
github vaexio / vaex / packages / vaex-core / vaex / legacy.py View on Github external
means, vars = self._unpack(means), self._unpack(vars)
            # return self.subspace.correlation(means=means, vars=vars)
            return vaex.promise.listPromise([subspace.correlation(means=subspace_mean, vars=subspace_var) for subspace_mean, subspace_var, subspace in zip(means, vars, self.subspaces)])
        if means is not None:
            means = self._pack(means)
        if vars is not None:
            vars = self._pack(vars)
        if self.delay:
            if means is None:
                mean_promise = self.subspace.mean()
            else:
                mean_promise = vaex.promise.Promise.fulfilled(means)
            if vars is None:
                var_promise = mean_promise.then(var)
            else:
                var_promise = vaex.promise.Promise.fulfilled(vars)
            mean_and_var_calculated = vaex.promise.listPromise(mean_promise, var_promise)
            return mean_and_var_calculated.then(correlation)
        else:
            if means is None:
                means = self.subspace.mean()
            if vars is None:
                vars = self.subspace.var(means=means)
            means = self._unpack(means)
            vars = self._unpack(vars)
            return [subspace.correlation(means=subspace_mean, vars=subspace_var) for subspace_mean, subspace_var, subspace in zip(means, vars, self.subspaces)]
            # return correlation((means, vars))