From cc11896cbd78ec188ce054d7f449defcfb9f538e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Ri=C3=9Fe?= Date: Mon, 19 Aug 2024 16:30:23 +0200 Subject: [PATCH] Remove usage of features unimplemented in CDS beta --- src/datalad_cds/cds_remote.py | 37 ++--------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/src/datalad_cds/cds_remote.py b/src/datalad_cds/cds_remote.py index 2193bba..da57495 100755 --- a/src/datalad_cds/cds_remote.py +++ b/src/datalad_cds/cds_remote.py @@ -1,6 +1,5 @@ import pathlib import subprocess -import time import cdsapi from annexremote import Master, ProtocolError, RemoteError, SpecialRemote @@ -39,44 +38,12 @@ def _is_dry_run(self) -> bool: ) return result.returncode == 0 and result.stdout.strip() == "true" - def _info(self, message: str) -> None: - try: - self.annex.info(message) - except ProtocolError: - pass - def _retrieve_cds(self, spec: datalad_cds.spec.Spec, filename: str) -> None: if self._is_dry_run(): pathlib.Path(filename).write_text(spec.to_json()) return - c = cdsapi.Client(quiet=True, wait_until_complete=False) - r = c.retrieve(spec.dataset, spec.sub_selection) - self._info("CDS request is submitted") - previous_state = "submitted" - sleep_duration = 1.0 - sleep_max = 60.0 - while True: - r.update() - current_state = r.reply["state"] - if current_state != previous_state: - self._info("CDS request is {}".format(current_state)) - if current_state == "completed": - break - if current_state == "failed": - error = r.reply["error"] - raise RemoteError( - "CDS request failed, message: {}, reason: {}".format( - error.get("message"), error.get("reason") - ) - ) - # Exponential backoff - sleep_duration *= 1.5 - if sleep_duration > sleep_max: - sleep_duration = sleep_max - previous_state = current_state - time.sleep(sleep_duration) - self._info("Starting download from CDS") - r.download(filename) + c = cdsapi.Client() + c.retrieve(spec.dataset, spec.sub_selection, filename) def transfer_retrieve(self, key: str, filename: str) -> None: urls = self.annex.geturls(key, "cds:")