Skip to content

Commit

Permalink
Support python generation (#47)
Browse files Browse the repository at this point in the history
## Description

Support python generation

## Changes Made

* Support python generation
* Restructure folders

## Related Issues

Fixes #46

## Checklist

- [x] I have used a PR title that is descriptive enough for a release
note.
- [ ] I have tested these changes locally.
- [ ] I have added appropriate tests or updated existing tests.
- [ ] I have tested these changes on a dedicated VM or a customer VM
[name of the VM]
- [ ] I have added appropriate documentation or updated existing
documentation.

---------

Co-authored-by: Alberto Moretti <moretti919@gmail.com>
Co-authored-by: Bot <bot@zaphiro.ch>
Co-authored-by: hiimjako <hiimjako@users.noreply.github.com>
  • Loading branch information
4 people authored Mar 25, 2024
1 parent 562ec8c commit e8332e2
Show file tree
Hide file tree
Showing 62 changed files with 2,129 additions and 965 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Golang
name: Protobuf

concurrency:
group: ${{github.repository}}-${{ github.ref_name }}-proto
Expand Down Expand Up @@ -29,8 +29,6 @@ jobs:
- run: git config --global url.https://$GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/
- uses: bufbuild/buf-setup-action@v1
- uses: bufbuild/buf-lint-action@v1
with:
input: "proto"
# - uses: bufbuild/buf-breaking-action@v1
# with:
# # The 'main' branch of the GitHub repository that defines the module.
Expand Down Expand Up @@ -63,5 +61,6 @@ jobs:
git add --all && git commit -m "Buf re-generated protos" || echo "No changes to commit"
git push
golang:
needs: proto
uses: zaphiro-technologies/github-workflows/.github/workflows/golang.yaml@main
secrets: inherit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ go.work
*/.DS_Store
.DS_Store
output.txt
/dist

*.pyc
7 changes: 3 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ linters-settings:
- whyNoLint
- unnamedResult
gofmt:
gofmt:
simplify: false
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
lll:
line-length: 140
misspell:
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ cov:

.PHONY: generate
generate:
cd proto; buf generate
buf generate

.PHONY: docs
docs:
../proto-gen-md-diagrams/proto-gen-md-diagrams -d proto -md true
../proto-gen-md-diagrams/proto-gen-md-diagrams -d zaphiro -md true
mkdir -p docs
# mv -f proto/**/*.md docs #why it works on my mac but not in the action?
mv -f proto/*/v1/*.md docs
# mv -f zaphiro/**/*.md docs #why it works on my mac but not in the action?
mv -f zaphiro/*/v1/*.md docs

.PHONY: proto-lint
proto-lint:
cd proto; buf lint
buf lint

# Mandatory
ci-test: cov
Expand Down
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ At the time being this repository includes the following Protocol Buffer
packages:

- _Grid_ package collects grid related messages, defined in
[`proto/grid/v1`](./proto/grid/v1/), which currently include:
[`zaphiro/grid/v1`](./zaphiro/grid/v1/), which currently include:
- `Data` protocol buffer package, that includes the following messages
- `Data`: a single measurement data
- `DataSet`: a collection of measurement data.
Expand All @@ -36,18 +36,40 @@ packages:
inherited by:
- `GridEvent`: a message that represent grid events.
- _Platform_ package collects platform related messages, defined in
[`proto/platform/v1`](./proto/platform/v1/), which currently include:
[`zaphiro/platform/v1`](./zaphiro/platform/v1/), which currently include:
- `Task`: a task to be performed by an service in the platform.
- `Notification`: a notification produced by a service in the platform.
- _C37118_ package collects messages related to the IEEE c37.118 standard,
defined in [`proto/c37118/v1`](./proto/c37118/v1/), which currently include:
defined in [`zaphiro/c37118/v1`](./zaphiro/c37118/v1/), which currently
include:
- `Conf2Frame`: a Protocol Buffer used to store PMU configuration frames.
- `Stat`: a Protocol Buffer used to store PMU measurement Stat.

## Protocol Buffers Management

All protocol buffers are documented in [docs](./docs).

### Installation

Currently code is generated for:

- [go](go)
- [python](python)

#### Python

Installation was tested with poetry:

```bash
poetry add git+https://github.com/zaphiro-technologies/protobuf.git#v0.0.5
```

#### Go

```bash
go install github.com/zaphiro-technologies/protobuf/go@v0.0.5
```

### Generate Code from Protocol Buffers

```bash
Expand Down
10 changes: 7 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# ProtoBuf Release Notes

## 0.0.5-dev - 2024-03-13
## 0.0.5-dev - 2024-03-22

### Features

- Support python generation (PR #47 by @chicco785)

### Documentation

- Add `aligned` header to Data and DataSet (PR #42 by @hiimjako)

### Dependencies

- Bump google.golang.org/protobuf from 1.32.0 to 1.33.0 (PR #44 by
@dependabot[bot])
- Bump github.com/stretchr/testify from 1.8.4 to 1.9.0 (PR #43 by
@dependabot[bot])
- Bump google.golang.org/protobuf from 1.32.0 to 1.33.0 (PR #44 by
@dependabot[bot])

## 0.0.4-dev - 2024-02-21

Expand Down
8 changes: 8 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: v1
plugins:
- plugin: buf.build/protocolbuffers/go:v1.31.0
out: go
- plugin: buf.build/protocolbuffers/pyi:v26.0
out: python
- plugin: buf.build/protocolbuffers/python:v26.0
out: python
1 change: 1 addition & 0 deletions proto/buf.yaml → buf.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version: v1

breaking:
use:
- FILE
Expand Down
8 changes: 4 additions & 4 deletions docs/conf2.proto.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Package: c37118.v1
# Package: zaphiro.c37118.v1

<!-- markdownlint-disable -->
Messages describing PMU C37.118 Configurations.
Expand Down Expand Up @@ -92,7 +92,7 @@ class Config {

## Message: Conf2Frame

**FQN**: c37118.v1.Conf2Frame
**FQN**: zaphiro.c37118.v1.Conf2Frame

Configuration frame 2
Headers used in rabbitMQ:
Expand All @@ -114,7 +114,7 @@ Headers used in rabbitMQ:

## Message: Conf2Header

**FQN**: c37118.v1.Conf2Header
**FQN**: zaphiro.c37118.v1.Conf2Header

Configuration frame 2 header

Expand All @@ -134,7 +134,7 @@ Configuration frame 2 header

## Message: Config

**FQN**: c37118.v1.Config
**FQN**: zaphiro.c37118.v1.Config

Single PMU configuration according to Configuration frame 2

Expand Down
8 changes: 4 additions & 4 deletions docs/data.proto.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Package: grid.v1
# Package: zaphiro.grid.v1

<!-- markdownlint-disable -->
Messages to support data injection in the platform.
Expand All @@ -24,7 +24,7 @@ Data are grouped into sets, where each id identifies a specific measurement. The

## Enum: DataType

**FQN**: grid.v1.DataType
**FQN**: zaphiro.grid.v1.DataType

The collection of Data Types defined so far. They are useful to map
measurements to their rappresentation. Some of the descriptions are taken from [here](https://github.com/3lbits/Grunnprofil/blob/main/DIGIN10/docs/MeasurementType.adoc) This is important since all measurements
Expand Down Expand Up @@ -187,7 +187,7 @@ DataSet .. ` Data`

## Message: Data

**FQN**: grid.v1.Data
**FQN**: zaphiro.grid.v1.Data

A single data.
Headers used in rabbitMQ (only if not sent as part of `DataSet`):
Expand All @@ -210,7 +210,7 @@ Headers used in rabbitMQ (only if not sent as part of `DataSet`):

## Message: DataSet

**FQN**: grid.v1.DataSet
**FQN**: zaphiro.grid.v1.DataSet

A set of data.
Headers used in rabbitMQ:
Expand Down
24 changes: 12 additions & 12 deletions docs/device_event.proto.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Package: grid.v1
# Package: zaphiro.grid.v1

<!-- markdownlint-disable -->
Messages to support device event detection in the platform. Device events are sub classes of Events.
Expand All @@ -7,9 +7,9 @@ Messages to support device event detection in the platform. Device events are su

## Imports

| Import | Description |
|---------------------|-------------|
| grid/v1/event.proto | |
| Import | Description |
|-----------------------------|-------------|
| zaphiro/grid/v1/event.proto | |



Expand Down Expand Up @@ -150,7 +150,7 @@ DataError --> `DeviceEvent`

## Message: DeviceEvent

**FQN**: grid.v1.DeviceEvent
**FQN**: zaphiro.grid.v1.DeviceEvent

A device event.
Headers used in rabbitMQ:
Expand All @@ -177,7 +177,7 @@ Headers used in rabbitMQ:

## Message: CommunicationError

**FQN**: grid.v1.CommunicationError
**FQN**: zaphiro.grid.v1.CommunicationError



Expand All @@ -191,7 +191,7 @@ Headers used in rabbitMQ:

## Message: TimeQuality

**FQN**: grid.v1.TimeQuality
**FQN**: zaphiro.grid.v1.TimeQuality



Expand All @@ -205,7 +205,7 @@ Headers used in rabbitMQ:

## Message: SyncStatus

**FQN**: grid.v1.SyncStatus
**FQN**: zaphiro.grid.v1.SyncStatus



Expand All @@ -219,7 +219,7 @@ Headers used in rabbitMQ:

## Message: Power

**FQN**: grid.v1.Power
**FQN**: zaphiro.grid.v1.Power



Expand All @@ -233,7 +233,7 @@ Headers used in rabbitMQ:

## Message: Config

**FQN**: grid.v1.Config
**FQN**: zaphiro.grid.v1.Config



Expand All @@ -247,7 +247,7 @@ Headers used in rabbitMQ:

## Message: Trigger

**FQN**: grid.v1.Trigger
**FQN**: zaphiro.grid.v1.Trigger



Expand All @@ -261,7 +261,7 @@ Headers used in rabbitMQ:

## Message: DataError

**FQN**: grid.v1.DataError
**FQN**: zaphiro.grid.v1.DataError



Expand Down
8 changes: 4 additions & 4 deletions docs/event.proto.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Package: grid.v1
# Package: zaphiro.grid.v1

<!-- markdownlint-disable -->
Messages to support event detection in the platform.
Expand All @@ -23,7 +23,7 @@ The event detected may be originated from different sources: devices (e.g. a PMU

## Enum: EventStatus

**FQN**: grid.v1.EventStatus
**FQN**: zaphiro.grid.v1.EventStatus

The collection of Event Status defined so far.

Expand All @@ -39,7 +39,7 @@ The collection of Event Status defined so far.

## Enum: EventSourceType

**FQN**: grid.v1.EventSourceType
**FQN**: zaphiro.grid.v1.EventSourceType



Expand Down Expand Up @@ -116,7 +116,7 @@ Event --> `EventStatus`

## Message: Event

**FQN**: grid.v1.Event
**FQN**: zaphiro.grid.v1.Event

A generic event.
Headers used in rabbitMQ (only if not sent as part of `DataSet`):
Expand Down
Loading

0 comments on commit e8332e2

Please sign in to comment.