File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 11import os
2+ import warnings
23
34import json
45from contextlib import nullcontext
@@ -496,7 +497,20 @@ def client_location(self) -> str:
496497 return location
497498
498499 def _surveillance_flags (self , sample_sets : List [str ]):
499- raise NotImplementedError ("Subclasses must implement `_surveillance_flags`." )
500+ """Return surveillance flags for sample sets. Subclasses should override to
501+ load real data; this base implementation returns empty data and warns.
502+ """
503+ warnings .warn (
504+ "Surveillance flags not implemented for this resource; returning empty data." ,
505+ UserWarning ,
506+ stacklevel = 2 ,
507+ )
508+ return pd .DataFrame (
509+ {
510+ "sample_id" : pd .Series (dtype = "object" ),
511+ "is_surveillance" : pd .Series (dtype = "boolean" ),
512+ }
513+ )
500514
501515 def _release_has_unrestricted_data (self , * , release : str ):
502516 """Return `True` if the specified release has any unrestricted data. Otherwise return `False`."""
Original file line number Diff line number Diff line change @@ -411,3 +411,28 @@ def test_sample_sets_no_terms_of_use(ag3_sim_fixture):
411411 finally :
412412 for mp , bp in zip (manifest_paths , backups ):
413413 shutil .move (bp , mp )
414+
415+
416+ class TestSurveillanceFlagsBaseFallback :
417+ """Tests for issue #1206: base _surveillance_flags graceful fallback."""
418+
419+ def test_surveillance_flags_base_returns_empty_and_warns (self , ag3_sim_api ):
420+ """Base implementation returns empty DataFrame with correct schema and warns."""
421+ with pytest .warns (UserWarning , match = "Surveillance flags not implemented" ):
422+ df = ag3_sim_api ._surveillance_flags (sample_sets = ["AG1000G-AO" ])
423+
424+ assert isinstance (df , pd .DataFrame )
425+ assert list (df .columns ) == ["sample_id" , "is_surveillance" ]
426+ assert df ["sample_id" ].dtype == object
427+ assert pd .api .types .is_bool_dtype (df ["is_surveillance" ])
428+ assert len (df ) == 0
429+
430+ def test_sample_set_has_surveillance_data_returns_false_when_fallback (
431+ self , ag3_sim_api
432+ ):
433+ """_sample_set_has_surveillance_data returns False when base fallback is used."""
434+ with pytest .warns (UserWarning , match = "Surveillance flags not implemented" ):
435+ result = ag3_sim_api ._sample_set_has_surveillance_data (
436+ sample_set = "AG1000G-AO"
437+ )
438+ assert not result
You can’t perform that action at this time.
0 commit comments