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

support NO_ORG job filtering #2098

Merged
merged 3 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion platform_api/handlers/jobs_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ def create_from_query(self, query: MultiDictProxy) -> JobFilter: # type: ignore
for cluster_name in query.getall("cluster_name", [])
}
orgs = {
self._org_name_validator.check(org_name)
self._parse_org_name(org_name)
for org_name in query.getall("org_name", [])
}
projects = {
Expand Down Expand Up @@ -1134,6 +1134,13 @@ def create_from_query(self, query: MultiDictProxy) -> JobFilter: # type: ignore
**bool_filters, # type: ignore
)

def _parse_org_name(self, org_name: str) -> Optional[str]:
return (
None
if org_name.upper() == "NO_ORG"
zubenkoivan marked this conversation as resolved.
Show resolved Hide resolved
else self._org_name_validator.check(org_name)
)


@dataclass(frozen=True)
class BulkJobFilter:
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,11 @@ def test_create_from_query(self) -> None:
query = MultiDict([("logs_removed", "False")])
assert factory(query) == JobFilter(logs_removed=False)

query = MultiDict(
[("org_name", "NO_ORG"), ("org_name", "org1"), ("org_name", "org2")]
)
assert factory(query) == JobFilter(orgs={None, "org1", "org2"})

def test_create_from_query_with_status(self) -> None:
factory = JobFilterFactory().create_from_query

Expand Down Expand Up @@ -1185,6 +1190,7 @@ def test_create_from_query_by_hostname_with_status(self) -> None:
[("hostname", "testjob--johndoe.example.org"), ("project_name", "johndoe")],
[("hostname", "TESTJOB--johndoe.example.org")],
[("hostname", "testjob--JOHNDOE.example.org")],
[("org_name", "invalid_org")],
],
)
def test_create_from_query_fail(self, query: Any) -> None:
Expand Down