-
Notifications
You must be signed in to change notification settings - Fork 17
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
Long-term draft topic: Vsc lib with fixes #31
Conversation
ab2150d
to
a559637
Compare
@@ -0,0 +1,373 @@ | |||
Mozilla Public License Version 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.
This is the same license as in root repo, right? So why do we need this file.
vsclib/setup.py
Outdated
description="VSC Generator Library", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/COVESA/vsclib", |
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.
Will this URL ever exist? Or should it be vsc-tools?
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.
Yes, as of now it seems like it should be vsc-tools.
vsclib/setup.py
Outdated
classifiers=[ | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"License :: Other/Proprietary License", |
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 we use MPL2 - is the license statement here correct? Compare with e.g. https://github.com/mozilla/libmozdata/blob/master/setup.py
Also, here we explictly state Python 3.7 and 3.8, but in buildcheck we use Python 3.10. Is it needed to specify Python version here. (In the long run, but not now, we should preferably perform tests with all Python versions we claim to support. I.e. if we say here that Python 3.7 is sufficient then we shall have a build that verifies that 3.7 actually is sufficient)
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.
-
I agree, the license info looks wrong to me.
-
Yeah the python version in the buildcheck has evolved over time. I seem to recall that it started with a language feature we used that required 3.9, and then the Ubuntu version of the GitHub CI environment underwent some change so it did not support the version we demanded, so it was then changed to 3.10 for the CI to run OK.
In any case, good catch - we should make this consistent and also avoid overspecifying such details.
* Add python setuptools setup.py script. * Move python code to the vsc folder. * Move templates folder to the vsc folder. * Install vscgen tool to simplify codegenerator use via cmd. * Update github actions (use python 3.10 and vscgen). Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
* Implement vehicle service catalog AST using python dataclasses. * Implement parsing of YAML vsc format into vsc AST format. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
* Add simple tests for newly written dataclasses AST. * Add new example YAML files input2.yaml and input3.yaml. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
Take over typic gitignore for python projects from https://github.com/github/gitignore/blob/main/Python.gitignore Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
All the previous code in this file, to read YAML into an AST tree, is now superseded by vsc_ast.py. There are a few files and scripts referring to this file so at the moment it remains as a wrapper around vst_ast but soon it should probably be replaced completely.
(should be no functional change)
- Methods need to be inside a namespace - includes: should be a list - Change one test to output name of main file instead of first namespace See also previous comment
From what I can tell, the new parsing function instantiates all needed fields of all objects in the AST tree (or leaves the field as the default (= None), if something is Optional and not provided by the input YAML. I therefore removed all the post_init functions, here as a separate commit in case we need to test further, rollback, or something. unit-tests and basic template generation seem to run fine (except for those templates that need update, but that is known)
In vscgen tool template argument becomes optional. When vscgen <yaml.file> called it would use default templates from vsc.templates.default_templates dictionary. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
After short discussion we have decided to bring back the AST node. This node is always a root, but inherits everything from the Namespace class. And vsc_parser.gen() function now accepts object of any type. Later we might want to introduce some checks for the passed node, like assert dataclass.is_dataclass(node). Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
Moving all code related to YAML processing to the vsc_parser.py from vsc_ast.py to keep in vsc_ast module only AST nodes. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
Use Any instead of Generic[T] for gen() function. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
Improve setup.py script to properly package and install files inside the templates folder. Now setup.py will install the *.tpl and *.html files into the respective python3 packages directory. This allows to use module independently. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
An attempt to reverse dependencies by moving all the jinja2 related code to the vsc.templates module. This makes vsc_generator.py more abstract and in theory removes dependency on the concrete template engine. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
Making description field empty by default instead of None. Removing Optional[..] from the Lists and using default_factory assigning empty lists by default to avoid additional checks in the templates code. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
Bring back Optional[List[...]] and Optional[str] to some of the fields to bring AST closer to the specification. It would not change the runtime behaviour, lists would have default value [], etc. Fix arraysize type in some of the classes from Optional[str] to Optional[int]. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
Change python version from 3.10.6 to 3.10.7. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
Comments added to the AST classes, using information from the VSC specification and format of python docstrings. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
I noticed some discrepancy in the readme file and rawly fixed all the incosistencies I have been able to find out. Maybe there are bigger changes needed, but I will leave it for the future PRs. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
Remove line "#All right reserved" from the files added by previous MR. Signed-off-by: Mikhail Tsukerman <[email protected]> Signed-off-by: Magnus Feuer <[email protected]>
Signed-off-by: Erik Jaegervall <[email protected]>
Signed-off-by: Erik Jaegervall <[email protected]>
a5a68e9
to
7fcc47f
Compare
Corrected the setup.py file according to the remarks noted above. |
This configures `dacite` to throw an exception if the input (yaml-dict) contains any unexpected data items (usually coming from a misspelled or misplaced keyword in the YAML input). Then we catch the exception and output a message that is as useful as we can, given the information. Signed-off-by: Gunnar Andersson <gunnar_dev@[email protected]>
- Each test is now stored in a subdir under tests. - Each test subdir must be named test.<something>. - gen_test.py loops over those directories and performs the same test as before (generate the given 'input.py' using 'template' and compare to 'result') Signed-off-by: Gunnar Andersson <gunnar@[email protected]>
The test only checks that the expected exception is raised on illegal input. Signed-off-by: Gunnar Andersson <gunnar@[email protected]>
It seems that GitHub bumps the patch level number frequently. (right now from 3.10.7 to 3.10.8) Let's go with 3.10 instead of the more specific 3.10.7 to see if this works more long term.
… a VSC tree Signed-off-by: Magnus Feuer <[email protected]>
Simple fixes according to PR feedback - can be squashed during merge.
byteBuffer is the name used in the current specification
(minor, can be squashed during merge)
It it self-evident from the LICENSE file that this was intended to be MPLv2 licensed and the setup.py script should reflect this. (When it becomes part of vsc-tools, then this setup.py might even be superfluous and therefore removed)
19dadc7
to
8ef8282
Compare
Just rebased on master as a starting point, because there were 34 new commits. |
Reference: #100 implements a more rudimentary version of this support for creating IFEX (previously VSC) definition from within a python program. The constructors provided by #100 are derived directly from the current IFEX language model. The original vsc_lib does a bit more by including code that does type resolution, checking if types are visible through the namespace visibility rules, etc. However, at least the construction of an IFEX interface tree representation is likely covered adequately by #100 now, with the advantage of it being up to date (and automatically up to date when/if the model changes). |
Fixed according to feedback on PR #30. I didn't force push that branch without @magnusfeuer's permission. In any case, I recommend we also squash these small fixes into the original commit, and that we should merge the PR (it still goes to separate branch). What do you think?