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
7 changes: 4 additions & 3 deletions src/biodata_schema/core/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def from_metadata(
cls,
metadata: "Union[Metadata, List[Metadata]]",
process_name: str = "processed",
location: Optional[str] = None,
location: Optional[str] = "",
new_processing: Optional[Processing] = None,
new_quality_control: Optional[QualityControl] = None,
**data_description_kwargs,
Expand Down Expand Up @@ -464,7 +464,8 @@ def from_metadata(
Shortened name for the process or pipeline that was run -
used in creating name of derived asset. Defaults to 'processed'.
location : Optional[str]
Location of the new derived data asset.
Location of the new derived data asset. Defaults to an empty string
when unknown.
new_processing : Optional[Processing]
New processing performed to create this derived asset.
new_quality_control : Optional[QualityControl]
Expand Down Expand Up @@ -528,7 +529,7 @@ def from_metadata(

return cls(
name=derived_dd.name,
location=location,
location="" if location is None else location,
data_description=derived_dd,
subject=subject,
procedures=procedures,
Expand Down
10 changes: 10 additions & 0 deletions tests/test_inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ def setup_method(self):
default_grouping=["modality"],
)

@pytest.mark.parametrize("location_kwargs", [{}, {"location": None}, {"location": ""}])
def test_single_source_without_location(self, location_kwargs):
"""An unknown derived location is represented by an empty string."""
source_location = self.source.location
result = Metadata.from_metadata(self.source, **location_kwargs)

assert result.location == ""
assert result.data_description.data_level == DataLevel.DERIVED
assert self.source.location == source_location

def test_single_source_inherits_subject(self):
"""Subject should be inherited from the single source"""
result = Metadata.from_metadata(
Expand Down
Loading