Menu
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version
Publication date

Mar 9, 2022

Confidentiality
Public
Reactions
1
Share

DataFrameRField

Specific RField for Dataframe, these are loaded and dumped into a file

WARNING, this uses the pick function, only load file that you trust, otherwise it could execute malicious code

:param FileRField: [description] :type FileRField: [type]

Attributes
include_in_dict_view: boolstorage: RFieldStorage
Functions
__init__

Initialize a FileRField with automatic file-based persistence.

The field is configured to store file path references in KV_STORE and is excluded from dict views since the actual data is in files.

deserialize

Deserialize field value by loading data from the file path.

This method is marked as final and cannot be overridden. It delegates to the load_from_file method which must be implemented by subclasses.

r_field_value : str
File path where the data is stored
Return type : Any
dump_to_file

Serialize and save the field value to a file.

This abstract method must be implemented by subclasses to define how data is serialized and written to the file. It is called automatically when the Resource is saved.

The data MUST be written to the exact file path provided. The directory containing the file is guaranteed to exist.

r_field_value : DataFrame
The field value to serialize and save
file_path : str
Absolute path where the data should be saved
get_default_value

Get the default value for this field.

If the default value is a Type or Callable, it will be called to generate a new default value. Otherwise, the default value is returned directly.

This ensures that mutable defaults (like lists or dicts) are not shared between Resource instances.

Return type : Any
load_from_file

Load and deserialize the field value from a file.

This abstract method must be implemented by subclasses to define how data is read and deserialized from the file. It is called automatically when the Resource is loaded.

The file at file_path is guaranteed to exist when this method is called.

file_path : str
Absolute path to the file containing the serialized data
Return type : DataFrame
serialize

Serialize method not used for FileRField.

The actual serialization is handled by dump_to_file which is called by the resource persistence layer. This method exists for interface compatibility but should be ignored.

r_field_value : Any
The field value (ignored)
Return type : str
Shine Logo
Technical bricks to reuse or customize

Have you developed a brick?

Share it to accelerate projects for the entire community.