Skip to content

Commit 599ce37

Browse files
authored
[LIMS-2025] Use SCAUP token for upserting orphan samples (#24)
* Use SCAUP token for upserting orphan samples * Use SCAUP token for patching orphan samples
1 parent 3c069a8 commit 599ce37

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/scaup/crud/shipments.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ def create_all_items_in_shipment(
112112
)
113113

114114
for sample in containerless_samples:
115-
Expeye.upsert(token, sample, None, session_id)
115+
# There is no way of verifying orphan sample ownership in ISPyB, so we need to use SCAUP's
116+
# token instead to create them on behalf of SCAUP, which has permission to manipulate all samples.
117+
# TODO: revisit this when SCAUP creates containers, dewars and shipments for orphan samples
118+
Expeye.upsert(Config.ispyb_api.jwt, sample, None, session_id)
116119

117120
modified_items = list(create_all_items_in_shipment(shipment, f"{shipment.proposalCode}{shipment.proposalNumber}"))
118121

src/scaup/utils/external.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,11 @@ def upsert(
177177
ext_obj.url = f"{ext_obj.external_link_prefix}{item.externalId}"
178178
method = "PATCH"
179179

180+
# There is no way of verifying orphan sample ownership in ISPyB, so we need to use SCAUP's
181+
# token instead to create them on behalf of SCAUP, which has permission to manipulate all samples.
182+
# TODO: revisit this when SCAUP creates containers, dewars and shipments for orphan samples
180183
response = ExternalRequest.request(
181-
token,
184+
Config.ispyb_api.jwt,
182185
method=method,
183186
url=ext_obj.url,
184187
json=ext_obj.item_body.model_dump(mode="json", exclude=ext_obj.to_exclude),

0 commit comments

Comments
 (0)