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

"Deprecated by" feature #4950

Closed
wants to merge 2 commits into from
Closed

"Deprecated by" feature #4950

wants to merge 2 commits into from

Conversation

xni
Copy link
Contributor

@xni xni commented Oct 27, 2018

This is a part1 of #4626 feature, which allows admin to specify the alternative.

I will update this PR or place a new one with API update, that shows the alternative to the package maintainer.

@xni xni force-pushed the deprecated-by branch 2 times, most recently from 2ae4229 to cb823e9 Compare October 27, 2018 15:38
Copy link
Member

@di di left a comment

Choose a reason for hiding this comment

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

Added a couple of small nits, but one big thing we want to address here:

It's possible that a deprecated classifier might be replaces by multiple new classifiers, e.g. if a classifier is not specific enough and we need to split it into two more specific classifiers.

I mentioned this in the parent issue but it was easy to overlook:

It would be great if we could optionally identify one or more classifiers which replace a deprecated classifier when deprecating it

I think this is going to require some significant changes to this PR, so I'll hold off on additional review until we address that.

pretend.call(
(
"Deprecated classifier 'Classifier :: For tSeting' "
"in favour of 'Classifier :: For Testing'"
Copy link
Member

Choose a reason for hiding this comment

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

Could you use American-English spelling here for consistency? Sorry! 🙂

# deployment process, but while the previous version of the code is still
# up and running. Thus backwards incompatible changes must be broken up
# over multiple migrations inside of multiple pull requests in order to
# phase them in over multiple deploys.
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove the comments from this migration?

# in favour of classifier A, this will create a circular dependency.
message = (
f"You can not deprecate the classifier "
f"in favour of already deprecated classifier"
Copy link
Member

Choose a reason for hiding this comment

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

American-English here as well please.

@@ -95,6 +95,16 @@ <h3 class="box-title">Deprecate Classifier</h3>
</option>
{% endfor %}
</select>
<label for="deprecated_by">Deprecated in favour of (optional):</label>
Copy link
Member

Choose a reason for hiding this comment

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

American-English here as well please.

<select name="deprecated_by" id="deprecated_by">
<option selected>(Empty)</option>
{% for classifier in classifiers %}
<!-- TODO: mark currently selected package as disabled -->
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand this TODO. Can you either resolve or remove it?

@xni
Copy link
Contributor Author

xni commented Oct 27, 2018

@di, thanks a lot for your comments! I will try to address them asap

@xni
Copy link
Contributor Author

xni commented Oct 28, 2018

@di , Dustin, I've updated my PR, please, take a look when you have a moment! Thank you!

alternatives = get_alternatives(
request.db.query(Classifier)
.filter(Classifier.classifier == first_invalid_classifier)
.limit(1)
Copy link
Member

Choose a reason for hiding this comment

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

The .limit filter is unnecessary if you're using .one below.

host = request.registry.settings.get("warehouse.domain")
classifiers_url = request.route_url("classifiers", _host=host)
alternatives = get_alternatives(
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be as simple as:

alternatives = (
    request.db.query(Classifier)
    .filter(Classifier.classifier == first_invalid_classifier)
    .one()
    .alternatives
)

We don't need to also check if the alternatives are deprecated and have alternatives (although I appreciate you being thorough).

f"deprecated, see {classifiers_url} for a list of valid "
"classifiers."
f"deprecated{alternative_classifiers}. "
f"See {classifiers_url} for a list of valid classifiers."
Copy link
Member

Choose a reason for hiding this comment

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

I think this validation message should say:

Classifier "Whatever" has been deprecated, see https://pypi.org/classifiers/ for a list of valid classifiers.

when there is no alternative, or

Classifier "Whatever" has been deprecated in favor of the following classifier(s): "Something", "Another".

when there are alternatives. The logic can just be simplified to:

if alternatives:
    raise ...
else:
    raise ...

try:
if deprecated_classifier_id in alternative_classifier_ids:
raise ValidationException(
f"You can not deprecate the classifier in favor of itself"
Copy link
Member

Choose a reason for hiding this comment

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

Let's just remove the classifier from the list of possible alternative classifiers, and don't worry about explicitly checking it here. Because this UI is just use by the administrators (and relatively infrequently, at that) we don't need to worry too much about these edge cases, I'd rather just simplify the logic as much as possible.

f"{deprecated_classifier.classifier!r} "
f"in favor of already deprecated classifier "
f"{alternative_classifier.classifier!r}"
)
Copy link
Member

Choose a reason for hiding this comment

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

Ditto here. Let's just filter deprecated classifiers in the UI.


request.session.flash(
f"Deprecated classifier {classifier.classifier!r}", queue="success"
)
Copy link
Member

Choose a reason for hiding this comment

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

I think we can just leave the flash message as-is.

@xni
Copy link
Contributor Author

xni commented Oct 28, 2018

@di , whenever you have a time, please, take a look. Simplified things as much as possible :)

@brainwane
Copy link
Contributor

@xni I see you have a merge conflict here; could you take a look, and leave a comment when you resolve it? Thanks!

@nlhkabu
Copy link
Contributor

nlhkabu commented Sep 15, 2019

Note:
If / when this PR is re-reviewed, we will need to ensure that the template is appropriately translated.

@di di mentioned this pull request Mar 24, 2020
@di di closed this in #7582 Apr 3, 2020
@di
Copy link
Member

di commented Apr 3, 2020

Hi @xni, wanted to let you know that we went a slightly different direction by making the classifiers external to PyPI entirely, which removed the requirement for this feature in Warehouse.

Thanks for your work here, though! Please let us know if you're interested in working on another feature.

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.

4 participants