Cloud#
These functions are used by the OpenGHG cloud platform.
- openghg.cloud.create_file_package(filepath, obs_type)[source]#
Reads file metadata and compresses data to be sent to the serverless function
- Parameters:
filepath (
Path
) – Path of dataobs_type (
str
) – Observation type
- Returns:
Compressed data as bytes and dictionary of file metadata
- Return type:
tuple
- openghg.cloud.create_post_dict(function_name, data, metadata, file_metadata, precision_data=None, precision_file_metadata=None)[source]#
Create the dictionary to POST to the remote function
- Parameters:
function – Function name
data (
bytes
) – Compressed datametadata (
Dict
) – Metadata dictionaryfile_metadata (
Dict
) – File metadataprecision_data (
Optional
[Dict
]) – GCWERKS precision dataprecision_file_metadata (
Optional
[Dict
]) – GCWERKS precision file metadata
- Returns:
Dictionary ready for function call
- Return type:
dict
- openghg.cloud.call_function(data)[source]#
Calls an OpenGHG serverless function and returns its response
- Parameters:
data (
Dict
) – Data to POST. Must be a dictionary created using the create_post_dict function.- Returns:
Dictionary containing response status, headers and content.
- Return type:
dict
- openghg.cloud.package_from_function(data, metadata=None)[source]#
Creates a package of data ready to be sent back to the caller. This calculates the SHA1 sum of the passed data and compresses it. If metadata is passed this is added to the returned dictionary. No SHA1 is calculated for the metadata.
NOTE: This function should only be used internally by a serverless function.
- Parameters:
data (
bytes
) – Binary datametadata (
Optional
[str
]) – Result of json.dumps
- Returns:
Dictionary of compressed data and file metadata.
- Return type:
dict