LocalObjectStore
QuantConnect.Lean.Engine.Storage.LocalObjectStore
Bases: Object, IObjectStore, Iterable[KeyValuePair[str, List[int]]]
A local disk implementation of IObjectStore.
max_size
max_size: int
Gets the maximum storage limit in bytes
max_files
max_files: int
Gets the maximum number of files allowed
NO_READ_PERMISSIONS_ERROR
NO_READ_PERMISSIONS_ERROR: str = ...
No read permissions error message
This codeEntityType is protected.
NO_WRITE_PERMISSIONS_ERROR
NO_WRITE_PERMISSIONS_ERROR: str = ...
No write permissions error message
This codeEntityType is protected.
NO_DELETE_PERMISSIONS_ERROR
NO_DELETE_PERMISSIONS_ERROR: str = ...
No delete permissions error message
This codeEntityType is protected.
error_raised
error_raised: _EventContainer[
Callable[
[Object, ObjectStoreErrorRaisedEventArgs], Any
],
Any,
]
Event raised each time there's an error
default_object_store
default_object_store: str
Gets the default object store location
controls
controls: Controls
Provides access to the controls governing behavior of this instance, such as the persistence interval
This codeEntityType is protected.
algorithm_storage_root
algorithm_storage_root: str
The root storage folder for the algorithm
This codeEntityType is protected.
file_handler
file_handler: FileHandler
The file handler instance to use
This codeEntityType is protected.
keys
keys: ICollection[str]
Returns the file paths present in the object store. This is specially useful not to load the object store into memory
__iter__
__iter__() -> Iterator[KeyValuePair[str, List[int]]]
clear
clear() -> None
Will clear the object store state cache. This is useful when the object store is used concurrently by nodes which want to share information
contains_key
contains_key(path: str) -> bool
Determines whether the store contains data for the specified path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The object path |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the key was found. |
delete
delete(path: str) -> bool
Deletes the object data for the specified path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The object path |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the delete operation was successful. |
dispose
dispose() -> None
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
get_enumerator
get_enumerator() -> (
IEnumerator[KeyValuePair[str, List[int]]]
)
Returns an enumerator that iterates through the collection.
Returns:
| Type | Description |
|---|---|
IEnumerator[KeyValuePair[str, List[int]]]
|
A System.Collections.Generic.IEnumerator`1 that can be used to iterate through the collection. |
get_file_path
get_file_path(path: str) -> str
Returns the file path for the specified path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The object path |
required |
Returns:
| Type | Description |
|---|---|
str
|
The path for the file. |
initialize
initialize(
user_id: int,
project_id: int,
user_token: str,
controls: Controls,
algorithm_mode: AlgorithmMode,
) -> None
Initializes the object store
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
The user id |
required |
project_id
|
int
|
The project id |
required |
user_token
|
str
|
The user token |
required |
controls
|
Controls
|
The job controls instance |
required |
algorithm_mode
|
AlgorithmMode
|
The algorithm mode |
required |
internal_save_bytes
internal_save_bytes(path: str, contents: List[int]) -> bool
Won't trigger persist nor will check storage write permissions, useful on initialization since it allows read only permissions to load the object store
This codeEntityType is protected.
is_within_storage_limit
is_within_storage_limit(
path: str, contents: List[int]
) -> bool
Validates storage limits are respected on a new save operation
This codeEntityType is protected.
on_error_raised
on_error_raised(error: Exception) -> None
Event invocator for the error_raised event
This codeEntityType is protected.
path_for_key
path_for_key(path: str) -> str
Get's a file path for a given path. Internal use only because it does not guarantee the existence of the file.
This codeEntityType is protected.
persist_data
persist_data() -> bool
Overridable persistence function
This codeEntityType is protected.
Returns:
| Type | Description |
|---|---|
bool
|
True if persistence was successful, otherwise false. |
read_bytes
read_bytes(path: str) -> List[int]
Returns the object data for the specified path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The object path |
required |
Returns:
| Type | Description |
|---|---|
List[int]
|
A byte array containing the data. |
save_bytes
save_bytes(path: str, contents: List[int]) -> bool
Saves the object data for the specified path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The object path |
required |
contents
|
List[int]
|
The object data |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the save operation was successful. |
storage_root
storage_root() -> str
Storage root path
This codeEntityType is protected.