How to use the descarteslabs.common.graft.client.apply_graft function in descarteslabs

To help you get started, we’ve selected a few descarteslabs 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 descarteslabs / descarteslabs-python / descarteslabs / workflows / types / datetimes / timedelta.py View on Github external
def __init__(
        self,
        days=0,
        seconds=0,
        microseconds=0,
        milliseconds=0,
        minutes=0,
        hours=0,
        weeks=0,
    ):
        self.graft = client.apply_graft(
            "timedelta.from_components",
            days=days,
            seconds=seconds,
            microseconds=microseconds,
            milliseconds=milliseconds,
            minutes=minutes,
            hours=hours,
            weeks=weeks,
        )
github descarteslabs / descarteslabs-python / descarteslabs / workflows / types / geospatial / groupby.py View on Github external
func: Function
            Key function which takes an `Image` and returns which group the `Image` belongs to.
            Must return an instance of ``self.key_type``.

        Returns
        -------
        grouped: ImageCollectionGroupby
        """
        if self._type_params is None:
            raise TypeError(
                "Cannot instantiate a generic {}; the item type must be specified".format(
                    type(self).__name__
                )
            )

        self.graft = client.apply_graft("ImageCollectionGroupby.create", imgs, func)

        # store this once so that repeated calls to `.groups` refer to the same object in the graft
        self._groups = Dict[self.key_type, ImageCollection]._from_apply(
            "ImageCollectionGroupby.groups", self
        )
github descarteslabs / descarteslabs-python / descarteslabs / workflows / types / containers / dict_.py View on Github external
"Expected Dict values of type {}, but got {}".format(vt, val)
                    )
                if is_str_dict:
                    promoted[key] = promoted_val
                    # note we use the unpromoted key, which should be a string
                    # this is an optimization that produces a cleaner graph for the case of string-keyed dicts
                else:
                    promoted += [promoted_key, promoted_val]
                    # for non-string dicts, we just give varargs of key, value, key, value, ...
                    # since that's a much simpler graft representation than constructing a list
                    # of tuples

            if is_str_dict:
                self.graft = client.apply_graft("dict.create", **promoted)
            else:
                self.graft = client.apply_graft("dict.create", *promoted)
github descarteslabs / descarteslabs-python / descarteslabs / workflows / types / core / core.py View on Github external
def _from_apply(cls, function, *args, **kwargs):
        "Shorthand for ``cls._from_graft(client.apply_graft(function, *args, **kwargs))``"
        return cls._from_graft(client.apply_graft(function, *args, **kwargs))