-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Saving Long-term Memory (#463)
* Added LTM utils. (#462) * Added config `use_ltm`. (#462) * Migrated `distance_between()` to `leads.data`. (#462) * Supported odometer under GPS-only mode. (#462) * Merged submodules.
- Loading branch information
Showing
9 changed files
with
66 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from json import loads as _loads, dumps as _dumps | ||
from os.path import abspath as _abspath | ||
|
||
from leads.types import SupportedConfigValue as _SupportedConfigValue | ||
|
||
_ltm: dict[str, _SupportedConfigValue] = {} | ||
|
||
|
||
def _load_ltm() -> None: | ||
global _ltm | ||
with open(f"{_abspath(__file__)[:-6]}_ltm/core", "r") as f: | ||
ltm_content = f.read() | ||
if not (ltm_content.startswith("{") and ltm_content.endswith("}")): | ||
ltm_content = "{}" | ||
_ltm = _loads(ltm_content) | ||
|
||
|
||
def _sync_ltm() -> None: | ||
with open(f"{_abspath(__file__)[:-6]}_ltm/core", "w") as f: | ||
f.write(_dumps(_ltm)) | ||
|
||
|
||
def ltm_get(key: str) -> _SupportedConfigValue: | ||
return _ltm[key] | ||
|
||
|
||
def ltm_set(key: str, value: _SupportedConfigValue) -> None: | ||
_ltm[key] = value | ||
_sync_ltm() | ||
|
||
|
||
_load_ltm() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters