Skip to content

Commit 8399b56

Browse files
authored
Merge pull request #420 from AllenNeuralDynamics/release-v2.1.2
release v2.1.2
2 parents 6f3a2ef + 29ec95f commit 8399b56

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

src/aind_data_transfer_service/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import yaml
99
from pythonjsonlogger import json as log_json
1010

11-
__version__ = "2.1.1"
11+
__version__ = "2.1.2"
1212

1313

1414
# We want to standardize the timestamp format to UTC and ISO-8601, which

src/aind_data_transfer_service/log_handler.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
"""Module to handle logging submit job requests"""
22

33
import logging
4+
from datetime import datetime
45
from enum import Enum
56
from typing import Any
67

8+
from aind_data_schema_models.data_name_patterns import build_data_name
9+
710

811
class EventType(str, Enum):
912
"""Enum for event types in structured logging"""
@@ -13,6 +16,22 @@ class EventType(str, Enum):
1316
STAGE_FAILURE = "stage_failure"
1417

1518

19+
def compute_label(upload_job: dict) -> str:
20+
"""Hack to compute acquisition_name from raw user input. This can be
21+
cleaned up in the next major release."""
22+
subject_id = upload_job.get("subject_id")
23+
acq_datetime = datetime.fromisoformat(upload_job.get("acq_datetime"))
24+
platform = upload_job.get("platform")
25+
if platform is not None:
26+
label = f"{platform['abbreviation']}_{subject_id}"
27+
else:
28+
label = subject_id
29+
return build_data_name(
30+
label=label,
31+
creation_datetime=acq_datetime,
32+
)
33+
34+
1635
def log_submit_job_request(
1736
content: Any, event_type: EventType | None = None
1837
) -> None:
@@ -35,7 +54,7 @@ def log_submit_job_request(
3554
):
3655
for row in upload_jobs:
3756
subject_id = row.get("subject_id")
38-
acquisition_name = row.get("s3_prefix")
57+
acquisition_name = compute_label(row)
3958
extra_info = {
4059
"subject_id": subject_id,
4160
"acquisition_name": acquisition_name,

tests/test_log_handler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class TestLogHandler(unittest.TestCase):
2020
def test_log_submit_job_request(self, mock_log: MagicMock):
2121
"""Tests log_submit_job_request"""
2222
content = {
23-
"upload_jobs": [{"s3_prefix": "abc-123", "subject_id": "123456"}]
23+
"upload_jobs": [
24+
{"acq_datetime": "2026-10-10T00:01:02", "subject_id": "123456"}
25+
]
2426
}
2527
log_submit_job_request(
2628
content=content, event_type=EventType.STAGE_START
@@ -30,7 +32,7 @@ def test_log_submit_job_request(self, mock_log: MagicMock):
3032
extra={
3133
"event_type": EventType.STAGE_START,
3234
"subject_id": "123456",
33-
"acquisition_name": "abc-123",
35+
"acquisition_name": "123456_2026-10-10_00-01-02",
3436
},
3537
)
3638

0 commit comments

Comments
 (0)