-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Playground feature catalog #11592
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
base: main
Are you sure you want to change the base?
Playground feature catalog #11592
Conversation
…d kms-feature catalog files
class SupportStatus(Enum): | ||
""" | ||
Indicates the support on LocalStack in regard to the actual implementation | ||
E.g. | ||
SUPPORTED means that everything is behaving as on AWS | ||
SUPPORTED_MOCKED_ONLY means that the response is the same as on AWS, but there is no actual behavior behind it (e.g. no database created) | ||
SUPPORTED_PARTIALLY_EMULATED means that there is some kind of emulation, but there may be parts missing | ||
NOT_SUPPORTED means this is not implemented at all on LS | ||
""" | ||
|
||
SUPPORTED = 1 | ||
SUPPORTED_MOCKED_ONLY = 2 | ||
SUPPORTED_PARTIALLY_EMULATED = 3 | ||
NOT_SUPPORTED = 4 | ||
|
||
|
||
class ImplementationStatus(Enum): | ||
""" | ||
Indicates implementation status on LS | ||
E.g. | ||
FULLY_IMPLEMENTED means that all (important?) operations are implemented | ||
PARTIALLY_IMPLEMENTED means some selected operations are implemented | ||
EXPERIMENTAL means that there is some implementation, but this feature is still higly experimental | ||
""" | ||
|
||
FULLY_IMPLEMENTED = 1 | ||
PARTIALLY_IMPLEMENTED = 2 | ||
EXPERIMENTAL = 3 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was mainly for testing purpose, I don't think this is the best classification as it seems a bit confusing
) | ||
|
||
|
||
class CreateKey(ApiCoverage): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this approach was suggested by @sannya-singal to document additional limitations.
However, we also iterated over it, and came up with a ApiLimitation
decorator that could take the limitation as input, which may be more practical solution as we don't need to setup subclasses.
implementation_status: ImplementationStatus = ImplementationStatus.FULLY_IMPLEMENTED | ||
support_type: SupportStatus = SupportStatus.SUPPORTED | ||
aws_docs_link: str = "https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html" | ||
api_operations: list = ["CreateKey"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just one suggestion on how to include api_operations.
With the usage as decorators, however, we have shown that we can also link the decorated functions back to the feature-catalog-mapping, which makes this information redundant.
@cloudwatch_feature.Alarm | ||
def delete_alarms_helper(): | ||
pass | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just added this to verify that we can also decorate functions, and that the data will be collected as well.
@kms_api.CreateKey | ||
@ApiLimitation(limitation="Status 'Updating' is not supported.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both, @kms_api.CreateKey
and @ApiLimitation
are used as an example to track api-specific limitations.
The playground.py
script only considers the ApiLimitation
, while in the playgrond_kms_api_limitation.py
we collect the data from the former decorator.
@handler("GenerateDataKeyPair") | ||
@kms_feature.Data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the @handler
decorator without any parameter input somehow interfered with the asf_utils
-tests, I didn't investigate too much and just removed for now. handlers
with input-parameter are handled correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice to see everything coming together in one PR 🎉 I'm a bit biased towards the implementation here since I worked on it, so I'll leave the feedback to Dominik :)
Motivation
With the requirement of having more up-to-date feature documentation, this PR is exploring one approach, where we the documentation will live inside the code base.
This is only a first PoC. It includes the entire feature catalog for KMS, and only a few selected features for cloudwatch.
We added a script that is creating a json-output with the data from this PoC.
Basic Idea
For this PoC the main idea is to have python classes that will document certain features.
E.g. it provides base class
ServiceFeature
, which will then be enhanced by service specific features, likeKmsFeature
. The KmsFeatures in turn can further be split into sub classes, and you can add as many class-attributes as required (e.g. general docs description, limitations, implementation status etc).This part of the feature catalog documentation is static, e.g. the classes itself already document the behavior.
Decorators
The classes can be used as decorators for functions or api-operations. In that case, we can collect the data dynamically, e.g. by iterating through all service-packages and collect the function/operation names and map them to the specific features.
In a similar way, we are suggesting two approaches to document specific limitations for an api-operation.
This could be useful in case we use this docs also for creating the api-coverage docs, and also if you have some specific limitations that you feel shouldn't be part of the python-docs limitation, as they are very specific.
The suggested approaches:
1. Using sub classes for each limitation
There is a class
ApiCoverage
, which should be used a base class for any additional api-limitation that you want to document, e.g.localstack/localstack-core/localstack/feature_catalog/services/kms_api.py
Lines 8 to 21 in 9609dc3
Downside: for every limitation, you have to create a new subclass, maintaining may be more tedious
Advantage: code is not cluttered too much in case there are a lot of limitations
2. Using a generic class to document limitation
Using a decorator
ApiLimitation
that takes an input argumentlimitation
that can be set dynamically for as many operations as required.Downside: if there are a lot of limitations, this may clutter the code (one way to improve this could be to use string constants in that case, that are defined in another file)
Advantage: no need to recreate subclasses
Here is a sample on how this would be applied for both approaches:
localstack/localstack-core/localstack/services/kms/provider.py
Lines 372 to 382 in 9609dc3
General Evaluation
Advantages:
Disadvantages:
Further improvement ideas
Changes
playground.py
to parse the data: