Skip to content

Do not error out if the first download attempt fails for any reason.#16

Merged
gouttegd merged 4 commits into
mainfrom
fix-download
May 26, 2026
Merged

Do not error out if the first download attempt fails for any reason.#16
gouttegd merged 4 commits into
mainfrom
fix-download

Conversation

@gouttegd
Copy link
Copy Markdown
Collaborator

This commit reorders the exception handling logic within the odk-helper download command.

We catch download errors inside the loop on download attempts, rather than outside, so that a failed download attempt (for any reason at all) does not automatically cause the command to error out without even trying the remaining attempts. Only when the last attempt fails do we actually error out.

This fixes INCATools/ontology-development-kit#1349.

This commit reorders the exception handling logic within the `odk-helper
download` command.

We catch download errors _inside_ the loop on download attempts, rather
than _outside_, so that a failed download attempt (for any reason at
all) does not automatically cause the command to error out without even
trying the remaining attempts. Only when the _last_ attempt fails do we
actually error out.

This fixes INCATools/ontology-development-kit#1349.
@gouttegd gouttegd self-assigned this May 23, 2026
@gouttegd gouttegd requested a review from matentzn May 23, 2026 15:22
Comment thread src/incatools/odk/helper.py Outdated
Comment thread src/incatools/odk/download.py
Comment thread src/incatools/odk/helper.py
Comment thread src/incatools/odk/download.py
gouttegd added 2 commits May 26, 2026 11:39
Update the `odk-helper download` command to emit:

* one INFO message indicating the URL that we are currently trying to
  download from;
* one WARNING message if we fail to download from one particular URL,
  unless that URL was the last URL to try (in which case we error out
  instead of logging a warning).
@gouttegd gouttegd requested a review from matentzn May 26, 2026 11:21
raise click.ClickException(f"Cannot download {url}: {e}")
except DownloadError as e:
if i == len(attempts) - 1:
raise click.ClickException(f"Cannot download {url}: {e}")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cosmetic: I assume here that the printed DownloadError always contains the response.status_code (status). If that for some unfathomable reason is not the case I would print it as part of the exception.

@gouttegd gouttegd merged commit fab2bc1 into main May 26, 2026
6 checks passed
@gouttegd gouttegd deleted the fix-download branch May 26, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ODK dev: goplus mirror download fails on .owl.gz with no fallback to .owl

2 participants