From 50c4e28a02bfe9dc3af20c2ebd88e61856dbcb1e Mon Sep 17 00:00:00 2001 From: fynnbe Date: Mon, 27 May 2024 13:42:15 +0200 Subject: [PATCH] fix trailing slashes --- .../remote_collection.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bioimageio_collection_backoffice/remote_collection.py b/bioimageio_collection_backoffice/remote_collection.py index 7567c2ca..36161d1b 100644 --- a/bioimageio_collection_backoffice/remote_collection.py +++ b/bioimageio_collection_backoffice/remote_collection.py @@ -262,11 +262,11 @@ def partner_ids(self): def get_concepts(self): return [ # general resources outside partner folders - RecordConcept(client=self.client, concept_id=d) + RecordConcept(client=self.client, concept_id=concept_id) for d in self.client.ls("", only_folders=True) - if d.strip("/") not in self.partner_ids + if (concept_id := d.strip("/")) not in self.partner_ids ] + [ # resources in partner folders - RecordConcept(client=self.client, concept_id=pid + "/" + d) + RecordConcept(client=self.client, concept_id=pid + "/" + d.strip("/")) for pid in self.partner_ids for d in self.client.ls(pid + "/", only_folders=True) ] @@ -430,9 +430,9 @@ def draft(self) -> RecordDraft: def get_published_versions(self) -> List[Record]: """Get representations of the published version""" versions = [ - Record(client=self.client, concept_id=self.id, version=v) + Record(client=self.client, concept_id=self.id, version=version) for v in self.client.ls(self.folder, only_folders=True) - if v.strip("/") != "draft" + if (version := v.strip("/")) != "draft" ] versions.sort(key=lambda r: r.info.created, reverse=True) return versions @@ -468,6 +468,7 @@ class RecordBase(RemoteBase, ABC): concept: RecordConcept = field(init=False) def __post_init__(self): + self.concept_id = self.concept_id.strip("/") self.concept = RecordConcept(client=self.client, concept_id=self.concept_id) @property @@ -841,7 +842,7 @@ class Record(RecordBase): @property def id(self) -> str: - return f"{self.concept.id}/{self.version}" + return f"{self.concept_id}/{self.version}" @property def doi(self):