Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: return more aspen tag search results #357

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tagreader"
version = "5.4.0"
version = "5.4.1"
description = "Tagreader is a Python package for reading trend data from the OSIsoft PI and Aspen Infoplus.21 IMS systems."
authors = ["Einar S. Idsø <eiids@equinor.com>", "Morten Dæhli Aslesen <masl@equinor.com"]
license = "MIT"
Expand Down
6 changes: 4 additions & 2 deletions tagreader/web_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,13 @@ def generate_search_query(
tag: Optional[str],
desc: Optional[str],
datasource: Optional[str],
max: Optional[int] = 100000,
) -> Dict[str, Any]:
if not datasource:
raise ValueError("Data source is required argument")
# Aspen Web API expects single space instead of consecutive spaces.
tag = " ".join(tag.split())
params = {"datasource": datasource, "tag": tag, "max": 100, "getTrendable": 0}
params = {"datasource": datasource, "tag": tag, "max": max, "getTrendable": 0}
return params

def generate_read_query(
Expand Down Expand Up @@ -450,7 +451,7 @@ def search(
desc = desc.replace("*", ".*") if isinstance(desc, str) else None

params = self.generate_search_query(
tag=tag, desc=desc, datasource=self.datasource
tag=tag, desc=desc, datasource=self.datasource, max=100000
)
# Ensure space is encoded as "%20" instead of default "+" and leave asterisks
# unencoded. Otherwise, searches for tags containing spaces break, as do wildcard
Expand Down Expand Up @@ -744,6 +745,7 @@ def generate_search_query(
tag: Optional[str],
desc: Optional[str],
datasource: Optional[str],
max: Optional[int] = 100,
) -> Dict[str, str]:
q = []
if tag is not None:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_AspenHandlerREST.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ def test_generate_search_query() -> None:
with pytest.raises(ValueError):
AspenHandlerWeb.generate_search_query(tag="ATCAI", desc=None, datasource=None)
assert AspenHandlerWeb.generate_search_query(
tag="ATCAI", datasource="source_name", desc=None
tag="ATCAI", datasource="source_name", desc=None, max=100
) == {
"datasource": "source_name",
"tag": "ATCAI",
"max": 100,
"getTrendable": 0,
}
assert AspenHandlerWeb.generate_search_query(
tag="ATC*", datasource="source_name", desc=None
tag="ATC*", datasource="source_name", desc=None, max=100
) == {
"datasource": "source_name",
"tag": "ATC*",
Expand All @@ -38,7 +38,7 @@ def test_generate_search_query() -> None:
}
assert AspenHandlerWeb.generate_search_query(
tag="ATCAI", datasource="source_name", desc=None
) == {"datasource": "source_name", "tag": "ATCAI", "max": 100, "getTrendable": 0}
) == {"datasource": "source_name", "tag": "ATCAI", "max": 100000, "getTrendable": 0}


def test_split_tagmap() -> None:
Expand Down
Loading