Skip to content

Commit

Permalink
update source on dataclasses that should contain children
Browse files Browse the repository at this point in the history
  • Loading branch information
JLoveUOA committed Jun 5, 2024
1 parent 9651d51 commit e16a526
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
5 changes: 3 additions & 2 deletions src/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
)

OPTION_CLONE_DIRECTORY = click.option(
"--duplicate_directory","-d",
"--duplicate_directory",
"-d",
type=bool,
is_flag=True,
default=False,
Expand Down Expand Up @@ -183,7 +184,7 @@ def print_lab(
bag_crate: Optional[bool],
collect_all: Optional[bool],
gpg_binary: Optional[Path],
duplicate_directory: Optional[Path]
duplicate_directory: Optional[bool],
) -> None:
"""
Create an RO-Crate based on a Print Lab metadata file
Expand Down
10 changes: 2 additions & 8 deletions src/ingestion_targets/print_lab_genomics/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import src.ingestion_targets.print_lab_genomics.consts as profile_consts
from src.cli.mytardisconfig import SchemaConfig
from src.ingestion_targets.print_lab_genomics.print_crate_dataclasses import (
ExtractionDataset,
MedicalCondition,
Participant,
SampleExperiment,
ExtractionDataset
)
from src.metadata_extraction.metadata_extraction import (
MetadataHanlder,
Expand Down Expand Up @@ -63,12 +63,6 @@ def __init__(
self.metadata_handler = MetadataHanlder(self.api_agent, namespaces)
self.collect_all = collect_all

#
# def _contruct_sensitive_dict(
# self, sensitive_feild_names: list[str]
# ) -> dict[str, Callable[[str], str]]:
# return {field_name: field_name for field_name in sensitive_feild_names}

def datasheet_to_dataframe(
self, input_data_source: Any, sheet_name: str
) -> pd.DataFrame:
Expand Down Expand Up @@ -289,7 +283,7 @@ def parse_dataset(row: pd.Series) -> ExtractionDataset:
additional_properties={},
schema_type="Dataset",
acls=None,
copy_unlisted=row["Crate Children"]
copy_unlisted=row["Crate Children"],
)
return new_dataset

Expand Down
16 changes: 8 additions & 8 deletions src/ingestion_targets/print_lab_genomics/print_crate_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from mytardis_rocrate_builder.rocrate_builder import ROBuilder
from mytardis_rocrate_builder.rocrate_dataclasses.rocrate_dataclasses import (
Dataset,
Experiment,
Dataset
)
from rocrate.model.contextentity import ContextEntity
from rocrate.model.encryptedcontextentity import ( # pylint: disable=import-error, no-name-in-module
Expand All @@ -16,10 +16,10 @@
from slugify import slugify

from src.ingestion_targets.print_lab_genomics.print_crate_dataclasses import (
ExtractionDataset,
MedicalCondition,
Participant,
SampleExperiment,
ExtractionDataset
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -143,8 +143,6 @@ def add_experiment(self, experiment: Experiment) -> ContextEntity:
Args:
experiment (Experiment): The experiment to be added to the crate
"""
# Note that this is being created as a data catalog object as there are no better
# fits
if not isinstance(experiment, SampleExperiment):
return super().add_experiment(experiment)
properties: Dict[str, str | list[str] | dict[str, Any]] = {
Expand Down Expand Up @@ -183,7 +181,6 @@ def add_experiment(self, experiment: Experiment) -> ContextEntity:
)
return self._add_identifiers(experiment, experiment_obj)


def add_dataset(self, dataset: Dataset) -> ContextEntity:
"""Add a dataset to the RO-Crate accounting for if unlisted cildren should be added
Expand All @@ -193,9 +190,12 @@ def add_dataset(self, dataset: Dataset) -> ContextEntity:
# Note that this is being created as a data catalog object as there are no better
# fits
datset_entity = super().add_dataset(dataset)
if not isinstance(dataset, ExtractionDataset):
if not isinstance(dataset, ExtractionDataset):
return datset_entity
if dataset.copy_unlisted:
datset_entity.source = self.crate.source / dataset.directory if self.crate.source else dataset.directory
datset_entity.source = (
self.crate.source / dataset.directory
if self.crate.source
else dataset.directory
)
return datset_entity

Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class SampleExperiment(
schema_type = "DataCatalog"

@dataclass
class ExtractionDataset(Dataset): # type: ignore
class ExtractionDataset(Dataset):
"""Dataset information for extraction of a dataset
that may need to copy unlisted"""
copy_unlisted : bool

0 comments on commit e16a526

Please sign in to comment.