-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mostly working refactored snapshot functionality. Failing tests are (…
…mostly) unrelated
- Loading branch information
Showing
15 changed files
with
733 additions
and
495 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
from typing import TypeAlias | ||
|
||
from omnipy.modules.general.models import Model, NestedFrozenDictsOrTuplesModel | ||
from tests.modules.general.cases.raw.examples import (e_complex_key_dict, | ||
e_int_key_dict, | ||
e_none_key_dict, | ||
ej_frozendict_iterable_scalar, | ||
ej_frozendict_iterable_scalar_empty, | ||
ej_frozendict_wrong_scalar, | ||
ej_tuple_iterable_scalar, | ||
ej_tuple_wrong_scalar, | ||
ej_type, | ||
f_complex, | ||
f_dict, | ||
f_frozendict, | ||
f_int, | ||
f_list, | ||
f_none, | ||
f_set, | ||
f_str, | ||
f_tuple) | ||
|
||
FSK: TypeAlias = int | str | complex # for keys | ||
FSV: TypeAlias = None | int | str | complex # for values | ||
|
||
|
||
def run_nested_frozen_dicts_or_tuples_model() -> None: | ||
_two_level_list: list[FSV | list[FSV] | dict[str, FSV]] = \ | ||
f_list + [list(f_list)] + [dict(f_dict)] | ||
_two_level_dict: dict[str, str | list[FSV] | dict[str, FSV]] = \ | ||
{'a': f_str, 'b': list(f_list), 'c': dict(f_dict)} | ||
|
||
number_model = Model[int](123) | ||
|
||
print(number_model.snapshot_holder._deepcopy_memo) | ||
|
||
number_model.snapshot_holder._deepcopy_memo.clear() | ||
|
||
print(number_model.snapshot_holder._deepcopy_memo) | ||
|
||
nested_frozen_dicts_or_tuples = ( | ||
list(f_list + [list(f_list), dict(f_dict), list(_two_level_list), dict(_two_level_dict)])) | ||
nested_frozen_dicts_or_tuples_model = NestedFrozenDictsOrTuplesModel( | ||
nested_frozen_dicts_or_tuples) | ||
|
||
print(len(number_model.snapshot_holder._deepcopy_memo)) | ||
k = 0 | ||
v = 0 | ||
for k, v in number_model.snapshot_holder._deepcopy_memo.items(): | ||
print(f'{k}: {v}') | ||
del k | ||
del v | ||
|
||
del nested_frozen_dicts_or_tuples_model | ||
number_model.snapshot_holder.delete_scheduled() | ||
print(number_model.snapshot_holder._deepcopy_memo) | ||
|
||
assert len(number_model.snapshot_holder._deepcopy_memo) == 0 | ||
|
||
|
||
run_nested_frozen_dicts_or_tuples_model() |
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 @@ | ||
import cProfile | ||
from importlib import import_module | ||
import os | ||
import pstats | ||
import sys | ||
|
||
if __name__ == '__main__': | ||
script_path = os.path.abspath(sys.argv[1]) | ||
project_path = os.path.abspath(__file__ + '/../..') | ||
|
||
print(f'script_path: {script_path}') | ||
print(f'project_path: {project_path}') | ||
|
||
assert script_path.startswith(project_path) | ||
module = '.'.join(script_path.split('.')[0][len(project_path) + 1:].split('/')) | ||
|
||
# print(f'package: {package}') | ||
print(f'module: {module}') | ||
|
||
sys.path.append(project_path) | ||
|
||
mod = import_module(module) | ||
|
||
profiler = cProfile.Profile() | ||
profiler.enable() | ||
|
||
mod.run() | ||
|
||
profiler.disable() | ||
stats = pstats.Stats(profiler).sort_stats('cumtime') | ||
stats.dump_stats('latest4.pstats') | ||
print('dumped') |
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
Oops, something went wrong.