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

Add support for experimental features #1053

Merged
merged 7 commits into from
Jan 30, 2019
Merged

Conversation

jamesls
Copy link
Member

@jamesls jamesls commented Jan 28, 2019

Issue #, if available:

#1019

Description of changes:

This adds support for feature flags, as discussed here: #1019 (comment)

This PR branches on top of (and targets) the blueprints branch, so after we merge this PR, we can merge blueprints back to master.

@jamesls
Copy link
Member Author

jamesls commented Jan 28, 2019

The doc linkchecker keeps failing on travis, though I've manually verified that the links work. I've added retries to this link checker: #1054

Copy link
Contributor

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

Looks fine. Just had a comment and a question.

chalice/deploy/validate.py Outdated Show resolved Hide resolved
self.experimental_feature_flags = set()
# This is marked as internal but is intended to be used by
# any code within Chalice.
self._features_used = set()
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I'm not sure if I like this trend of marking something as an internal property and then accessing it in the deployer code. I think we did something similar in blueprints. I get why we are doing it right now, but I'm wondering if there are any alternatives to tell users that it is an internal property? Options that I am thinking include: Just documenting it as internal (somewhat similar to some of the standard library) or having like an property like app.internal_stuff that could be a grab bag for anything that needs to be accessed in the deployer but should not be used in a user's Chalice app.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we've learned that lesson from botocore that this isn't a great idea. It basically comes down to either:

a) We make it public, call it something that's hopefully obvious (e.g. internal_stuff) and document that users shouldn't touch it and hope that they don't.

b) Make it actually internal with a _ prefix, and then we (chalice devs) purposefully access internal attributes we know are safe.

I think (b) is a much safer alternative, especially given that the _ prefix is a much more explicit mechanism. We need the concept of "package private" and I would prefer the option that requires chalice devs to be mindful of what they're accessing (e.g that _features_used is safe) vs. customers knowing that they shouldn't access an attribute called internal_features_used.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with james. I think the convention for a friend-ish class should just be marked private, its a lot safer for everyone involved.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess its fine. The only thing I do not like about the _ prefix is that it can be hard to know which _ properties are public for our development only. The only way to really tell is to look for the comment in the code where it is defined. We also have to be diligent in making sure we test the _ property so we do not accidentally refactor it in a backwards incompatible way (but I think we have a good amount of tests for the ones we have added so that should be fine).

Copy link
Contributor

@stealthycoin stealthycoin left a comment

Choose a reason for hiding this comment

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

Code looks good. Just had some questions about tangential stuff like docs.

chalice/deploy/validate.py Outdated Show resolved Hide resolved
chalice/deploy/validate.py Outdated Show resolved Hide resolved
validate_feature_flags(config.chalice_app)


def validate_feature_flags(chalice_app):
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to have some sort of warning/alert that something has been removed from the feature flag list and is now a stable feature? Looks like it doesn't really matter but if I upgrade chalice and redeploy and blueprints was moved to stable. I will still have my BLUEPRINTS entry in the experimental feature flags list when not necessary.

Copy link
Member

Choose a reason for hiding this comment

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

+1, though it doesn't necessarily need to be added now since we won't be using it yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd prefer not to. I think warnings should only be for things that may cause issues for a user (i.e. a deprecation of something). In this case it's just unnecessary code that runs.

Perhaps in the future we can have a some sort of linting command that can check these things, but I don't think it needs to happen at deploy time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Linting command seems good. Agreed it doesn't need to be deploy time.

must add to the ``app.experimental_feature_flags`` attribute.
The status of an experimental API can be:

* ``Trial`` - You must explicitly opt-in to use this feature.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add a column here for a link to context. PR/Feature request thread or something like that. Especially useful for tracking when/why something was rejected/accepted.

Copy link
Member

Choose a reason for hiding this comment

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

+1

$ chalice deploy
You are using experimental features without explicitly opting in.
Experimental features do not guarantee backwards compatibility and may be removed in the future.
If you still like to use these experimental features, you can opt-in by adding this to your app.py file:
Copy link
Member

Choose a reason for hiding this comment

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

If you would

'You are using experimental features without explicitly opting in.\n'
'Experimental features do not guarantee backwards compatibility '
'and may be removed in the future.\n'
'If you still like to use these '
Copy link
Member

Choose a reason for hiding this comment

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

If you would

validate_feature_flags(config.chalice_app)


def validate_feature_flags(chalice_app):
Copy link
Member

Choose a reason for hiding this comment

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

+1, though it doesn't necessarily need to be added now since we won't be using it yet.

must add to the ``app.experimental_feature_flags`` attribute.
The status of an experimental API can be:

* ``Trial`` - You must explicitly opt-in to use this feature.
Copy link
Member

Choose a reason for hiding this comment

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

+1

@JordonPhillips
Copy link
Member

Looks great!

Copy link
Member Author

@jamesls jamesls left a comment

Choose a reason for hiding this comment

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

Feedback incorporated, I'll take a look at what codecov is complaining about.

chalice/deploy/validate.py Outdated Show resolved Hide resolved
validate_feature_flags(config.chalice_app)


def validate_feature_flags(chalice_app):
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd prefer not to. I think warnings should only be for things that may cause issues for a user (i.e. a deprecation of something). In this case it's just unnecessary code that runs.

Perhaps in the future we can have a some sort of linting command that can check these things, but I don't think it needs to happen at deploy time.

@codecov-io
Copy link

codecov-io commented Jan 29, 2019

Codecov Report

Merging #1053 into blueprints will increase coverage by <.01%.
The diff coverage is 86.2%.

Impacted file tree graph

@@              Coverage Diff               @@
##           blueprints    #1053      +/-   ##
==============================================
+ Coverage       95.45%   95.45%   +<.01%     
==============================================
  Files              27       27              
  Lines            4528     4556      +28     
  Branches          569      574       +5     
==============================================
+ Hits             4322     4349      +27     
- Misses            134      135       +1     
  Partials           72       72
Impacted Files Coverage Δ
chalice/app.py 96.99% <100%> (+0.49%) ⬆️
chalice/deploy/validate.py 100% <100%> (ø) ⬆️
chalice/constants.py 100% <100%> (ø) ⬆️
chalice/cli/__init__.py 86.46% <25%> (-0.94%) ⬇️
chalice/cli/factory.py 92.35% <75%> (-0.51%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 53cfc47...ea22664. Read the comment docs.

@jamesls
Copy link
Member Author

jamesls commented Jan 29, 2019

Not sure what codecov/patch is complaining about, otherwise travis is passing now.

cc @kyleknap @stealthycoin

Copy link
Contributor

@kyleknap kyleknap left a comment

Choose a reason for hiding this comment

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

Yeah I'm not sure why Codecov is saying we are missing coverage for that line. We have a test for the CLI exception. Otherwise 🚢

@jamesls jamesls merged commit ea22664 into aws:blueprints Jan 30, 2019
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.

5 participants