export
table.export
Documentation
Export a table object to disk.
Origin
Authors Markus Binsteiner (markus@frkl.io)
Context
Tags core
Labels package: kiara_modules.core
References source_repo:
https://github.com/DHARPA-Project/kia…
documentation:
https://dharpa.org/kiara_modules.core/
module_doc:
https://dharpa.org/kiara_modules.core…
source_url:
https://github.com/DHARPA-Project/kia…
Module config
Field Type Description Required
─────────────────────────────────────────────────────
constants object Value constants for no
this module.
defaults object Value defaults for no
this module.
Module config -- no config --
Python class
class_name ExportArrowTable
module_name kiara_modules.core.table
full_name kiara_modules.core.table.ExportArrow…
Processing source code ─────────────────────────────────────────────────────
def process(self, inputs: ValueSet, outputs: Value…
import pyarrow as pa
from pyarrow import feather
table: pa.Table = inputs.get_value_data("table…
full_path: str = inputs.get_value_data("path")
force_overwrite = inputs.get_value_data("force…
format: str = inputs.get_value_data("format")
compression = inputs.get_value_data("compressi…
if compression not in ["zstd", "lz4", "uncompr…
raise KiaraProcessingException(
f"Invalid compression format '{compres…
)
if format != "feather":
raise KiaraProcessingException(
f"Can't export table to format '{forma…
)
if os.path.exists(full_path) and not force_ove…
raise KiaraProcessingException(
f"Can't write table to file, file alre…
)
os.makedirs(os.path.dirname(full_path), exist_…
feather.write_feather(table, full_path, compre…
result = {
"module_type": "table.load",
"base_path_input_name": "base_path",
"inputs": {
"base_path": os.path.dirname(full_path…
"rel_path": os.path.basename(full_path…
"format": format,
},
"value_id": NO_VALUE_ID_MARKER,
"output_name": "table",
}
outputs.set_value("load_config", result)
─────────────────────────────────────────────────────