diff --git a/analysis/webservice/algorithms/DataSeriesList.py b/analysis/webservice/algorithms/DataSeriesList.py index e247bb63..4c287a97 100644 --- a/analysis/webservice/algorithms/DataSeriesList.py +++ b/analysis/webservice/algorithms/DataSeriesList.py @@ -33,11 +33,11 @@ class DataSeriesListCalcHandlerImpl(NexusCalcHandler): path = "/list" description = "Lists datasets currently available for analysis" params = {} - remote_sdaps = RemoteSDAPCache() def __init__(self, tile_service_factory, remote_collections=None, **kwargs): super().__init__(tile_service_factory, **kwargs) self._remote_collections = remote_collections + self.remote_sdaps = RemoteSDAPCache() @cached(ttl=(60 * 60 * 1000)) # 1 hour cached diff --git a/analysis/webservice/redirect/RemoteSDAPCache.py b/analysis/webservice/redirect/RemoteSDAPCache.py index 2568ab18..b3d99842 100644 --- a/analysis/webservice/redirect/RemoteSDAPCache.py +++ b/analysis/webservice/redirect/RemoteSDAPCache.py @@ -37,7 +37,8 @@ def _add(self, url, timeout=2, max_age=3600*24): def get(self, url, short_name): stripped_url = url.strip('/') - if stripped_url not in self.sdap_lists or self.sdap_lists[stripped_url].outdated_at>datetime.now(): + logger.debug("") + if stripped_url not in self.sdap_lists or self.sdap_lists[stripped_url].outdated_at > datetime.now(): self._add(stripped_url) for collection in self.sdap_lists[stripped_url].list: diff --git a/tools/create-remote-conf/__init__.py b/tools/create-remote-conf/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tools/create-remote-conf/create-conf-from-remote.py b/tools/create-remote-conf/create-conf-from-remote.py new file mode 100644 index 00000000..d4bec244 --- /dev/null +++ b/tools/create-remote-conf/create-conf-from-remote.py @@ -0,0 +1,46 @@ +import argparse +import requests +import yaml + + +def parse_args(): + parser = argparse.ArgumentParser(description='Create a collections.yaml config from a remote SDAP', + formatter_class=argparse.ArgumentDefaultsHelpFormatter) + + parser.add_argument('--remote-nexus-list', + help='The url of the remote SDAP server, list end-point', + required=True + ) + + parser.add_argument('--prefix', + help='Add prefix to the remote collection id to form the local collection id', + required=False, + default="") + + return parser.parse_args() + + +def main(): + the_args = parse_args() + r = requests.get(the_args.remote_nexus_list, verify=False) + collection_config = [] + for collection in r.json(): + if 'remoteUrl' not in collection: + collection_config.append( + { + 'id': the_args.prefix + collection['shortName'], + 'path': the_args.remote_nexus_list.removesuffix('/list'), + 'remote-id': collection['shortName'] + } + ) + + with open('./collections.yml', 'w') as outfile: + yaml.dump(collection_config, outfile, default_flow_style=False) + + + + + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/tools/create-remote-conf/requirements.txt b/tools/create-remote-conf/requirements.txt new file mode 100644 index 00000000..f2293605 --- /dev/null +++ b/tools/create-remote-conf/requirements.txt @@ -0,0 +1 @@ +requests