Skip to content

Commit 7ac25e1

Browse files
committed
Adding a limit parameter to osw.data.import_utility.get_entities_from_osw() to address issue #43
1 parent cafd31b commit 7ac25e1

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/osw/data/import_utility.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ def get_entities_from_osw(
760760
model_to_cast_to,
761761
cred_filepath,
762762
domain,
763+
limit: int = None,
763764
osw_obj: OSW = None,
764765
debug: bool = False,
765766
) -> list:
@@ -777,6 +778,8 @@ def get_entities_from_osw(
777778
Filepath to the credentials file, used to access the OSW instance.
778779
domain:
779780
Domain of the OSW instance.
781+
limit:
782+
Maximum number of entities returned by this query
780783
osw_obj:
781784
OSW instance to use. If None, a new instance is created.
782785
debug:
@@ -810,9 +813,17 @@ def test_if_empty_list_or_none(obj) -> bool:
810813
if debug:
811814
print(f"Searching for instances of {category_to_search} in OSW...")
812815
entities = wtsite_obj.semantic_search(
813-
query=wt.SearchParam(
814-
query=f"[[HasType::Category:OSW{str(category_uuid).replace('-', '')}]]",
815-
debug=debug,
816+
query=(
817+
wt.SearchParam(
818+
query=f"[[HasType::Category:OSW{str(category_uuid).replace('-', '')}]]",
819+
debug=debug,
820+
)
821+
if limit is None
822+
else wt.SearchParam(
823+
query=f"[[HasType::Category:OSW{str(category_uuid).replace('-', '')}]]",
824+
debug=debug,
825+
limit=limit,
826+
)
816827
)
817828
)
818829
for entity in entities:

0 commit comments

Comments
 (0)