earthkit.data.targets¶
Submodules¶
Attributes¶
Classes¶
Represent a target. |
|
Represent a target. |
|
Functions¶
|
|
|
Write data to a target. |
Package Contents¶
- class earthkit.data.targets.SimpleTarget(encoder=None, template=None, metadata=None, **kwargs)¶
Bases:
TargetRepresent a target.
- Parameters:
encoder (
str,Encoder,None) – The encoder to use to encode the data. Can be overridden in the thewritemethod. When a string is passed, the encoder is looked up in the available encoders. When None, the encoder will be determined from the data to write (if possible) or from theTargetproperties.template (
obj,None) – The template to use to encode the data. Can be overridden in thewritemethod.metadata (
dict,None) – Metadata to pass to the encoder.
:param The
Targetis used to write data to a specific location. The target can be: :param a file: :param a database: :param a remote server: :param etc.:- abstractmethod close()¶
Close the target.
The implementation must close the target and release any resources. It must also call
_mark_closed. The target will not be able to write anymore.- Raises:
ValueError –
- property closed¶
True if the target is closed, False otherwise.
- abstractmethod flush()¶
Flush the target.
Some targets may require to flush the data to the underlying storage.
- Raises:
ValueError –
- write(data=None, **kwargs)¶
Write data to the target using the given encoder.
- Parameters:
data (
obj,None) – The data object to write. If None, the encoder will use all the other arguments to generate the data to write.encoder (
str,Encoder,None) – The encoder to use to encode the data. When a string is passed, the encoder is looked up in the available encoders. When None, the encoder theTargetwas created with will be used if available. Otherwise, the encoder will be determined from the data to write (if possible) or from theTargetproperties.template (
obj,None) – The template to use to encode the data. When None, the template theTargetwas created with will be used if available.metadata (
dict,None) – Metadata to pass to the encoder.**kwargs (
dict) – Other keyword arguments passed to the encoder.
- Raises:
ValueError –
- class earthkit.data.targets.Target(encoder=None, template=None, metadata=None, **kwargs)¶
Represent a target.
- Parameters:
encoder (
str,Encoder,None) – The encoder to use to encode the data. Can be overridden in the thewritemethod. When a string is passed, the encoder is looked up in the available encoders. When None, the encoder will be determined from the data to write (if possible) or from theTargetproperties.template (
obj,None) – The template to use to encode the data. Can be overridden in thewritemethod.metadata (
dict,None) – Metadata to pass to the encoder.
:param The
Targetis used to write data to a specific location. The target can be: :param a file: :param a database: :param a remote server: :param etc.:- abstractmethod close()¶
Close the target.
The implementation must close the target and release any resources. It must also call
_mark_closed. The target will not be able to write anymore.- Raises:
ValueError –
- property closed¶
True if the target is closed, False otherwise.
- abstractmethod flush()¶
Flush the target.
Some targets may require to flush the data to the underlying storage.
- Raises:
ValueError –
- abstractmethod write(data=None, encoder=None, template=None, metadata=None, **kwargs)¶
Write data to the target using the given encoder.
- Parameters:
data (
obj,None) – The data object to write. If None, the encoder will use all the other arguments to generate the data to write.encoder (
str,Encoder,None) – The encoder to use to encode the data. When a string is passed, the encoder is looked up in the available encoders. When None, the encoder theTargetwas created with will be used if available. Otherwise, the encoder will be determined from the data to write (if possible) or from theTargetproperties.template (
obj,None) – The template to use to encode the data. When None, the template theTargetwas created with will be used if available.metadata (
dict,None) – Metadata to pass to the encoder.**kwargs (
dict) – Other keyword arguments passed to the encoder.
- Raises:
ValueError –
- class earthkit.data.targets.TargetLoader¶
- kind = 'target'¶
- load_entry(entry)¶
- load_module(module)¶
- load_remote(name)¶
- earthkit.data.targets.create_target¶
- earthkit.data.targets.target_kwargs(target_type)¶
- earthkit.data.targets.to_target(target, *args, **kwargs)¶
Write data to a target.
This is a top level function that writes data to a target.
- Parameters:
target (
str) – The target to write to. Must be a string.