-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the first version where we generate the initial Protocol Buffer definitions for all the available meta-models. We still do not generate anything for V3.1 as it has not been officially released yet.
- Loading branch information
Showing
11 changed files
with
4,079 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
paths: | ||
- dev_scripts/** | ||
pull_request: | ||
branches: [ 'main' ] | ||
paths: | ||
- dev_scripts/** | ||
|
||
jobs: | ||
Precommit: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ['3.10'] | ||
|
||
defaults: | ||
run: | ||
working-directory: ./dev_scripts | ||
|
||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
pip3 install -e .[dev] | ||
- name: Run precommit.py | ||
run: python3 precommit.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea/ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Contributing | ||
|
||
## Issues | ||
|
||
Please report bugs or feature requests by [creating GitHub issues]. | ||
|
||
[creating GitHub issues]: https://github.com/aas-core-works/aas-core-protobuf/issues | ||
|
||
## In Code | ||
|
||
If you want to contribute in code, pull requests are welcome! | ||
|
||
Please do [create a new issue] before you dive into coding. | ||
It can well be that we already started working on the feature, or that there are upstream or downstream complexities involved which you might not be aware of. | ||
|
||
[create a new issue]: https://github.com/aas-core-works/aas-core-protobuf/issues | ||
|
||
## Definition Generation | ||
|
||
All the generation logic lives in [dev_scripts/](dev_scripts/) (short for "development scripts"). | ||
Dev. scripts are a Python project. | ||
|
||
To install the dev. scripts, create a virtual environment: | ||
|
||
``` | ||
python3 -m venv venv | ||
``` | ||
|
||
Activate it (on Linux): | ||
|
||
``` | ||
source venv/bin/activate | ||
``` | ||
|
||
Or on Windows: | ||
|
||
``` | ||
venv/bin/Scripts/activate | ||
``` | ||
|
||
Once in a virtual environment, install the dependencies to run the generation: | ||
|
||
``` | ||
cd dev_scripts | ||
pip3 install -e . | ||
``` | ||
|
||
Run the definition generation: | ||
|
||
``` | ||
python dev_scripts/aas_core_protobuf_generation/main.py | ||
``` | ||
|
||
If you want to propagate the changes from aas-core-meta or aas-core-codegen, update the dependencies in [dev_scripts/pyproject.toml](dev_scripts/pyproject.toml). | ||
|
||
### Development | ||
|
||
Install a couple of development dependencies (*e.g.*, tools for static code analysis): | ||
|
||
``` | ||
pip3 install -e .[dev] | ||
``` | ||
|
||
Make changes to the code. | ||
|
||
Run the precommit checks: | ||
|
||
``` | ||
python dev_scripts/precommit.py | ||
``` | ||
|
||
If you want to automatically re-format: | ||
|
||
``` | ||
python dev_scripts/precommit.py --overwrite | ||
``` | ||
|
||
### Pull Requests | ||
|
||
**Feature branches**. | ||
We develop using the feature branches, see [this section of the Git book]. | ||
|
||
[this section of the Git book]: https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows | ||
|
||
If you are a member of the development team, create a feature branch directly within the repository. | ||
|
||
Otherwise, if you are a non-member contributor, fork the repository and create the feature branch in your forked repository. | ||
See [this GitHub tutorial] for more guidance. | ||
|
||
[this GitHub tutorial]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork | ||
|
||
**Branch Prefix**. | ||
Please prefix the branch with your Github user name (*e.g.,* ``mristin/Add-some-feature``). | ||
|
||
**Continuous Integration**. | ||
GitHub will run the continuous integration (CI) automatically through GitHub actions. | ||
The CI includes running the tests, inspecting the code, re-building the documentation *etc.* | ||
|
||
### Commit Messages | ||
|
||
The commit messages follow the guidelines from https://chris.beams.io/posts/git-commit: | ||
|
||
* Separate subject from body with a blank line, | ||
* Limit the subject line to 50 characters, | ||
* Capitalize the subject line, | ||
* Do not end the subject line with a period, | ||
* Use the imperative mood in the subject line, | ||
* Wrap the body at 72 characters, and | ||
* Use the body to explain *what* and *why* (instead of *how*). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
# aas-core-protobuf | ||
|
||
Provide Protocol Buffer definitions for AAS meta-models. | ||
|
||
We put the definitions in the directories corresponding to the meta-model version: | ||
* [v3/](v3/) | ||
|
||
If you want to contribute (*e.g.*, update or re-generate the definitions), please see [CONTRIBUTING.md](CONTRIBUTING.md). |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""Generate the Protobuf definitions for AAS meta-models.""" | ||
|
||
import argparse | ||
import os | ||
import pathlib | ||
import sys | ||
|
||
import aas_core_codegen.main | ||
import aas_core_meta.v3 | ||
|
||
|
||
def module_basename(name: str) -> str: | ||
""" | ||
Extract the last name in a qualified module name. | ||
>>> module_basename("aas_core_meta.v3") | ||
'v3' | ||
""" | ||
return name.split(".")[-1] | ||
|
||
|
||
def main() -> int: | ||
"""Execute the main routine.""" | ||
parser = argparse.ArgumentParser(description=__doc__) | ||
parser.parse_args() | ||
|
||
this_path = pathlib.Path(os.path.realpath(__file__)) | ||
|
||
for meta_model in [aas_core_meta.v3]: | ||
assert meta_model.__file__ is not None | ||
model_path = pathlib.Path(meta_model.__file__) | ||
meta_model_basename = module_basename(meta_model.__name__) | ||
|
||
print(f"Generating the definitions for meta-model: {meta_model_basename}") | ||
|
||
codegen_params = aas_core_codegen.main.Parameters( | ||
model_path=model_path, | ||
target=aas_core_codegen.main.Target.PROTOBUF, | ||
snippets_dir=this_path.parent.parent / "snippets" / meta_model_basename, | ||
output_dir=this_path.parent.parent.parent / meta_model_basename, | ||
) | ||
|
||
aas_core_codegen.main.execute( | ||
params=codegen_params, stdout=sys.stdout, stderr=sys.stderr | ||
) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Run the pre-commit on all the files.""" | ||
|
||
import argparse | ||
import os | ||
import pathlib | ||
import subprocess | ||
import sys | ||
|
||
|
||
def main() -> int: | ||
"""Execute the main routine.""" | ||
parser = argparse.ArgumentParser(description=__doc__) | ||
parser.add_argument( | ||
"--overwrite", help="Auto-heal, where possible", action="store_true" | ||
) | ||
args = parser.parse_args() | ||
|
||
overwrite = bool(args.overwrite) | ||
|
||
this_path = pathlib.Path(os.path.realpath(__file__)) | ||
|
||
python_files = [ | ||
str(pth) | ||
for pth in ( | ||
sorted((this_path.parent / "aas_core_protobuf_generation").glob("*.py")) | ||
+ [this_path.parent / "precommit.py"] | ||
) | ||
] | ||
|
||
subprocess.check_call( | ||
["black", "--check"] + python_files | ||
if not overwrite | ||
else ["black"] + python_files | ||
) | ||
|
||
subprocess.check_call(["mypy"] + python_files) | ||
|
||
subprocess.check_call(["pylint"] + python_files) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "aas-core-protobuf-generation" | ||
version = "0.0.1" | ||
|
||
description = "Generate ProtoBuf definitions for AAS meta-models." | ||
readme = "README.md" | ||
requires-python = ">=3.7" | ||
|
||
authors = [ | ||
{ name = "Marko Ristin", email = "[email protected]" } | ||
] | ||
|
||
dependencies = [ | ||
"aas-core-meta@git+https://github.com/aas-core-works/aas-core-meta@f9cbdb3#egg=aas-core-meta", | ||
"aas-core-codegen@git+https://github.com/aas-core-works/aas-core-codegen@6df5c9e8#egg=aas-core-codegen", | ||
] | ||
|
||
[project.urls] | ||
repository = "https://github.com/aas-core-works/aas-core-protobuf" | ||
|
||
license = "MIT" | ||
|
||
[tool.setuptools.packages.find] | ||
include = ["aas_core_protobuf_generation"] | ||
exclude = ["precommit.py"] | ||
|
||
# Development dependencies | ||
[tool] | ||
[tool.black] | ||
line-length = 88 | ||
|
||
[tool.pylint] | ||
disable = ["too-many-locals", "no-member", "duplicate-code"] | ||
|
||
[tool.mypy] | ||
python_version = "3.8" | ||
strict = true | ||
|
||
[project.optional-dependencies] | ||
dev = [ | ||
"black==24.8.0", | ||
"pylint==3.2.7", | ||
"mypy==1.5.1", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aas_core3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
aas_core3_1 |
Oops, something went wrong.