From a2e4155305b8ae5d45e31bec47ab52ab658d7241 Mon Sep 17 00:00:00 2001 From: Ahmet Nihat Simsek Date: Wed, 16 Oct 2024 14:45:30 +0200 Subject: [PATCH] fix: preserve v1.0a14 feature IDs --- siibra/features/feature.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/siibra/features/feature.py b/siibra/features/feature.py index c2440836..7c8f52ae 100644 --- a/siibra/features/feature.py +++ b/siibra/features/feature.py @@ -271,13 +271,18 @@ def id(self): if self._id: return self._id + if self._prerelease: + name_ = self.name.removeprefix("[PRERELEASE] ") + else: + name_ = self.name + prefix = '' for ds in self.datasets: if hasattr(ds, "id"): prefix = ds.id + '--' break return prefix + md5( - f"{self.name} - {self.anchor}".encode("utf-8") + f"{name_} - {self.anchor}".encode("utf-8") ).hexdigest() def _to_zip(self, fh: ZipFile): @@ -842,12 +847,16 @@ def name(self) -> str: @property def id(self) -> str: + if self._prerelease: + name_ = self.name.removeprefix("[PRERELEASE] ") + else: + name_ = self.name return "::".join(( "cf0", f"{self._feature_type.__name__}", self._encode_concept(self._queryconcept), self.datasets[0].id if self.datasets else "nodsid", - md5(self.name.encode("utf-8")).hexdigest() + md5(name_.encode("utf-8")).hexdigest() )) def __iter__(self) -> Iterator['Feature']: