objectstore API Detail#

These functions are used by OpenGHG to store and retrieve data from the object store.

openghg.objectstore.delete_object(bucket, key)[source]#

Remove object at key in bucket

Parameters
  • bucket (str) – Bucket path

  • key (str) – Key to data in bucket

Return type

None

Returns

None

openghg.objectstore.get_all_object_names(bucket, prefix=None, without_prefix=False)[source]#

Returns the names of all objects in the passed bucket

Parameters
  • bucket (str) – Bucket path

  • prefix (Optional[str]) – Prefix for keys

  • without_prefix (bool) – If True don’t use prefix

Returns

List of object names

Return type

list

openghg.objectstore.get_object_names(bucket, prefix=None)[source]#

List all the keys in the object store

Parameters

bucket (str) – Bucket containing data

Returns

List of keys in object store

Return type

list

openghg.objectstore.get_bucket(empty=False)[source]#

Find and return a new bucket in the object store called ‘bucket_name’. If ‘create_if_needed’ is True then the bucket will be created if it doesn’t exist. Otherwise, if the bucket does not exist then an exception will be raised.

Return type

str

openghg.objectstore.get_object(bucket, key)[source]#

Gets the object at key in the passed bucket

Parameters
  • bucket (str) – Bucket containing data

  • key (str) – Key for data in bucket

Returns

Object from store

Return type

Object

openghg.objectstore.set_object(bucket, key, data)[source]#

Store data in bucket at key

Parameters
  • bucket (str) – Bucket path

  • key (str) – Key to store data in bucket

  • data (bytes) – Data in string form

Return type

None

Returns

None

openghg.objectstore.set_object_from_json(bucket, key, data)[source]#

Set JSON data in the object store

Parameters
  • bucket (str) – Bucket for data storage

  • key (str) – Key for data in bucket

  • data (Union[str, Dict]) – JSON serialised data string

Return type

None

Returns

None

openghg.objectstore.set_object_from_file(bucket, key, filename)[source]#

Set the contents of file at filename to key in bucket

Parameters
  • bucket (str) – Bucket path

  • key (str) – Key to for data

  • filename (str, pathlib.Path) – Filename/path

Return type

None

Returns

None

openghg.objectstore.get_object_from_json(bucket, key)[source]#

Return an object constructed from JSON stored at key.

Parameters
  • bucket (str) – Bucket containing data

  • key (str) – Key for data in bucket

Returns

Dictionary

Return type

dict

openghg.objectstore.exists(bucket, key)[source]#

Checks if there is an object in the object store with the given key

Parameters
  • bucket (str) – Bucket containing data

  • key (str) – Prefix for key in object store

Returns

True if key exists in store

Return type

bool

openghg.objectstore.visualise_store()[source]#

View the object store using a pyvis force graph.

This function should only be called from within a notebook

Return type

Network

Returns

pyvis.network.Network