-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: Add client side caching and pre-loading support (#477)
- Loading branch information
Showing
11 changed files
with
338 additions
and
97 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
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 |
---|---|---|
@@ -1,14 +1,38 @@ | ||
"""This module contains utility functions for API development work.""" | ||
from ansys.api.edb.v1.layout_obj_pb2 import LayoutObjTargetMessage | ||
|
||
from ansys.edb.core.inner.factory import create_lyt_obj | ||
from ansys.edb.core.utility.cache import get_cache | ||
|
||
|
||
def map_list(iterable_to_operate_on, operator=None): | ||
"""Apply the given operator to each member of an iterable and return the modified list. | ||
Parameters | ||
--------- | ||
iterable_to_operate on | ||
iterable_to_operate_on | ||
operator | ||
""" | ||
return list( | ||
iterable_to_operate_on if operator is None else map(operator, iterable_to_operate_on) | ||
) | ||
|
||
|
||
def query_lyt_object_collection(owner, obj_type, unary_rpc, unary_streaming_rpc): | ||
"""For the provided request, retrieve a collection of objects using the unary_rpc or unary_streaming_rpc methods \ | ||
depending on whether caching is enabled.""" | ||
items = [] | ||
cache = get_cache() | ||
request = LayoutObjTargetMessage(target=owner.msg, type=obj_type.value) | ||
|
||
def add_msgs_to_items(edb_obj_collection_msg): | ||
nonlocal items | ||
for item in edb_obj_collection_msg.items: | ||
items.append(create_lyt_obj(item, obj_type)) | ||
|
||
if cache is None: | ||
add_msgs_to_items(unary_rpc(request)) | ||
else: | ||
for streamed_items in unary_streaming_rpc(request): | ||
add_msgs_to_items(streamed_items) | ||
return items |
Oops, something went wrong.