def __post_init__()

in ez_wsi_dicomweb/ml_toolkit/dicom_path.py [0:0]


  def __post_init__(self) -> None:
    """Validates path configuration.

    Returns:
      None

    Raises:
      ValueError: Invalid configuration.
    """
    if _REGEX_BASE_ADDRESS.fullmatch(self.base_address) is None:
      raise ValueError('Invalid base_address')
    if (
        self.healthcare_api_version
        and _REGEX_ID_1.fullmatch(self.healthcare_api_version) is None
    ):
      raise ValueError('Healthcare API version')
    if self.project_id and _REGEX_ID_1.fullmatch(self.project_id) is None:
      raise ValueError('Invalid project_id')
    if self.location and _REGEX_ID_1.fullmatch(self.location) is None:
      raise ValueError('Invalid location')
    if self.dataset_id and _REGEX_ID_2.fullmatch(self.dataset_id) is None:
      raise ValueError('Invalid dataset_id')
    if self.store_id and _REGEX_ID_2.fullmatch(self.store_id) is None:
      raise ValueError('Invalid store_id')
    id_count_defined = sum([
        1
        for id in [
            self.project_id,
            self.location,
            self.dataset_id,
            self.store_id,
        ]
        if id
    ])
    if (
        self.study_prefix != 'dicomWeb'
        and self.base_address == _HEALTHCARE_API_URL
    ):
      raise ValueError('Invalid study_prefix')
    if id_count_defined != 0 and id_count_defined != 4:
      raise ValueError('Invalid id')
    if self.study_uid and _REGEX_UID.fullmatch(self.study_uid) is None:
      raise ValueError('Invalid study_uid')
    if self.series_uid and _REGEX_UID.fullmatch(self.series_uid) is None:
      raise ValueError('Invalid series_uid')
    if self.instance_uid and _REGEX_UID.fullmatch(self.instance_uid) is None:
      raise ValueError('Invalid instance_uid')
    self._StudyUidMissing(self.study_uid)
    self._SeriesUidMissing(self.series_uid)