Skip to content

Commit

Permalink
Return storage alias in dataset information service response (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
mephenor authored Oct 11, 2024
1 parent 5947e81 commit 5e41b4d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,16 @@ components:
exclusiveMinimum: 0.0
title: Size
type: integer
storage_alias:
description: Alias of the storage location where the corresponding file
data resides in permanent storage.
title: Storage Alias
type: string
required:
- accession
- size
- sha256_hash
- storage_alias
title: FileInformation
type: object
HTTPValidationError:
Expand Down
1 change: 1 addition & 0 deletions src/dins/core/information_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ async def register_file_information(
accession=file.file_id,
size=file.decrypted_size,
sha256_hash=file.decrypted_sha256,
storage_alias=file.s3_endpoint_alias,
)
file_id = file_information.accession

Expand Down
5 changes: 5 additions & 0 deletions src/dins/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class FileInformation(FileAccession):
description="SHA256 hash of the unencrypted file content encoded as hexadecimal"
" values as produced by hashlib.hexdigest().",
)
storage_alias: str = Field(
default=...,
description="Alias of the storage location where the corresponding file data resides"
" in permanent storage.",
)


class DatasetFileAccessions(BaseModel):
Expand Down
14 changes: 11 additions & 3 deletions tests/test_typical_journey.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,17 @@
)

INCOMING_FILE_PAYLOAD_2 = INCOMING_FILE_PAYLOAD.model_copy(
update={"file_id": FILE_ID_2}
update={"file_id": FILE_ID_2, "s3_endpoint_alias": "test-node-2"}
)
INCOMING_FILE_PAYLOAD_3 = INCOMING_FILE_PAYLOAD.model_copy(
update={"file_id": FILE_ID_3}
update={"file_id": FILE_ID_3, "s3_endpoint_alias": "test-node-3"}
)

FILE_INFORMATION = models.FileInformation(
accession=FILE_ID_1, sha256_hash=DECRYPTED_SHA256, size=DECRYPTED_SIZE
accession=FILE_ID_1,
sha256_hash=DECRYPTED_SHA256,
size=DECRYPTED_SIZE,
storage_alias="test-node",
)

pytestmark = pytest.mark.asyncio()
Expand Down Expand Up @@ -227,11 +230,13 @@ async def test_dataset_information_journey(
"accession": FILE_ID_1,
"size": DECRYPTED_SIZE,
"sha256_hash": DECRYPTED_SHA256,
"storage_alias": "test-node",
},
{
"accession": FILE_ID_2,
"size": DECRYPTED_SIZE,
"sha256_hash": DECRYPTED_SHA256,
"storage_alias": "test-node-2",
},
]

Expand All @@ -256,16 +261,19 @@ async def test_dataset_information_journey(
"accession": FILE_ID_1,
"size": DECRYPTED_SIZE,
"sha256_hash": DECRYPTED_SHA256,
"storage_alias": "test-node",
},
{
"accession": FILE_ID_2,
"size": DECRYPTED_SIZE,
"sha256_hash": DECRYPTED_SHA256,
"storage_alias": "test-node-2",
},
{
"accession": FILE_ID_3,
"size": DECRYPTED_SIZE,
"sha256_hash": DECRYPTED_SHA256,
"storage_alias": "test-node-3",
},
]

Expand Down

0 comments on commit 5e41b4d

Please sign in to comment.