Skip to content
Merged
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
603 changes: 305 additions & 298 deletions act/logs/GGIR_QC_errs.csv

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions act/tests/test_manifest_rebuild_from_lss.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,66 @@ def test_rebuild_manifest_payload_from_lss_aggregates_strict_errors(tmp_path, mo
assert "missing RedCap subject->lab mapping" in message


def test_rebuild_manifest_payload_from_lss_ignores_9000_subject_missing_mapping(
tmp_path, monkeypatch
):
save = _make_save_for_lss(tmp_path)

monkeypatch.setattr(
save,
"discover_lss_sessions",
lambda: (
{
"9000123": [
{
"subject_id": "9000123",
"study": "int",
"run": 1,
"file_path": "/lss/int/sub-9000123/accel/ses-1/sub-9000123_ses-1_accel.csv",
}
]
},
{},
),
)
monkeypatch.setattr(save, "_fetch_redcap_subject_lab_rows", lambda: [])
monkeypatch.setattr(save, "_list_rdss_metadata_rows", lambda: [])

payload = save.rebuild_manifest_payload_from_lss()

assert payload == {}


def test_rebuild_manifest_payload_from_lss_ignores_4digit_9000_series_missing_mapping(
tmp_path, monkeypatch
):
save = _make_save_for_lss(tmp_path)

monkeypatch.setattr(
save,
"discover_lss_sessions",
lambda: (
{
"9002": [
{
"subject_id": "9002",
"study": "int",
"run": 1,
"file_path": "/lss/int/sub-9002/accel/ses-1/sub-9002_ses-1_accel.csv",
}
]
},
{},
),
)
monkeypatch.setattr(save, "_fetch_redcap_subject_lab_rows", lambda: [])
monkeypatch.setattr(save, "_list_rdss_metadata_rows", lambda: [])

payload = save.rebuild_manifest_payload_from_lss()

assert payload == {}


def test_atomic_manifest_write_preserves_existing_manifest_on_failure(tmp_path, monkeypatch):
save = _make_save_for_lss(tmp_path)
manifest_path = tmp_path / "res" / "data.json"
Expand Down
14 changes: 14 additions & 0 deletions act/utils/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,18 @@ def _subject_order_key(self, subject_id):
except ValueError:
return (1, subject)

def _subject_exempt_from_manifest_metadata_strictness(self, subject_id):
subject_text = str(subject_id).strip()
if subject_text.startswith("9000"):
return True

try:
subject_value = int(subject_text)
except (TypeError, ValueError):
return False

return 9000 <= subject_value <= 9999

def _resolve_rdss_session_metadata_with_missing(
self,
discovered_sessions,
Expand Down Expand Up @@ -549,6 +561,8 @@ def rebuild_manifest_payload_from_lss(self):
report_rows,
)
for subject_id in missing_subjects:
if self._subject_exempt_from_manifest_metadata_strictness(subject_id):
continue
subject_errors.setdefault(subject_id, []).append(
"missing RedCap subject->lab mapping"
)
Expand Down
4 changes: 2 additions & 2 deletions cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ conda activate act

cd "${REPO_ROOT}"

git pull --ff-only origin final-test
git pull --ff-only

if [[ -z "${BOOST_TOKEN:-}" ]]; then
echo "BOOST_TOKEN is required. Aborting." >&2
Expand All @@ -22,7 +22,7 @@ DAYS_AGO="${DAYS_AGO:-30}"
mkdir -p "logs/${SYSTEM}"
LOG_FILE="logs/${SYSTEM}/$(date +%Y%m%d_%H%M%S).log"
export LOG_FILE
python -m act.main --daysago "${DAYS_AGO}" --token "${BOOST_TOKEN}" --system "${SYSTEM}" >> "${LOG_FILE}" 2>&1
python -m act.main --daysago "${DAYS_AGO}" --token "${BOOST_TOKEN}" --system "${SYSTEM}" --rebuild-manifest-only >> "${LOG_FILE}" 2>&1

if ! git diff --quiet; then
git add .
Expand Down
4 changes: 4 additions & 0 deletions data.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@
"8090": [
"data/int/UI/8090/daily_plot.png",
"data/int/UI/8090/summary_plot.png"
],
"8085": [
"data/int/UI/8085/daily_plot.png",
"data/int/UI/8085/summary_plot.png"
]
},
"NE": {
Expand Down
13 changes: 13 additions & 0 deletions features/FEATURE-cli-and-manifest-update/FIXES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Fixes for current logic issues in manifest // cli update

## Current bugs // logic issues
- Subjects starting with 9000 ids will not have a subject -> lab id mapping and will not be found in the rdss, remove warnings for these subjects that is causing strict conflict updates
^^ Expanded below


### 9000 IDs
---
***Dilemma***
- 9000 IDs are pulled outside of this workflow from another data source, this logic is currently stable and will always end like this
- Should these subjects even be added to the manifest if they are not truly required?
- They are ran automatically through the GGIR script thus they should not be touched in this pipeline
Loading