From 428562f82b5e06e06f5bc262ee98540498364cd6 Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Wed, 11 Dec 2024 17:33:15 +0100 Subject: [PATCH] Fixup f9590916a0b related to https://github.com/ESA-APEx/apex_documentation/issues/69 --- src/esa_apex_toolbox/algorithms.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/esa_apex_toolbox/algorithms.py b/src/esa_apex_toolbox/algorithms.py index 38c0e88..b3f5f93 100644 --- a/src/esa_apex_toolbox/algorithms.py +++ b/src/esa_apex_toolbox/algorithms.py @@ -62,6 +62,7 @@ def from_link_object(cls, data: dict) -> UdpLink: title=data.get("title"), ) + @dataclasses.dataclass(frozen=True) class ServiceLink: href: str @@ -123,15 +124,15 @@ def from_ogc_api_record(cls, src: Union[dict, str, Path]) -> Algorithm: udp_link = udp_links[0] if udp_links else None service_links = [ServiceLink.from_link_object(link) for link in links if link.get("rel") == LINK_REL.SERVICE] - if len(udp_links) == 0: - raise InvalidMetadataError("No service links found, the algorithm requires at least one valid service that is known to execute it.") - - + if len(service_links) == 0: + raise InvalidMetadataError( + "No service links found, the algorithm requires at least one valid service that is known to execute it." + ) - pis = [ c for c in properties.get("contacts",[]) if "principal investigator" in c.get("roles",[]) ] + pis = [c for c in properties.get("contacts", []) if "principal investigator" in c.get("roles", [])] pi_org = pis[0].get("organization", None) if pis else None - service_license = data.get("license",None) + service_license = data.get("license", None) return cls( id=data["id"], title=properties.get("title"), @@ -139,7 +140,7 @@ def from_ogc_api_record(cls, src: Union[dict, str, Path]) -> Algorithm: udp_link=udp_link, service_links=service_links, license=service_license, - organization = pi_org + organization=pi_org, )