Skip to content

Commit

Permalink
Add hiking or biking tag to trip start, fix sanity test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajfabbri committed Jun 1, 2024
1 parent 8752b5e commit 2e25465
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 8 deletions.
2 changes: 1 addition & 1 deletion avro/python/protocols_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_fastavro(self):
fastavro_validate(data, schema)

def test_sanity(self):
protocol = Protocol("sanity", "0.1-example")
protocol = Protocol("Sanity", "0.1-example")
protocol.validate()

def test_protocol(self):
Expand Down
29 changes: 28 additions & 1 deletion docs/generated/version-0.1-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
## Overview

- [trip](#trip) includes schemas:
- [TripType](/protocol/v0.1-example/schema/TripType.avsc)
- [GeomType](/protocol/v0.1-example/schema/GeomType.avsc)
- [TripStart](/protocol/v0.1-example/schema/TripStart.avsc)
- [TripEnd](/protocol/v0.1-example/schema/TripEnd.avsc)
- [sanity](#sanity) includes schemas:
- [Sanity](/protocol/v0.1-example/schema/Sanity.avsc)
## Protocols

### trip
Expand All @@ -21,6 +24,11 @@
*/
protocol Trip {
enum TripType {
Hiking,
Biking
} = Hiking;
enum GeomType {
Point,
Polygon
Expand All @@ -40,12 +48,15 @@ protocol Trip {
/** Trip ID, .e.g '06.1.2024'. */
string trip_id;
/** Hiking or biking? */
TripType trip_type;
/** Number of travellers */
int num_travellers;
/** Location where you started. geoJSON geometry type. Typically a
* Point but could also be a Polygon. */
GeomType type;
GeomType coord_type;
/** geoJSON geometry coordinates, 1 element for Point, at least 4
* points for Polygon. */
Expand All @@ -65,4 +76,20 @@ protocol Trip {
}
}
```
### sanity

```avdl
@namespace("v0.1-example")
protocol Sanity {
record Sanity {
string name;
int count;
float realnum;
array<string> cities;
}
}
```
File renamed without changes.
3 changes: 2 additions & 1 deletion example_data/v0.1-example/TripStart.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"name": "trip_start",
"timestamp": "2024-03-08T20:17:39.926Z",
"trip_id": "05.0.2",
"trip_type": "Hiking",
"num_travellers": 1,
"type": "Polygon",
"coord_type": "Polygon",
"coordinates": [ [-122.5234, 37.7322 ], [-122.5102, 37.8934],
[-122.4234, 37.8120], [-122.4240, 37.7723], [-122.5201, 37.7938] ]
}
11 changes: 8 additions & 3 deletions protocol/v0.1-example/proto3/v0.1-example.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ message TripStart {
string name = 1;
string timestamp = 2;
string trip_id = 3;
int32 num_travellers = 4;
GeomTypeEnum GeomType = 5;
repeated array coordinates = 6;
TripTypeEnum TripType = 4;
int32 num_travellers = 5;
GeomTypeEnum GeomType = 6;
repeated array coordinates = 7;
enum TripTypeEnum {
Hiking = 0;
Biking = 1;
}
enum GeomTypeEnum {
Point = 0;
Polygon = 1;
Expand Down
11 changes: 11 additions & 0 deletions protocol/v0.1-example/sanity.avdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@namespace("v0.1-example")
protocol Sanity {

record Sanity {
string name;
int count;
float realnum;
array<string> cities;
}
}

21 changes: 21 additions & 0 deletions protocol/v0.1-example/schema/Sanity.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type" : "record",
"name" : "Sanity",
"namespace" : "v0.1-example",
"fields" : [ {
"name" : "name",
"type" : "string"
}, {
"name" : "count",
"type" : "int"
}, {
"name" : "realnum",
"type" : "float"
}, {
"name" : "cities",
"type" : {
"type" : "array",
"items" : "string"
}
} ]
}
11 changes: 10 additions & 1 deletion protocol/v0.1-example/schema/TripStart.avsc
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@
"name" : "trip_id",
"type" : "string",
"doc" : "Trip ID, .e.g '06.1.2024'."
}, {
"name" : "trip_type",
"type" : {
"type" : "enum",
"name" : "TripType",
"symbols" : [ "Hiking", "Biking" ],
"default" : "Hiking"
},
"doc" : "Hiking or biking?"
}, {
"name" : "num_travellers",
"type" : "int",
"doc" : "Number of travellers"
}, {
"name" : "type",
"name" : "coord_type",
"type" : {
"type" : "enum",
"name" : "GeomType",
Expand Down
7 changes: 7 additions & 0 deletions protocol/v0.1-example/schema/TripType.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type" : "enum",
"name" : "TripType",
"namespace" : "v0.1-example",
"symbols" : [ "Hiking", "Biking" ],
"default" : "Hiking"
}
10 changes: 9 additions & 1 deletion protocol/v0.1-example/trip.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
*/
protocol Trip {

enum TripType {
Hiking,
Biking
} = Hiking;

enum GeomType {
Point,
Polygon
Expand All @@ -27,12 +32,15 @@ protocol Trip {
/** Trip ID, .e.g '06.1.2024'. */
string trip_id;

/** Hiking or biking? */
TripType trip_type;

/** Number of travellers */
int num_travellers;

/** Location where you started. geoJSON geometry type. Typically a
* Point but could also be a Polygon. */
GeomType type;
GeomType coord_type;

/** geoJSON geometry coordinates, 1 element for Point, at least 4
* points for Polygon. */
Expand Down

0 comments on commit 2e25465

Please sign in to comment.