browser

BrowserObject()

S3Directory(path, interface)

Get an object that allows you to tab-complete your way through your objects.

S3FSLike(path, interface)

Base class for file-system-like backend_interface to S3

S3HDF5(path, interface)

BrowserObject

class cottoncandy.browser.BrowserObject

Bases: object

__init__()

S3Directory

class cottoncandy.browser.S3Directory(path, interface)

Bases: cottoncandy.browser.S3FSLike

Get an object that allows you to tab-complete your way through your objects. One also has access to _ls() and _fullpath() methods.

__init__(path, interface)
Parameters
  • path (str) – The path to start naviation from

  • interface – A cottoncandy.InterfaceObject instance

Returns

ccbrowser – A cottoncandy browser object

Return type

cottoncandy.BrowserObject

Examples

>>> import cottoncandy as cc
>>> browser = cc.get_browser('my_bucket_name')
>>> browser.s<TAB>
browser.sweet_project
>>> browser.sweet_project
cottoncandy-path <bucket:my_bucket_name> sweet_project
>>> browser.sweet_project.sub<TAB>
browser.sweet_project.sub01_awesome_analysis_DOT_grp
browser.sweet_project.sub02_awesome_analysis_DOT_grp
>>> browser.sweet_project.sub01_awesome_analysis_DOT_grp
<cottoncandy-group <bucket:my_bucket_name> (sub01_awesome_analysis.grp: 3 keys)>

We can also explore the contents of the grp object

>>> browser.sweet_project.sub01_awesome_analysis_DOT_grp.<TAB>
browser.sweet_project.sub01_awesome_analysis_DOT_grp.result_model01
browser.sweet_project.sub01_awesome_analysis_DOT_grp.result_model02
browser.sweet_project.sub01_awesome_analysis_DOT_grp.result_model03

Let’s look at one

>>> browser.sweet_project.sub01_awesome_analysis_DOT_grp.result_model01
<cottoncandy-dataset <bucket:my_bucket_name [1.00MB:shape=(10000)]>

We can download the data

>>> arr = browser.sweet_project.sub01_awesome_analysis_DOT_grp.result_model01.load()
>>> arr.shape
(10000,)

We can also ask for the object name in the bucket

>>> browser.sweet_project.sub01_awesome_analysis_DOT_grp._fullpath
'sweet_project/sub01_awesome_analysis.grp/result_model01'

We can also download the object. Useful when dealing with other object types

>>> browser.sweet_project.sub01_awesome_analysis_DOT_grp.result_model01()
s3.Object(bucket_name='my_bucket_name', key='sweet_project/sub01_awesome_analysis.grp/result_model01')

S3FSLike

class cottoncandy.browser.S3FSLike(path, interface)

Bases: cottoncandy.browser.BrowserObject

Base class for file-system-like backend_interface to S3

__init__(path, interface)
path: str

The path to start naviation from

backend_interface:

A cottoncandy.InterfaceObject instance

S3HDF5

class cottoncandy.browser.S3HDF5(path, interface)

Bases: cottoncandy.browser.S3Directory

__init__(path, interface)
keys()

Show the contents of

load(key=None)