-
-
Notifications
You must be signed in to change notification settings - Fork 751
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 new "python_versions" attribute to the pack metadata file #4474
Conversation
complex_semver_match function.
pack.yaml file for future compatibility reasons.
Use semver - it's standard. |
Although semver is standard and which is what we use for st2 version, the python version really doesn't need the level of details. We are really interested in the python major versions. So something like "python_major_versions": [2, 3] is an option too. |
@jeking3 Thanks for your input, but after more thinking about it, I agree with @lakshmi-kannan here. semver is too complicated in this specific scenario. We only care about the major version (so Python 2.x or Python 3.x) and complex semver expression would just confuse end users and pack developers. |
Another thing worth noting - packs will only work with with Python 2.x and Python 3.x versions supported by the platform (aka StackStorm packages and components). This means it makes no sense for pack to also specify Python version beyond the major one (aka also specifying minor and patch version). Minor and patch versions will always be dictated by the platform. Right now that is 2.7.x and 3.6.x. That means that packs which declare support for Python 2 are tested and work with Python 2.7.x and same goes for Python 3. |
make it a list. This attribute specifies which major Python versions the pack works with (2, 3). If this attribute is not specified in pack.yaml, we perform no Python version compatibility check when installing and registering the pack. The check can also be skipped by using --force install flag, but that is at user's own risk and packs are not guaranteed to work. Update affected tests.
I've pushed necessary changes which add new Valid values for that field are "2", "3: and combination of those two. I made it a string, but if other think it makes more sense, I can also make it an integer (I didn't make it an integer because we will never do number like comparisons on it). |
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 a few small comments.
@@ -100,6 +100,22 @@ class PackAPI(BaseAPI): | |||
'">=1.8.0, <2.2.0"', | |||
'pattern': ST2_VERSION_REGEX, | |||
}, | |||
'python_versions': { | |||
'type': 'array', | |||
'description': ('Major Python versiosn supported by this pack. E.g. ' |
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.
Typo "versiosn".
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.
Thanks, will fix it.
'python_versions': { | ||
'type': 'array', | ||
'description': ('Major Python versiosn supported by this pack. E.g. ' | ||
'"2" for Python 2.7.x and "3" for Python 3.6.x'), |
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 will change over time, is it wise to put the minor versions in here? I could see this getting stale.
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.
As mentioned here (#4474 (comment)), the minor and patch version itself are dictated by the StackStorm platform and the packages we ship.
We could also store it here, but I don't think it would serve any good purpose - the information itself would be duplicated and provide no additional value, just potential confusion.
The idea is if you are using official StackStorm packages under Python 2 and pack metadata says it works under Python 2, it should work. Same goes for Python 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.
My point was that the string on line 106 will become incorrect over time.
'maxItems': 2, | ||
'uniqueItems': True, | ||
'additionalItems': True | ||
}, |
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.
What is the default for packs that do not specify it?
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.
We don't specify required=True
which means it's an optional attribute. If it's not provided, we don't perform any checks during pack install and register phase (we just assume it works with the version under which StackStorm is currently running).
That's done for backward compatibility reasons.
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.
Why maxItems
here? This means we have to update this code whenever a new major version of Python is released. Which, granted, doesn't happen all that often, but if packs want to specify a bunch of different values, I don't see how that is a problem.
'3' | ||
] | ||
}, | ||
'minItems': 1, |
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.
Without a default and minItems = 1 will this break all existing packs?
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.
Nope - min items only applies to this attribute when it's provided. If the attribute itself is not provided, minItems
validation check is not performed.
We also have various test cases which cover that scenarios (we have a lot of pack test fixtures without that attribute).
@jeking3 Thanks for taking a look and your feedback. I pushed a fix for the typo and I believe I addressed all of your comments. If I missed something, please let me know. |
'maxItems': 2, | ||
'uniqueItems': True, | ||
'additionalItems': True | ||
}, |
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.
Why maxItems
here? This means we have to update this code whenever a new major version of Python is released. Which, granted, doesn't happen all that often, but if packs want to specify a bunch of different values, I don't see how that is a problem.
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.
My issues were resolved and questions answered to satisfaction.
@blag Re maxItems - that's correct, but it doesn't happen often. And if a new version of Python is released this means we will likely need to update our code and definitely update our packages since we bundle the virtualenv with Python interpreter inside the packages. In short - if a new version for Python is released and some user wants to use it, we will need to update our code (packs CI, etc.) anyway and at that time we will update maxItems as well. |
@Kami Is this feature documented somewhere? |
@armab Not yet - feel free to create an issue and assign it for me. I will go to it in time for v3.0.0. |
|
||
result = action.run(packs=['test3'], abs_repo_base=self.repo_base) | ||
self.assertEqual(result['test3'], 'Success.') | ||
|
||
# Pack requires a version which is not satisfied by current StackStorm version | ||
st2common.util.pack_management.CURRENT_STACKSTROM_VERSION = '2.2.0' | ||
st2common.util.pack_management.CURRENT_STACKSTORM_VERSION = '2.2.0' |
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.
There is definitely a 100 and 1 way to misspell StormStack 😃
@Kami Sounds good, here we go StackStorm/st2docs#870 |
This pull request adds new
python_version
attribute to the pack metadata file.This attribute uses semver notation to specify which Python versions pack works with (e.g.
>= 2.7.0, <= 3.7.0
).The goal is to utilize this attribute for various things:
Once we agree on the attribute "design", I / we will go and manually populate this field for various most commonly used pack based on manual and automated testing (StackStorm-Exchange/ci#61).
Related PR: StackStorm-Exchange/ci#61
Open Questions
I went with semver approach because we already use that for
stackstorm_version
attribute (consistency).After more thought, I think it's too complicated - we could make it simpler by only advertising general python 2 and python 3 compatibility by adding
{"python_versions": "python2": true, "python3": false}
or similar attribute to pack metadata.This attribute is different from
stackstorm_version
one - in StackStorm version case, you might want to specify different minor and patch versions and this should rarely be the case with Python version.What do others think?