ObjectStore
QuantConnect.Storage.ObjectStore
ObjectStore(store: IObjectStore)
Bases: Object, IObjectStore, Iterable[KeyValuePair[str, List[int]]]
Helper class for easier access to IObjectStore methods
Initializes a new instance of the ObjectStore class
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
IObjectStore
|
The IObjectStore instance to wrap |
required |
max_size
max_size: int
Gets the maximum storage limit in bytes
max_files
max_files: int
Gets the maximum number of files allowed
error_raised
error_raised: _EventContainer[
Callable[
[Object, ObjectStoreErrorRaisedEventArgs], Any
],
Any,
]
Event raised each time there's an error
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
save
save(path: str) -> bool
save(
path: str, text: str, encoding: Encoding = None
) -> bool
Signature descriptions:
-
Saves the data from a local file path associated with the specified path
-
Saves the object data in text format for the specified path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The object path |
required |
text
|
Optional[str]
|
The string object to be saved |
None
|
encoding
|
Optional[Encoding]
|
The string encoding used, Encoding.UTF8 by default |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the object was saved successfully. |
__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 |
read
read(path: str, encoding: Encoding = None) -> str
Returns the string object data for the specified path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The object path |
required |
encoding
|
Encoding
|
The string encoding used |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A string containing the data. |
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. |
read_string
read_string(path: str, encoding: Encoding = None) -> str
Returns the string object data for the specified path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The object path |
required |
encoding
|
Encoding
|
The string encoding used |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A string 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. |
save_string
save_string(
path: str, text: str, encoding: Encoding = None
) -> bool
Saves the object data in text format for the specified path
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The object path |
required |
text
|
str
|
The string object to be saved |
required |
encoding
|
Encoding
|
The string encoding used |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if the object was saved successfully. |