Skip to content

onconova.research.models.dataset

Dataset

Bases: BaseModel

Represents a dataset within a research project.

Attributes:

Name Type Description
name CharField

The name of the dataset.

summary TextField

A brief summary of the dataset (optional).

rules JSONField

Composition rules for the dataset, validated as a list.

project ForeignKey[Project]

Reference to the associated Project.

last_export AnnotationProperty

Timestamp of the last export event.

total_exports AnnotationProperty

Total number of export events.

cohorts_ids AnnotationProperty

List of cohort IDs associated with export events.

cohorts_ids class-attribute instance-attribute

description property

Returns a string describing the dataset.

Returns:

Type Description
str

A formatted description of the dataset.

last_export class-attribute instance-attribute

name class-attribute instance-attribute

project class-attribute instance-attribute

rules class-attribute instance-attribute

summary class-attribute instance-attribute

total_exports class-attribute instance-attribute

save(*args, **kwargs)

Saves the current instance after validating its rules.

This method performs the following steps: 1. Imports the DatasetRule schema for rule validation. 2. Ensures that the 'rules' attribute is a list; raises ValueError if not. 3. Validates each rule in the 'rules' list using DatasetRule.model_validate. 4. Calls the superclass's save method to persist the instance.

Parameters:

Name Type Description Default

args

list

Variable length argument list passed to the superclass save method.

()

kwargs

dict

Arbitrary keyword arguments passed to the superclass save method.

{}

Raises:

Type Description
ValueError

If 'rules' is not a list.

ValidationError

If any rule fails validation via DatasetRule.model_validate.

Source code in onconova/research/models/dataset.py
def save(self, *args, **kwargs):
    """
    Saves the current instance after validating its rules.

    This method performs the following steps:
    1. Imports the DatasetRule schema for rule validation.
    2. Ensures that the 'rules' attribute is a list; raises ValueError if not.
    3. Validates each rule in the 'rules' list using DatasetRule.model_validate.
    4. Calls the superclass's save method to persist the instance.

    Args:
        args (list): Variable length argument list passed to the superclass save method.
        kwargs (dict): Arbitrary keyword arguments passed to the superclass save method.

    Raises:
        ValueError: If 'rules' is not a list.
        ValidationError: If any rule fails validation via DatasetRule.model_validate.
    """
    from onconova.research.schemas.dataset import DatasetRule

    # Validate the rules
    if not isinstance(self.rules, list):
        raise ValueError("Rules must be a valid list")
    for rule in self.rules:
        DatasetRule.model_validate(rule)
    super().save(*args, **kwargs)
runner