Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return exit code 1 if only partial upload #615

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,7 @@ Please add a _short_ line describing the PR you make, if the PR implements a spe
- Logging: Reduce debug level logging and remove logging from root ([#606](https://github.com/ScilifelabDataCentre/dds_cli/pull/606))
- Add separate executables for Ubuntu latest (currently 22.04) and Ubuntu 20.04 ([#604](https://github.com/ScilifelabDataCentre/dds_cli/pull/604))
- Bug: PyInstaller command not valid for Linux and macOS ([#612](https://github.com/ScilifelabDataCentre/dds_cli/pull/612))

# Sprint (2023-02-17 - 2023-03-03)

- Bug: Return error code if not all files have been uploaded ([#615](https://github.com/ScilifelabDataCentre/dds_cli/pull/615))
6 changes: 5 additions & 1 deletion dds_cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,8 +1612,12 @@ def put_data(
dds_cli.exceptions.ApiRequestError,
dds_cli.exceptions.NoKeyError,
dds_cli.exceptions.NoDataError,
dds_cli.exceptions.PartialUploadException,
) as err:
LOG.error(err)
if isinstance(err, dds_cli.exceptions.PartialUploadException):
LOG.warning(err)
else:
LOG.error(err)
sys.exit(1)


Expand Down
22 changes: 14 additions & 8 deletions dds_cli/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ def __printout_delivery_summary(self):
"specifying the same options as you did now. To also overwrite the files "
"that were uploaded, also add the `--overwrite` flag at the end of the command."
)
# Raise exception in order to give exit code 1
raise exceptions.UploadError(
f"{intro_error_message}. \n"
f"{retry_message} \n\n"
f"See {self.failed_delivery_log} for more information."
)
else:
# TODO: --destination should be able to >at least< overwrite the files in the
# previously created download location.
Expand All @@ -218,16 +224,16 @@ def __printout_delivery_summary(self):
"specifying the same options as you did now. A new directory will "
"automatically be created and all files will be downloaded again."
)

dds_cli.utils.stderr_console.print(
f"{intro_error_message}. \n"
f"{retry_message} \n\n"
f"See {self.failed_delivery_log} for more information."
)
dds_cli.utils.stderr_console.print(
f"{intro_error_message}. \n"
f"{retry_message} \n\n"
f"See {self.failed_delivery_log} for more information."
)

elif nr_uploaded:
dds_cli.utils.console.print(
(f"\nUpload completed!\n{nr_uploaded} files were already uploaded.\n")
# Raise exception in order to give exit code 1
raise exceptions.PartialUploadException(
f"{nr_uploaded} files were already uploaded.\nUpload [bold]partially[/bold] completed!\n"
)

else:
Expand Down
4 changes: 4 additions & 0 deletions dds_cli/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ class UploadError(Exception):
"""Errors relating to file uploads."""


class PartialUploadException(Exception):
"""Exception raised when some files failed to upload."""


class DownloadError(Exception):
"""Errors relating to file download."""

Expand Down