Objectstore#
These functions are used by OpenGHG to store and retrieve data from the object store. OpenGHG will call either local object
store functions (that create an object store on disk) or cloud object store functions depending on its environment. Within the
__init__.py of openghg.objectstore
a check is made to see if the environment is the OpenGHG hub or a serverless function.
Local#
These functions handle data storage on disk.
- openghg.objectstore.delete_object(bucket, key)[source]#
Remove object at key in bucket
- Parameters:
bucket (
str
) – Bucket pathkey (
str
) – Key to data in bucket
- Return type:
None
- Returns:
None
- 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 datakey (
str
) – Prefix for key in object store
- Returns:
True if key exists in store
- Return type:
bool
- 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 pathprefix (
Optional
[str
]) – Prefix for keyswithout_prefix (
bool
) – If True don’t use prefix
- Returns:
List of object names
- Return type:
list
- openghg.objectstore.get_bucket(name=None)[source]#
Find and return the local object store path. This will return the path to the user’s local object store if no name is given.
- Parameters:
name (
Optional
[str
]) – Object store name in config file- Returns:
Path to object store
- Return type:
str
- openghg.objectstore.get_object(bucket, key)[source]#
Gets the object at key in the passed bucket
- Parameters:
bucket (
str
) – Bucket containing datakey (
str
) – Key for data in bucket
- Returns:
Binary data from the store
- Return type:
bytes
- openghg.objectstore.get_object_from_json(bucket, key)[source]#
Return an object constructed from JSON stored at key.
- Parameters:
bucket (
str
) – Bucket containing datakey (
str
) – Key for data in bucket
- Returns:
Dictionary
- Return type:
dict
- 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_tutorial_store_path()[source]#
Get the path to the local tutorial store
- Returns:
Path of tutorial store
- Return type:
pathlib.Path
- openghg.objectstore.query_store()[source]#
Create a dictionary that can be used to visualise the object store
- Returns:
Dictionary for data to be shown in force graph
- Return type:
dict
- openghg.objectstore.set_object(bucket, key, data)[source]#
Store data in bucket at key
- Parameters:
bucket (
str
) – Bucket pathkey (
str
) – Key to store data in bucketdata (
bytes
) – Data in string form
- Return type:
None
- Returns:
None