Skip to content

Commit

Permalink
fix: preserve v1.0a14 feature IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmetNSimsek committed Oct 16, 2024
1 parent 7388773 commit a2e4155
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions siibra/features/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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']:
Expand Down

0 comments on commit a2e4155

Please sign in to comment.