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

Build: refactor logic to validate artifacts output paths #9940

Conversation

humitos
Copy link
Member

@humitos humitos commented Jan 25, 2023

Wrap all the logic into a class method so it's easier to follow and read.
It also remove some duplicated checks of os.path.exists,
making sure we are always using validated paths already.

PR based in #9939 (we can probably close that one and only review this one)

Related #9931

Wrap all the logic into a class method so it's easier to follow and read.
It also remove some duplicated checks of `os.path.exists`,
making sure we are always using _validated_ paths already.
@humitos humitos requested a review from a team as a code owner January 25, 2023 12:09
@humitos humitos requested a review from benjaoming January 25, 2023 12:09
@humitos humitos requested review from ericholscher and removed request for benjaoming January 25, 2023 12:09
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

This looks like a cleaner change 👍

readthedocs/projects/tasks/builds.py Show resolved Hide resolved
Comment on lines +551 to +559
# Check if there are multiple files on artifact directories.
# These output format does not support multiple files yet.
# In case multiple files are found, the upload for this format is not performed.
#
# TODO: we should fail the build for these cases and clearly communicate this.
# to the user. To do this, we need to call this method (``store_build_artifacts``)
# since the ``execute`` method.
# It will allow us to just `raise BuildUserError` and handle it at
# Celery `on_failure` handler.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Check if there are multiple files on artifact directories.
# These output format does not support multiple files yet.
# In case multiple files are found, the upload for this format is not performed.
#
# TODO: we should fail the build for these cases and clearly communicate this.
# to the user. To do this, we need to call this method (``store_build_artifacts``)
# since the ``execute`` method.
# It will allow us to just `raise BuildUserError` and handle it at
# Celery `on_failure` handler.
# Check if there are multiple files in artifact directories.
# These output formats don't support multiple files yet.
# In case multiple files are found, the upload for this format is not performed.
#
# TODO: we should fail the build for these cases and clearly communicate this
# to the user. To do this, we need to call this method (``store_build_artifacts``)
# It will allow us to just `raise BuildUserError` and handle it at
# in the `on_failure` handler.

Wasn't really sure what the second part here was saying with the since the ``execute`` method.?

Copy link
Member Author

Choose a reason for hiding this comment

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

Meh, s/since/from inside/. So, the correct sentence there should be:

we should fail the build for these cases and clearly communicate this to the user. To do this, we need to call this method (store_build_artifacts) from inside the execute method.

Copy link
Member Author

Choose a reason for hiding this comment

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

This comment was removed in the next iteration anyways, since we are calling store_build_artifacts from inside execute now and we can just raise exceptions there.

# since the ``execute`` method.
# It will allow us to just `raise BuildUserError` and handle it at
# Celery `on_failure` handler.
if artifact_type in ("htmlzip", "epub", "pdf"):
Copy link
Member

Choose a reason for hiding this comment

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

Seems this should be using a constant?

readthedocs/projects/tasks/builds.py Show resolved Hide resolved
readthedocs/projects/tasks/builds.py Show resolved Hide resolved
@humitos
Copy link
Member Author

humitos commented Jan 26, 2023

I closed this PR. We are continuing the conversation in #9941. I'll address all the feedback you provided here in that PR. I'm sorry for all these confusions 🙏🏼

@humitos humitos closed this Jan 26, 2023
@stsewd stsewd deleted the humitos/storage-valid-artifacts branch January 26, 2023 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants