How to use the datalab.storage._item.Item function in datalab

To help you get started, we’ve selected a few datalab 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 googledatalab / pydatalab / legacy_tests / kernel / storage_tests.py View on Github external
def bucket_items_side_effect(*args, **kwargs):
      bucket = args[0].name  # self
      if bucket == 'foo':
        return [
          datalab.storage._item.Item(bucket, 'item1', context=context),
          datalab.storage._item.Item(bucket, 'item2', context=context),
          datalab.storage._item.Item(bucket, 'item3', context=context),
        ]
      elif bucket == 'bar':
        return [
          datalab.storage._item.Item(bucket, 'object1', context=context),
          datalab.storage._item.Item(bucket, 'object3', context=context),
        ]
      else:
        return []
    return bucket_items_side_effect
github googledatalab / pydatalab / legacy_tests / kernel / storage_tests.py View on Github external
def bucket_items_side_effect(*args, **kwargs):
      bucket = args[0].name  # self
      if bucket == 'foo':
        return [
          datalab.storage._item.Item(bucket, 'item1', context=context),
          datalab.storage._item.Item(bucket, 'item2', context=context),
          datalab.storage._item.Item(bucket, 'item3', context=context),
        ]
      elif bucket == 'bar':
        return [
          datalab.storage._item.Item(bucket, 'object1', context=context),
          datalab.storage._item.Item(bucket, 'object3', context=context),
        ]
      else:
        return []
    return bucket_items_side_effect
github googledatalab / pydatalab / legacy_tests / kernel / storage_tests.py View on Github external
def bucket_items_side_effect(*args, **kwargs):
      bucket = args[0].name  # self
      if bucket == 'foo':
        return [
          datalab.storage._item.Item(bucket, 'item1', context=context),
          datalab.storage._item.Item(bucket, 'item2', context=context),
          datalab.storage._item.Item(bucket, 'item3', context=context),
        ]
      elif bucket == 'bar':
        return [
          datalab.storage._item.Item(bucket, 'object1', context=context),
          datalab.storage._item.Item(bucket, 'object3', context=context),
        ]
      else:
        return []
    return bucket_items_side_effect
github googledatalab / pydatalab / datalab / storage / _bucket.py View on Github external
def item(self, key):
    """Retrieves an Item object for the specified key in this bucket.

    The item need not exist.

    Args:
      key: the key of the item within the bucket.
    Returns:
      An Item instance representing the specified key.
    """
    return _item.Item(self._name, key, context=self._context)
github googledatalab / pydatalab / datalab / storage / _item.py View on Github external
Args:
      new_key: the new key to copy this item to.
      bucket: the bucket of the new item; if None (the default) use the same bucket.
    Returns:
      An Item corresponding to new key.
    Raises:
      Exception if there was an error copying the item.
    """
    if bucket is None:
      bucket = self._bucket
    try:
      new_info = self._api.objects_copy(self._bucket, self._key, bucket, new_key)
    except Exception as e:
      raise e
    return Item(bucket, new_key, new_info, context=self._context)