Fix Issue #39: Filter restricted data in wfcatalog_client#46
Fix Issue #39: Filter restricted data in wfcatalog_client#46NikolaosSokos merged 6 commits intoEIDA:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds functionality to filter restricted data from the WFCatalog client based on a new includerestricted parameter. When set to False (the default), the system now filters out restricted data segments before returning results to the user.
Key changes:
- Added
include_restrictedparameter to_apply_restricted_bitfunction to control filtering behavior - Modified
mongo_requestto pass theincluderestrictedparameter from request to the filtering function - Implemented logic to skip segments with
restr == "RESTRICTED"wheninclude_restrictedis False
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
apps/wfcatalog_client.py
Outdated
| if segment["restr"] == "RESTRICTED" and not include_restricted: | ||
| continue |
There was a problem hiding this comment.
The new filtering logic for restricted data lacks test coverage. Consider adding tests that verify:
- When
include_restrictedisFalse, restricted segments are excluded from results - When
include_restrictedisTrue, all segments (including restricted) are returned - The filtering correctly handles segments where
restris "RESTRICTED" vs other statuses
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
apps/wfcatalog_client.py:162
- The code accesses segment["restr"] at line 162, but this field is only explicitly set for segments in RESTRICTED_INVENTORY._restricted_seedIDs (line 147). For segments in _known_seedIDs but not in _restricted_seedIDs, the field is not set by this code. While the MongoDB projection includes "restr": 1 (line 24), if this field doesn't exist in some database documents, accessing it will cause a KeyError. Consider using segment.get("restr", None) at line 162 or explicitly setting segment["restr"] = None for segments not in _restricted_seedIDs to handle missing fields gracefully.
if sid in RESTRICTED_INVENTORY._restricted_seedIDs:
segment["restr"] = _get_restricted_status(segment)
if segment["restr"] in ["RESTRICTED", "PARTIAL"] and not include_restricted:
continue
results.append(
[
segment["net"],
segment["sta"],
segment["loc"],
segment["cha"],
segment["qlt"],
segment["srate"],
segment["ts"],
segment["te"],
segment["created"],
segment["restr"],
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.